https://github.com/iddi/oocsi-nodejs
OOCSI library for Node.js
https://github.com/iddi/oocsi-nodejs
Last synced: 5 months ago
JSON representation
OOCSI library for Node.js
- Host: GitHub
- URL: https://github.com/iddi/oocsi-nodejs
- Owner: iddi
- License: apache-2.0
- Created: 2019-05-12T18:08:38.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-16T19:11:10.000Z (over 4 years ago)
- Last Synced: 2025-10-20T16:14:40.812Z (8 months ago)
- Language: JavaScript
- Size: 11.8 MB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OOCSI client for Node.js
This OOCSI client allows access to OOCSI from Node.js via the websocket protocol.
# How to install
With NPM installed, type in your console:
```bash
npm install oocsi
```
# How to use
Then connect to an OOCSI server (which needs to be running a websocket adapter):
```javascript
var OOCSI = require('oocsi');
OOCSI.connect("ws://_SERVER_ADDRESS_/ws");
// or with specified client handle
OOCSI.connect("ws://_SERVER_ADDRESS_/ws", "client_handle");
// use wss:// for a secure connection if that's supported by your OOCSI server
OOCSI.connect("wss://_SERVER_ADDRESS_/ws", "client_handle");
```
You can send data to a channel or individual client (here: "John"):
```javascript
// 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:
```javascript
OOCSI.subscribe("testchannel", function(msg) {
// handle message on “test channel"
var position = msg.data.position;
var color = msg.data.color;
});
```