-
Notifications
You must be signed in to change notification settings - Fork 99
The event handler is invoked twitce #336
Unanswered
KevinGuancheDarias
asked this question in
Q&A
-
I have the following code to connect to obs and detect if it's streaming, for unknown reasons the event is fired twice, I have made a workaround, but of course the code will fail if the bug is suddenly fixed, do you know why it may be happening?
I have confirmed that the code is execute only twice, so is not registering dupplicated listeners!
let invocationTimes = 0; if(this.websocket) { await this.websocket.disconnect(); this.websocket.removeAllListeners(); } this.websocket = new OBSWebSocket(); await this.websocket.connect('ws://127.0.0.1:4455', password); this.websocket.on('RecordStateChanged', event => { invocationTimes++; if(invocationTimes % 2 === 0) { // Due to a bug in obs websocket workaround the dupplicated events this.log.debug(`Changed streaming status to ${event.outputActive}`); this.setStreamingState(event.outputActive); } }); await this.websocket.call('GetRecordStatus').then(recordStatus => { this.log.debug(`Initial streaming status is ${recordStatus.outputActive}`); this.setStreamingState(recordStatus.outputActive); }); Thanks in advance 🍺
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment