Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jchristn/watsonwebsocketjs
Javascript client for Watson Websocket
https://github.com/jchristn/watsonwebsocketjs
javascript message messaging rpc watson-websocket web websocket
Last synced: about 2 months ago
JSON representation
Javascript client for Watson Websocket
- Host: GitHub
- URL: https://github.com/jchristn/watsonwebsocketjs
- Owner: jchristn
- License: mit
- Created: 2017-05-28T21:47:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-07-01T05:52:56.000Z (over 7 years ago)
- Last Synced: 2024-10-04T06:47:17.965Z (4 months ago)
- Topics: javascript, message, messaging, rpc, watson-websocket, web, websocket
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.TXT
Awesome Lists containing this project
README
# Watson Websocket Javascript SDK
Lightweight Javascript SDK to access a server using Watson Websocket.
## Setup
Download Watson Websocket from here: https://github.com/jchristn/watsonwebsocket## Test App
```
npm install prompt
npm install ws
node test.js
```## Simple Example
Include the SDK.
```
const Watson = require("watsonwebscket");
```Define callbacks.
```
function onConnect(data) { }
function onDisconnect(data) { }
function onMessage(data) { }
function onError(data) { }
```Initialize the SDK.
```
var watson = new Watson(
"localhost", // hostname of the Watson Websocket server
8002, // TCP port number
false, // enable or disable SSL
true, // enable or disable debug logging
onConnect, // callback for when the connection is established
onDisconnect, // callback for when the connection is broken
onMessage, // callback for when a message is received
onError // callback for when an error is encountered
);
```