This OOCSI client allows access to OOCSI from HTML, iOS web views and Android web views via the websocket protocol.
First, include the JavaScript source (either as the source library or as the minified library) into the HTML page.
Then connect to an OOCSI server (which needs to be running a websocket adapter):
OOCSI.connect('wss://_SERVER_ADDRESS_/ws');
You need to replace _SERVER_ADDRESS_
by the actually address of the server that you want to connect to. Use ws://
for non-secure connections and wss://
for secure connections (<-- default).
You can send data to a channel or individual client (here: "John"):
// JSON data object with two items, position and color
var data = {'position' : 90, 'color': 255};
// send data object to client "John"
OOCSI.send("John", data);
You can subscribe to a channel with a handler to handle messages:
OOCSI.subscribe("testchannel", function(msg) {
// handle message on “test channel"
var position = msg.data.position;
var color = msg.data.color;
});