Skip to content

Commit

Permalink
fix(nodecg-utility-obs): compensate for obs-websocket bug
Browse files Browse the repository at this point in the history
  • Loading branch information
from-the-river-to-the-sea committed Jun 17, 2019
1 parent 0cac9f7 commit 9e8ca41
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 21 deletions.
6 changes: 3 additions & 3 deletions packages/nodecg-utility-obs/dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export declare class OBSUtility extends OBSWebSocket {
messageId: string;
status: "ok";
name: string;
sources: OBSWebSocket.Source[];
sources: OBSWebSocket.SceneItem[];
}, void, void]>;
/**
* Attempt to reconnect to OBS, and keep re-trying every 5s until successful.
Expand All @@ -69,7 +69,7 @@ export declare class OBSUtility extends OBSWebSocket {
messageId: string;
status: "ok";
name: string;
sources: OBSWebSocket.Source[];
sources: OBSWebSocket.SceneItem[];
}, void, void]>;
/**
* Updates the sceneList replicant with the current value from OBS.
Expand All @@ -90,7 +90,7 @@ export declare class OBSUtility extends OBSWebSocket {
messageId: string;
status: "ok";
name: string;
sources: OBSWebSocket.Source[];
sources: OBSWebSocket.SceneItem[];
}>;
/**
* Updates the previewScene replicant with the current value from OBS.
Expand Down
2 changes: 1 addition & 1 deletion packages/nodecg-utility-obs/dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 16 additions & 8 deletions packages/nodecg-utility-obs/dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/nodecg-utility-obs/dist/index.js.map

Large diffs are not rendered by default.

25 changes: 17 additions & 8 deletions packages/nodecg-utility-obs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,10 +392,15 @@ export class OBSUtility extends OBSWebSocket {
*/
_updateProgramScene() {
return this.send('GetCurrentScene').then(res => {
this.replicants.programScene.value = {
name: res.name,
sources: res.sources
};
// This conditional is required because of this bug:
// https://github.com/Palakis/obs-websocket/issues/346
if (res.name && res.sources) {
this.replicants.programScene.value = {
name: res.name,
sources: res.sources
};
}

return res;
}).catch(err => {
this.log.error('Error updating program scene:', err);
Expand All @@ -407,10 +412,14 @@ export class OBSUtility extends OBSWebSocket {
*/
_updatePreviewScene() {
return this.send('GetPreviewScene').then(res => {
this.replicants.previewScene.value = {
name: res.name,
sources: res.sources
};
// This conditional is required because of this bug:
// https://github.com/Palakis/obs-websocket/issues/346
if (res.name && res.sources) {
this.replicants.previewScene.value = {
name: res.name,
sources: res.sources
};
}
}).catch(err => {
if (err.error === 'studio mode not enabled') {
this.replicants.previewScene.value = null;
Expand Down

0 comments on commit 9e8ca41

Please sign in to comment.