npm

js-flux

2.0.1 • Public • Published

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 a log() 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

Readme

Keywords

none

Package Sidebar

Install

npm i js-flux

Weekly Downloads

3

Version

2.0.1

License

MIT

Unpacked Size

3.56 kB

Total Files

5

Last publish

Collaborators

  • piot