Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

chore(deps): bump obs-websocket-js from 4.0.3 to 5.0.0 #668

Merged
merged 2 commits into from
Jul 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 78 additions & 35 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions samples/obs-scenelist/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ module.exports = function (nodecg: NodeCG) {
const obs = requireService<OBSServiceClient>(nodecg, "obs");

obs?.onAvailable((client) => {
nodecg.log.info("OBS client has been updated, counting scenes and switching to another one.");
client.send("GetSceneList").then((data) => {
nodecg.log.info("OBS client has been updated, counting scenes and detecting when switching to another one.");
client.call("GetSceneList").then((data) => {
nodecg.log.info(`There are ${data.scenes.length} scenes!`);
});
client.on("SwitchScenes", (data) => {
nodecg.log.info(`Scene changed to ${data["scene-name"]}.`);
client.on("CurrentProgramSceneChanged", (data) => {
nodecg.log.info(`Scene changed to ${data.sceneName}.`);
});
});

Expand Down
10 changes: 8 additions & 2 deletions services/nodecg-io-obs/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import OBSWebSocket from "obs-websocket-js";
interface OBSServiceConfig {
host: string;
port: number;
isSecure?: boolean;
password?: string;
}

Expand All @@ -18,7 +19,7 @@ class OBSService extends ServiceBundle<OBSServiceConfig, OBSServiceClient> {
async validateConfig(config: OBSServiceConfig): Promise<Result<void>> {
const client = new OBSWebSocket();
try {
await client.connect({ address: `${config.host}:${config.port}`, password: config.password });
await this.connectClient(client, config);

client.disconnect();
} catch (e) {
Expand All @@ -30,7 +31,7 @@ class OBSService extends ServiceBundle<OBSServiceConfig, OBSServiceClient> {
async createClient(config: OBSServiceConfig, logger: Logger): Promise<Result<OBSServiceClient>> {
const client = new OBSWebSocket();
try {
await client.connect({ address: `${config.host}:${config.port}`, password: config.password });
await this.connectClient(client, config);
logger.info("Connected to OBS successfully.");
} catch (e) {
return error(e.error);
Expand All @@ -39,6 +40,11 @@ class OBSService extends ServiceBundle<OBSServiceConfig, OBSServiceClient> {
return success(client);
}

private async connectClient(client: OBSWebSocket, config: OBSServiceConfig): Promise<void> {
const protocol = config.isSecure ? "wss" : "ws";
await client.connect(`${protocol}://${config.host}:${config.port}`, config.password);
}

stopClient(client: OBSServiceClient) {
client.disconnect();
}
Expand Down
5 changes: 5 additions & 0 deletions services/nodecg-io-obs/obs-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"type": "string",
"description": "An IP address to the obs websocket server"
},
"isSecure": {
"type": "boolean",
"description": "Whether the websocket connection is using encryption (wss) or not (ws)",
"default": false
},
"port": {
"type": "number",
"description": "The port of the obs websocket server"
Expand Down
2 changes: 1 addition & 1 deletion services/nodecg-io-obs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
},
"dependencies": {
"nodecg-io-core": "^0.3.0",
"obs-websocket-js": "^4.0.3"
"obs-websocket-js": "^5.0.0"
}
}