js-flux
v2.0.1
Published
Datagram send and receive over binary websocket
Downloads
13
Readme
Table of Contents
WebsocketConnection
Encapsulates a websocket connection
Wraps a Websocket connection with a logger.
Parameters
host
string A websocket url, e.g. 'ws://demos.kaazing.com/echo'log
Log An object which has alog()
function
Examples
import { WebsocketConnection } from 'js-flux';
class Log {
log(x) {
console.log('log: ' + x);
}
}
let logger = new Log();
let connection = new WebsocketConnection('ws://demos.kaazing.com/echo', logger);
connection.onOpen = () => console.log('opened connection');
connection.onMessage = (message) => console.log('received message:', message);
connection.connect();
onOpen
onClose
Type: Callback
onError
Type: Callback
Parameters
e
onMessage
Type: Callback
Parameters
m
connect
Starts the connection process
close
Closes the current connection
send
Sends a binary payload
Parameters
payload
(Uint8Array | Blob)