Skip to content

Commit bb950a6

Browse files
committed
Update node example
1 parent fc0f21e commit bb950a6

File tree

3 files changed

+155
-48
lines changed

3 files changed

+155
-48
lines changed

samples/node-sample/index.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
const { OBSWebSocket } = require('obs-websocket-js');
1+
const { default: OBSWebSocket } = require('obs-websocket-js');
22
const obs = new OBSWebSocket();
33

44
// Declare some events to listen for.
55
obs.on('ConnectionOpened', () => {
66
console.log('Connection Opened');
7+
});
78

8-
// Send some requests.
9-
obs.sendCallback('GetSceneList', {}, (err, data) => {
10-
console.log('Using callbacks:', err, data);
11-
});
9+
obs.on('Identified', () => {
10+
console.log('Identified, good to go!')
1211

13-
obs.send('GetSceneList').then(data => {
14-
console.log('Using promises:', data);
12+
// Send some requests.
13+
obs.call('GetSceneList').then((data) => {
14+
console.log('Scenes:', data);
1515
});
1616
});
1717

1818
obs.on('SwitchScenes', data => {
1919
console.log('SwitchScenes', data);
2020
});
2121

22-
obs.connect();
22+
obs.connect('ws://localhost:4455', 'password').then((info) => {
23+
console.log('Connected and identified', info)
24+
}, () => {
25+
console.error('Error Connecting')
26+
});

samples/node-sample/package-lock.json

Lines changed: 142 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/node-sample/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
"author": "Brendan Hagan (haganbmj)",
1010
"license": "ISC",
1111
"dependencies": {
12-
"obs-websocket-js": "^4.0.0"
12+
"obs-websocket-js": "^5.0.2"
1313
}
1414
}

0 commit comments

Comments
 (0)