Skip to content

Commit 2a4079f

Browse files
committed
Also check if streaming on heartbeat
1 parent c04948e commit 2a4079f

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

lib/components/ObsSwitcher.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,7 @@ function (_EventEmitter) {
9999

100100
_this.obs.on("StreamStarted", _this.streamStarted.bind(_assertThisInitialized(_assertThisInitialized(_this))));
101101

102-
_this.obs.on("Heartbeat", function (heartbeat) {
103-
return _this.heartbeat = heartbeat;
104-
});
102+
_this.obs.on("Heartbeat", _this.handleHeartbeat.bind(_assertThisInitialized(_assertThisInitialized(_this))));
105103

106104
_this.obs.on("ScenesChanged", _this.scenesChanged.bind(_assertThisInitialized(_assertThisInitialized(_this))));
107105

@@ -330,6 +328,12 @@ function (_EventEmitter) {
330328
value: function scenesChanged() {
331329
this.getSceneList();
332330
}
331+
}, {
332+
key: "handleHeartbeat",
333+
value: function handleHeartbeat(heartbeat) {
334+
this.heartbeat = heartbeat;
335+
this.obsStreaming = heartbeat.streaming;
336+
}
333337
}]);
334338

335339
return ObsSwitcher;

src/components/ObsSwitcher.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ObsSwitcher extends EventEmitter {
4646
this.obs.on("StreamStatus", this.setStreamStatus.bind(this));
4747
this.obs.on("StreamStopped", this.streamStopped.bind(this));
4848
this.obs.on("StreamStarted", this.streamStarted.bind(this));
49-
this.obs.on("Heartbeat", heartbeat => (this.heartbeat = heartbeat));
49+
this.obs.on("Heartbeat", this.handleHeartbeat.bind(this));
5050
this.obs.on("ScenesChanged", this.scenesChanged.bind(this));
5151

5252
log.info("Connecting & authenticating");
@@ -193,6 +193,11 @@ class ObsSwitcher extends EventEmitter {
193193
scenesChanged() {
194194
this.getSceneList();
195195
}
196+
197+
handleHeartbeat(heartbeat) {
198+
this.heartbeat = heartbeat;
199+
this.obsStreaming = heartbeat.streaming;
200+
}
196201
}
197202

198203
export default ObsSwitcher;

0 commit comments

Comments
 (0)