IRPC defines the protocol in layers, which are configurable inside the implementation to allow future changes or different versions of IRPC.
Take into account that IRPC is a session oriented protocol, the connection is open once, and is reused infinitely over all queries.
First of all, IRPC is a stream protocol. It works whenever the points are connected through a stream. In practice, this would be a TCP/IP stack, but in practice is anything which can connect the two parts and recieves and sends the data in order and with error control.
For TCP/IP we use a socket. One of the parts has to place a listener socket (generally is the service) and once the connection is stablished, we can use that link to send our data.
All in IRPC are messages, and those are ended with \n
(this character is reserved for this use). The first character of a message is the message type. Probably we can have up to 90 message types, but actually we’re using mainly two:
!
: A request to the other part of the connection.>
: A response to a previous command from the other end.Each message type can have its own format and decoders, but generally they share the same structure. Generally, all messages have several fields separated by tabs \t
, in those commands that character is reserved for that use.
Commands must follow this syntax:
!
call
@3a
\t
\n
A parameter can be an internal parameter, or an external argument, depending on the case the syntax is:
param_name:raw_value
arg_name:json_value
[a-zA-Z][a-zA-Z0-9_]*
. Optionally they could be empty, meaning that is an ordered argument call, but that method is discouraged.Some command examples:
!call fn:sortlist lista=[5,2,7,9,1,6,3,7,4,2,8,0]
!help fn:reverselist
!monitor@mo2787 ev:testEvent
Command names are also defined by the IRPC, and at the moment the list of command names is:
NOTE: Actual implementation of monitor doesn’t allow stop yet.
Responses follow this format:
>
3a
\t
\t
\n
Some examples of response:
> "getFunctionList(self) method of irpcchatter.CMD_Execute instance\n"
>01 "signal testEvent(item)"
> null
IRPC also defines some base functions for introspection, authentication, and some more. There is a list of the existent functions at the moment:
Actually there aren’t any predefined events in IRPC, but it is possible to have some in the future.
the actual system for event or signal notification doesn’t follow the rest of the standard, so it will be replaced with:
Before, the monitoring of an event was done in this way:
!call@mo123 monitor ev:testEvent
and there was some inconsistency on the return value (there was more than one per call to monitor)
now it will be:
!callback add:callbackName ev:testEvent
it will add a callback named callbackName and will be called whenever the event testEvent is fired. A message will be recieved like:
!callback fired:callbackName arg1=2val1' arg2='val2'
And a callback can be removed like:
!callback remove:callbackName
Some possible advantages:
Adding conditions for calling a callback:
!callback add:callbackName ev:testEvent where={
'objecttype.equals' : 'string'}
Adding new static arguments for calling a callback:
!callback add:callbackName ev:testEvent addargs={'special' : True}
!callback fired:callbackName arg1='val1' arg2='val2' special=True
Discarding arguments:
!callback add:callbackName ev:testEvent rmargs=['arg1']
!callback fired:callbackName arg2='val2'