Javascript.NodeJS
Javascript.NodeJS copied to clipboard
Event Listener on nodejs
Hi.
I'm trying to use a lib that works with events. In my first implementation, it worked.
I have this code:
const { Client } = require("listeners.js");
const client = new Client();
module.exports = (callback) => {
try {
let qrCode = "";
client.on("qr", (qr) => {
qrCode = qr;
callback(null, qrCode);
});
client.on("ready", () => {
console.log("Client is ready!");
});
client.on("message", (message) => {
console.log(message);
});
client.initialize();
} catch (error) {
callback(error, null);
}
};
I need to listen those events some how. When i execute InvokeFromStringAsync once, it work. I can get the qrcode string. But the thread is ended.
Is there some way to keep listening the script, and some how pass the event data to c# code?
Thanks.
Sorry for the slow response. You could read from stdout: I want to subscribe to events.