Skip to content

Ipc API

Jannes P edited this page Jun 19, 2018 · 4 revisions

The current implementation of the IPC api uses two namedpipes (one in each direction) To connect simply connect both pipes and send the same unique token from them. pseudocode:

connectPipeIn(addr).writeToken("some unique thing");
connectPipeOut(addr).writeToken("some unique thing");
//after this youll get an OK in the pipe in your direction.

For reference look at the C#/java implementation.

The messages are a litte-endian 4 byte signed int followed by a string in UTF-8. The int is the message length of the following string in bytes. As an example implementation of this you should probably look at the Java implementation: StreamString.java

The string is a JSON encoded object of the following structure:

{
    "MessageCode": int, //list below
    "Data": object | null | undefined
}
/* these messages can be sent in both directions */
Unset = 0 //this is not actually send, it's basically the default for most JSON parsers
Debug = 1
Error = 2

/* the following are send to the server, responses are returned with the same code (if any)*/
//GetPeripheralInfo = 100 THIS HAS BEEN REMOVED (mentioned here to not reassign the 100)
//data taken from /wiki/Internal-API-Device-Context#set_layout
SetPeripheralLayout = 101
//data taken from /wiki/Internal-API-Device-Context#set_element_param
SetPeripheralElementParam = 102
//this implies that you got control after the message was sent to the server
ClaimControl = 103
//Indicates that you don't need control at the moment. You can still always get control back with ClaimControl.
FreeControl = 104

/* the following are send to the client */
//data copied from Internal Device API EventFired
PeripheralEventFired = 200
//no data
PeripheralDisconnected = 201
//data copied from /wiki/Internal-API-Device-Context#get_info
PeripheralConnected = 202
example: {
    "MessageCode": 202,
    "Data": { 
    	version: int,
        screen_type: tablet | phone | generic
        screen_width: int,	//number without any specific unit
        screen_height: int	//^
    }
}
//send if you lost control (eg somebody else claimed it)
ControlLost = 203
//send when no connected IPC client is in control at the moment
NotClaimed = 204
Clone this wiki locally