Manual Reference Source Test
import {Bot} from 'netflux/src/BotFacade.js'
public class | source

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

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:

NameTypeAttributeDescription
options BotOptions
options.server HttpServer | HttpsServer

NodeJS http(s) server.

options.url string
  • optional

Bot server URL.

options.perMessageDeflate boolean
  • optional
  • default: false

Enable/disable permessage-deflate.

options.leaveOnceAlone boolean
  • optional
  • default: false

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
  • optional
  • default: Topology.FULL_MESH
options.webGroupOptions.signalingServer string
  • optional
  • default: 'wss://signaling.netflux.coedit.re'
options.webGroupOptions.rtcConfiguration RTCConfiguration
  • optional
  • default: {iceServers: [{urls: 'stun:stun3.l.google.com:19302'}]}
options.webGroupOptions.autoRejoin boolean
  • optional
  • default: true

Public Members

public leaveOnceAlone: HttpServer | HttpsServer source

Read-only property leaveOnceAlone.

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 server: HttpServer | HttpsServer source

Read-only NodeJS http server instance.

public url: string source

Bot server url. Used to invite the bot in a web group via WebGroup#invite method.

public webGroups: Set<WebGroup> source

Read-only set of web groups the bot is member of.