class documentation

class Protocol:

Constructor: Protocol(client_id)

View In Hierarchy

The interface for a single client to interact with ROS.

See rosbridge_protocol for the default protocol used by rosbridge

The lifecycle for a Protocol instance is as follows: - Pass incoming messages from the client to incoming - Propagate outgoing messages to the client by overriding outgoing - Call finish to clean up resources when the client is finished

Method __init__ Keyword arguments: client_id -- a unique ID for this client to take. Uniqueness is important otherwise there will be conflicts between multiple clients with shared resources
Method add_capability Add a capability to the protocol.
Method deserialize Turns the wire-level representation into a dictionary of values
Method finish Indicate that the client is finished and clean up resources.
Method incoming Process an incoming message from the client
Method log Log a message to the client. By default just sends to stdout
Method outgoing Pass an outgoing message to the client. This method should be overridden.
Method register_operation Register a handler for an opcode
Method send Called internally in preparation for sending messages to the client
Method serialize Turns a dictionary of values into the appropriate wire-level representation.
Method unregister_operation Unregister a handler for an opcode
Class Variable busy Undocumented
Class Variable external_service_list Undocumented
Class Variable parameters Undocumented
Instance Variable bson_only_mode Undocumented
Instance Variable buffer Undocumented
Instance Variable capabilities Undocumented
Instance Variable client_id Undocumented
Instance Variable delay_between_messages Undocumented
Instance Variable fragment_size Undocumented
Instance Variable old_buffer Undocumented
Instance Variable operations Undocumented
Instance Variable png Undocumented
def __init__(self, client_id):

Keyword arguments: client_id -- a unique ID for this client to take. Uniqueness is important otherwise there will be conflicts between multiple clients with shared resources

def add_capability(self, capability_class):

Add a capability to the protocol.

This method is for convenience; assumes the default capability constructor

Keyword arguments: capability_class -- the class of the capability to add

def deserialize(self, msg, cid=None):

Turns the wire-level representation into a dictionary of values

Default behaviour assumes JSON. Override to use a different container.

Keyword arguments: msg -- the wire-level message to deserialize cid -- (optional) an ID associated with this. Is logged on error

Returns a dictionary of values

def finish(self):

Indicate that the client is finished and clean up resources.

All clients should call this method after disconnecting.

def incoming(self, message_string=''):

Process an incoming message from the client

Keyword arguments: message_string -- the wire-level message sent by the client

def log(self, level, message, lid=None):

Log a message to the client. By default just sends to stdout

Keyword arguments: level -- the logger level of this message message -- the string message to send to the user lid -- an associated for this log message

def outgoing(self, message):

Pass an outgoing message to the client. This method should be overridden.

Keyword arguments: message -- the wire-level message to send to the client

def register_operation(self, opcode, handler):

Register a handler for an opcode

Keyword arguments: opcode -- the opcode to register this handler for handler -- a callback function to call for messages with this opcode

def send(self, message, cid=None, compression='none'):

Called internally in preparation for sending messages to the client

This method pre-processes the message then passes it to the overridden outgoing method.

Keyword arguments: message -- a dict of message values to be marshalled and sent cid -- (optional) an associated id

def serialize(self, msg, cid=None):

Turns a dictionary of values into the appropriate wire-level representation.

Default behaviour uses JSON. Override to use a different container.

Keyword arguments: msg -- the dictionary of values to serialize cid -- (optional) an ID associated with this. Will be logged on err.

Returns a JSON string representing the dictionary

def unregister_operation(self, opcode):

Unregister a handler for an opcode

Keyword arguments: opcode -- the opcode to unregister the handler for

busy: bool =

Undocumented

external_service_list: dict =

Undocumented

parameters =

Undocumented

bson_only_mode =

Undocumented

buffer =

Undocumented

capabilities: list =

Undocumented

client_id =

Undocumented

delay_between_messages =

Undocumented

fragment_size =

Undocumented

old_buffer =

Undocumented

operations: dict =

Undocumented

png =

Undocumented