Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

The event handler is invoked twitce #336

Unanswered
KevinGuancheDarias asked this question in Q&A
Discussion options

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 🍺 
You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /