Skip to content

OOCSI client for Websocket protocol; allows access to OOCSI from HTML, iOS webview, Android webview, etc.

License

Notifications You must be signed in to change notification settings

iddi/oocsi-websocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OOCSI websocket client

This OOCSI client allows access to OOCSI from HTML, iOS web views and Android web views via the websocket protocol.

How to use

First, include the JavaScript source (either as the source library or as the minified library) into the HTML page.

Connecting

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).

Sending data

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);

Receiving 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;
});

About

OOCSI client for Websocket protocol; allows access to OOCSI from HTML, iOS webview, Android webview, etc.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published