Interface ChatMiddleware

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(null, room, 'I have joined the room: ' + connection.id, callback)
},
leave:(connection, room, callback) => {
// announce all connections leaving a room
api.chatRoom.broadcast(null, 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)
interface ChatMiddleware {
    join?: Function;
    leave?: Function;
    name: string;
    onSayReceive?: Function;
    priority?: number;
    say?: Function;
}

Properties

join?: Function

Called when a connection joins a room.

leave?: Function

Called when a connection leaves a room.

name: string

Unique name for the middleware.

onSayReceive?: Function

Called when a connection says a message to a room.

priority?: number

Module load order. Defaults to api.config.general.defaultMiddlewarePriority.

say?: Function

Called when a connection is about to receive a say message.