The plugin implement this interface will be called when a new message is received from a client.
class MessageLoggerPlugin implements HandleMessagePlugin { async handleMessage(ctx, message, next) { const startTime = Date.now(); console.log('Received message:', message); const result = await next(); console.log('Message processed in', Date.now() - startTime, 'ms'); return result; }} Copy
class MessageLoggerPlugin implements HandleMessagePlugin { async handleMessage(ctx, message, next) { const startTime = Date.now(); console.log('Received message:', message); const result = await next(); console.log('Message processed in', Date.now() - startTime, 'ms'); return result; }}
This method functions like Koa middleware and is called when a new message is received from a client.
The client context
The incoming message
The next function to call the next plugin
The plugin implement this interface will be called when a new message is received from a client.
Example