Called when a connection joins a room.
Called when a connection leaves a room.
Unique name for the middleware.
Called when a connection says a message to a room.
Module load order. Defaults to api.config.general.defaultMiddlewarePriority.
Called when a connection is about to receive a say message.
Generated using TypeDoc
Middleware definition for processing chat events. Can be of the
var chatMiddleware = { name: 'chat middleware', priority: 1000, join: (connection, room) => { // announce all connections entering a room api.chatRoom.broadcast({}, room, 'I have joined the room: ' + connection.id, callback) }, leave:(connection, room, callback) => { // announce all connections leaving a room api.chatRoom.broadcast({}, room, 'I have left the room: ' + connection.id, callback) }, // Will be executed once per client connection before delivering the message. say: (connection, room, messagePayload) => { // do stuff log(messagePayload) }, // Will be executed only once, when the message is sent to the server. onSayReceive: (connection, room, messagePayload) => { // do stuff log(messagePayload) } } api.chatRoom.addMiddleware(chatMiddleware)