You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CheshireCaat edited this page Sep 9, 2023
·
8 revisions
Subscribe to script events
You can subscribe to certain events that come from the script. Events can be very different - new messages in the log, notifications about the start and stop of threads and browsers etc.
To do this, you can add event handler using client.on('messageReceived', listener):
constBasRemoteClient=require('bas-remote-node');constclient=newBasRemoteClient({scriptName: 'TestRemoteControl'});// Add event handler for log messages.client.on('messageReceived',({ type, data })=>{// Process only log event.if(type==='log'){// Retrieve log text.const{ text }=data;// Output text to the console.console.log(`[Log] - ${text}`);}});// Add event handler for threads.client.on('messageReceived',({ type, data })=>{if(type==='thread_start'){console.log('[Thread] - started');}if(type==='thread_end'){console.log('[Thread] - ended');}});awaitclient.start();// Perform any actions here.