Websocket Brew for Pubkeeper
In a browser:
``html`
Using npm:
`bash`
$ npm install --save @pubkeeper/brew-websocket
Then, load using ES5 require() syntax…
`js`
var WebSocketBrew = require('@pubkeeper/brew-websocket').WebSocketBrew;
…or with ES2015+ import syntax:
`js`
import { WebSocketBrew } from '@pubkeeper/brew-websocket';
Simple example, pointing to localhost…
`js`
const wsb = new WebSocketBrew({
brewerConfig: {
hostname: '127.0.0.1',
port: 8080,
secure: false,
},
});
With multiple servers…
`js
const wsbLocal = new WebSocketBrew({
name: 'websocket-local',
brewerConfig: {
hostname: '127.0.0.1',
port: 8080,
secure: false,
},
});
const wsbShared = new WebSocketBrew({
name: 'websocket-shared',
brewerConfig: {
hostname: '10.10.0.21',
port: 443,
secure: true,
},
});
const brews = [wsbLocal, wsbShared];
`
ClassThe WebSocketBrew provides the connection management layer to publish to and read from the Pubkeeper WebSocket server.
new WebSocketBrew(options)
| Name | Type | Description |
|-|-|-|
| options | BrewOptions | The options for this pubkeeper client |
##### BrewOptions : object
These options can be given to a WebSocketBrew to customize its behavior.
| Name | Type | Default | Description |
|-|-|-|-|
| name | string | 'websocket' | brew name/idbrewerConfig
| | BrewerConfig? | null | The brew's brewer configurationloopback
| | boolean | true | Enable/Disbale loopback messagesmaxRetries
| | number | 7 | Maximum number of connection retriesmaxTimeout
| | number | 10000 | Maximum timeout between retries (in milliseconds)
##### BrewerConfig : object
| Name | Type | Description |
|-|-|-|
| hostname | string | hostname of the WebSocket serverport
| | number | port of the WebSocket serversecure
| | boolean | use wss:// or ws:// for server communication
##### .name : string`
Return the configured name of this brew.