38     """ Handles the operation-specific logic of a rosbridge message 
   40     May define one or more opcodes to handle, for example 'publish' or 
   43     Each connected client receives its own capability instance, which are 
   44     managed by the client's own protocol instance. 
   46     Protocol.send() is available to send messages back to the client. 
   51         """ Abstract class constructor.  All capabilities require a handle to 
   52         the containing protocol. 
   55         protocol -- the protocol instance for this capability instance 
   61         """ Handle an incoming message. 
   63         Called by the protocol after having already checked the message op code 
   66         message -- the incoming message, deserialized into a dictionary 
   72         """ Notify this capability that the client is finished and that it's 
   73         time to free up resources. """ 
   77         """ Performs basic typechecking on fields in msg. 
   80         msg        -- a message, deserialized into a dictoinary 
   81         types_info -- a list of tuples (mandatory, fieldname, fieldtype) where 
   82                 mandatory - boolean, is the field mandatory 
   83                 fieldname - the name of the field in the message 
   84                 fieldtypes - the expected python type of the field or list of types 
   87         MissingArgumentException -- if a field is mandatory but not present in 
   89         InvalidArgumentException -- if a field is present but not of the type 
   90         specified by fieldtype 
   93         for mandatory, fieldname, fieldtypes 
in types_info:
 
   94             if mandatory 
and fieldname 
not in msg:
 
   96             elif fieldname 
in msg:
 
   97                 if not isinstance(fieldtypes, tuple):
 
   98                     fieldtypes = (fieldtypes, )
 
  100                 for typ 
in fieldtypes:
 
  101                     if isinstance(msg[fieldname], typ):
 
  104                     raise InvalidArgumentException(
"Expected field %s to be one of %s. Invalid value: %s" % (fieldname, fieldtypes, msg[fieldname]))