Not tested yet. Event 'close' is dispatched when last connection gets closed and server stops listening
Event 'unit' is dispatched when peer gets connected to a unit
Event 'role' is dispatched when new role is registered
Sets or gets the default captureRejection value for all emitters.
This symbol shall be used to install a listener for only monitoring 'error'
events. Listeners installed using this symbol are called before the regular
'error'
listeners are called.
Installing a listener using this symbol does not change the behavior once an
'error'
event is emitted, therefore the process will still crash if no
regular 'error'
listener is installed.
Returns list of declared Destinations. If some units have declared roles out of this Peer's destinations, they are not listed here
Get peer's unique identifier. It is generated when Peer is being instantiated
Add secret key bound to id. After a key is added, this peer will not be authenticated with any other peer unless some common id:key pair is equal
Close all incoming connections and stop listening http server. Provide optional cb argument to run callback when internal server stops listening
Connect to another peer using WebSocket. Options can be used to override [[WebSocket.ClientOptions]]. Set options.permanent = false if connection is not supposed to reconnect after abort
Destination is remote peer's role
target name
class destination
Attach to existing http.Server instance
Example: peer.prepareWSServer() server.on("upgrade", (request, socket, head) => { peer.handleUpgrade(request, socket, head) })
Listen to incoming connections. Starts HTTP(S) server listening immediately.
Set middleware for incoming messages, requests and streams for all roles
Set handler to all incoming messages for all roles. Can be used in middleware
Set middleware for incoming request for receiving stream data for all roles
Set handler for all incoming request for all roles. Can be used in middlewares
Set middleware for incoming request for sending stream data for all roles
Instantiate websocket server. Use with .handleUpgrade
Generated using TypeDoc
Peer is the main class of Roletalk framework. Peer can be instantiated with counstructor. You can also use Singleton to retrieve a peer instance shared with other modules.