Bot
Bot server may be a member of severals groups. Each group is isolated. He can be invited by a group member via WebGroup#invite method.
Example:
// In NodeJS:
// Create a bot server with full mesh topology, without autorejoin feature
// and with specified Signaling and ICE servers for WebRTC.
// Bot server is listening on 'ws://BOT_HOST:BOT_PORT'.
const http = require('http')
const server = http.createServer()
const bot = new Bot({
server,
webGroupOptions: {
signalingServer: 'wss://mysignaling.com',
rtcConfiguration: {
iceServers: [
{
urls: 'stun.l.google.com:19302'
},
{
urls: ['turn:myturn.com?transport=udp', 'turn:myturn?transport=tcp'],
username: 'user',
password: 'password'
}
]
}
}
})
bot.onWebGroup = (wg) => {
// YOUR CODE
}
bot.onError = (err) => {
// YOUR CODE
}
server.listen(BOT_PORT, BOT_HOST)
Constructor Summary
Public Constructor | ||
public |
constructor(options: BotOptions) |
Member Summary
Public Members | ||
public |
Read-only property leaveOnceAlone. |
|
public |
onError: function(err: Error) This handler is called when an error occurs on WebSocket server. |
|
public |
onWebGroup: function(wg: WebGroup) This handler is called when the bot has been invited into a group by one of its members. |
|
public |
Read-only property of WebSocket server: permessage-deflate. |
|
public |
Read-only NodeJS http server instance. |
|
public |
url: string Bot server url. |
|
public |
Read-only set of web groups the bot is member of. |
Public Constructors
public constructor(options: BotOptions) source
Params:
Name | Type | Attribute | Description |
options | BotOptions | ||
options.server | HttpServer | HttpsServer | NodeJS http(s) server. |
|
options.url | string |
|
Bot server URL. |
options.perMessageDeflate | boolean |
|
Enable/disable permessage-deflate. |
options.leaveOnceAlone | boolean |
|
If true, bot will live (disconnect from the signaling server) if no other peers left in the group. |
options.webGroupOptions | WebGroupOptions | Options for each WebGroup the bot is member of. |
|
options.webGroupOptions.topology | Topology |
|
|
options.webGroupOptions.signalingServer | string |
|
|
options.webGroupOptions.rtcConfiguration | RTCConfiguration |
|
|
options.webGroupOptions.autoRejoin | boolean |
|
Public Members
public onError: function(err: Error) source
This handler is called when an error occurs on WebSocket server.
public onWebGroup: function(wg: WebGroup) source
This handler is called when the bot has been invited into a group by one of its members.
public perMessageDeflate: HttpServer | HttpsServer source
Read-only property of WebSocket server: permessage-deflate.
public url: string source
Bot server url. Used to invite the bot in a web group via WebGroup#invite method.