Public Member Functions | Public Attributes | Static Public Attributes | List of all members
rosbridge_library.protocol.Protocol Class Reference
Inheritance diagram for rosbridge_library.protocol.Protocol:
Inheritance graph
[legend]

Public Member Functions

def __init__ (self, client_id)
 
def add_capability (self, capability_class)
 
def deserialize (self, msg, cid=None)
 
def finish (self)
 
def incoming (self, message_string="")
 
def log (self, level, message, lid=None)
 
def outgoing (self, message)
 
def register_operation (self, opcode, handler)
 
def send (self, message, cid=None)
 
def serialize (self, msg, cid=None)
 
def unregister_operation (self, opcode)
 

Public Attributes

 bson_only_mode
 
 buffer
 
 capabilities
 
 client_id
 
 delay_between_messages
 
 old_buffer
 
 operations
 

Static Public Attributes

bool bson_only_mode = False
 
string buffer = ""
 
bool busy = False
 
int delay_between_messages = 0
 
dictionary external_service_list = {}
 
 fragment_size = None
 
string old_buffer = ""
 
 parameters = None
 
 png = None
 

Detailed Description

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

Definition at line 64 of file protocol.py.

Constructor & Destructor Documentation

def rosbridge_library.protocol.Protocol.__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

Definition at line 95 of file protocol.py.

Member Function Documentation

def rosbridge_library.protocol.Protocol.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

Definition at line 358 of file protocol.py.

def rosbridge_library.protocol.Protocol.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

Definition at line 302 of file protocol.py.

def rosbridge_library.protocol.Protocol.finish (   self)
Indicate that the client is finished and clean up resources.

All clients should call this method after disconnecting.

Definition at line 267 of file protocol.py.

def rosbridge_library.protocol.Protocol.incoming (   self,
  message_string = "" 
)
Process an incoming message from the client

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

Definition at line 113 of file protocol.py.

def rosbridge_library.protocol.Protocol.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

Definition at line 370 of file protocol.py.

def rosbridge_library.protocol.Protocol.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

Definition at line 216 of file protocol.py.

def rosbridge_library.protocol.Protocol.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

Definition at line 338 of file protocol.py.

def rosbridge_library.protocol.Protocol.send (   self,
  message,
  cid = 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

Definition at line 226 of file protocol.py.

def rosbridge_library.protocol.Protocol.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

Definition at line 276 of file protocol.py.

def rosbridge_library.protocol.Protocol.unregister_operation (   self,
  opcode 
)
Unregister a handler for an opcode

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

Definition at line 348 of file protocol.py.

Member Data Documentation

bool rosbridge_library.protocol.Protocol.bson_only_mode = False
static

Definition at line 91 of file protocol.py.

rosbridge_library.protocol.Protocol.bson_only_mode

Definition at line 109 of file protocol.py.

string rosbridge_library.protocol.Protocol.buffer = ""
static

Definition at line 81 of file protocol.py.

rosbridge_library.protocol.Protocol.buffer

Definition at line 120 of file protocol.py.

bool rosbridge_library.protocol.Protocol.busy = False
static

Definition at line 83 of file protocol.py.

rosbridge_library.protocol.Protocol.capabilities

Definition at line 103 of file protocol.py.

rosbridge_library.protocol.Protocol.client_id

Definition at line 102 of file protocol.py.

int rosbridge_library.protocol.Protocol.delay_between_messages = 0
static

Definition at line 87 of file protocol.py.

rosbridge_library.protocol.Protocol.delay_between_messages

Definition at line 108 of file protocol.py.

dictionary rosbridge_library.protocol.Protocol.external_service_list = {}
static

Definition at line 89 of file protocol.py.

rosbridge_library.protocol.Protocol.fragment_size = None
static

Definition at line 78 of file protocol.py.

string rosbridge_library.protocol.Protocol.old_buffer = ""
static

Definition at line 82 of file protocol.py.

rosbridge_library.protocol.Protocol.old_buffer

Definition at line 211 of file protocol.py.

rosbridge_library.protocol.Protocol.operations

Definition at line 104 of file protocol.py.

rosbridge_library.protocol.Protocol.parameters = None
static

Definition at line 93 of file protocol.py.

rosbridge_library.protocol.Protocol.png = None
static

Definition at line 79 of file protocol.py.


The documentation for this class was generated from the following file:


rosbridge_library
Author(s): Jonathan Mace
autogenerated on Wed Jun 3 2020 03:55:14