Variable: ev
const
ev:EventEmitter2
This is the library's event emitter. Use this to listen to internal events of the library like so:
ev.on('event', callback)
The event you want to listen to is in the format of [namespace].[sessionId]
The event can include wildcards.
For example, to listen to all qr code events, the event will be qr.**
. e.g:
ev.on('qr.**',...
Listen to all sessionData events
ev.on('sessionData.**',...
Listen to all events from session1
ev.on('**.session1',...
Listen to all events
ev.on('**.**',...
ev always emits data, sessionId and the namespace which is helpful to know if there are multiple sessions or you're listening to events from all namespaces
ev.on('**.**', (data, sessionId, namespace) => {
console.log(`${namespace} event detected for session ${sessionId}`, data)
});