Skip to content
mkind edited this page Aug 29, 2016 · 28 revisions

This document specifies the protocol used by the splonebox to communicate with clients. The protocol is based on msgpack-rpc.

API requests

All API requests are based on the msgpack-rpc request type:

[0, msgid, method, params]

All request expect a single response witch should be handled either by the core or by the clients. Responses may be errors or results carrying meta information.

API response

All API responses are based on the msgpack-rpc response type:

[1, request_msgid, error, result]

Error responses

Invalid request fails at server

Invalid request fails at client

Errors may occur at the server or at a remote client. Either way the response has this form:

[1, request_msgid, [errno, "Error description"], nil]

Register API call

The register call is intended to be handled, if valid, by the core.:

[
	msgid, # some random number.
	type,  # 0 Since it is a Request Type
	method, # "register" for obvious reasons
	[
		[                          # Metadata
			<plugin name>,
			<description>,
			...
		],
		[                          # List of functions
			[                      # Function description
				<function name>,
				<function descripton>,
				[<arg (="")>, <arg(=0)>] # Some Value is given to identify the type
			],
			[
				...
      		]
		]

	]
]

Valid call

If the register call was successful the following message should be returned by the core:

[1 , request_msgid, nil, []]

(There might be some information to respond in the future. [] is currently a placeholder)

Get Registered API call [WIP]

This call returns the registered plugins:

[
	msgid, # some random number.
	type,  # 0 Since it is a Request Type
	method, # "getregistered" 
	[]
]

Response

  [
     1 , # since it's a respone
     msgid, # echoing request id
     nil, # no error
     [# list of registered plugins
       [  # Metadata
           <plugin ID>,
           <plugin name>,
           <description>,
           ...
        ],
        [ # List of functions
           [ # Function description
                <function name>,
                <function descripton>,
                [<arg (="")>, <arg(=0)>]
            ],
            [ # next function of plugin
               ...
            ]
        ],
        ... # next plugin
  ]

Run API call

A run call is verified by the core and forwarded to the corresponding client. [WIP] A call identifier should be generated by the server and sent in the response to the executing client. The executing client sends 'nil' instead of the call_id and waits for the response to get the id.

[
  	msgid, # id of the request we are responding to
	type,  # 0 Since it is a Request Type (See :class: `Message`)
	method, # "run" for obvious reasons
	[
    [                          # Metadata
	   <target plugin key>,
	   <call id>
	  ],
		<function name>,
		[                          # Functions
			<arg1>,
			<arg2>,
			...
		]
	]
]

Valid call

client1 to core

Client1 doesn't know the 'call_id' yet. The targets identifier (plugin key) must be provided to allow multiple instances of one plug-in.

core to client2

After validating the message, the core creates an unique 'call_id' and forwards the message to client2. To avoid redundancy the plugin's identifier (plugin key) is not set. (If the identifier is set, the message is considered invalid)

client2 to core to client1

For response messages it is mandatory that client1 receives the 'call_id' specified by the core.

If the run call was successful the following message should be returned by the executing client:

[1 , request_msgid, nil, [call_id]]

Result API call [WIP]

A result call is sent by an executing client after an execution has terminated successfully.

[
  0,  # request
  m_id, # random number
  "result",
  [
    [
      call_id # call id specified by the core @ run call
    ],
    [
      <result>
    ]
  ]
]

Stop API call [WIP]

Terminates the execution of the run call which is identified by call_id

[
  0,  # request
  m_id, # random number
  "stop",
  [
    call_id # call id specified by the core @ run call    
  ]
]