Web Socket

Generic Web Socket Module

Author:Juti Noppornpitak
Status:Stable
Last Update:November 29, 2013
class tori.socket.websocket.WebSocket(*args, **kwargs)

Web Socket Handler with extension to session controller

component(name, fork_component=False)

Get the (re-usable) component from the initialized Imagination component locator service.

Parameters:
  • name – the name of the registered re-usable component.
  • fork_component – the flag to fork the component
Returns:

module, package registered or None

session

Session Controller

Return type:tori.session.controller.Controller

Remote Procedure Call Module

Author:Juti Noppornpitak
Status:Stable/Testing
Last Update:November 29, 2013
class tori.socket.rpc.Interface(*args, **kwargs)

Remote Interface

Extends from tori.socket.websocket.WebSocket

on_message(message)

The parameter message is supposed to be in JSON format:

{
    ["id":      unique_id,]
    ["service": service_name,]
    ["data":    parameter_object,]
    "method":  method_name
}

When the service is not specified, the interface will act as a service.

class tori.socket.rpc.Remote(method, id=None, data=None, service=None)

RPC Request

Parameters:
  • method (str) – the name of the method
  • id – the request ID (default with unix timestamp)
  • data (dict) – method parameters
  • service (str) – the ID of the registered component/service (optional)
call()

Execute the request

Returns:the result of the execution
class tori.socket.rpc.Response(result, id)

RPC Response

Parameters:
  • result – the result from RPC
  • id – the response ID
Read the Docs v: v2.1
Versions
latest
v2.1
v2.0
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.