How to use the obs-websocket-js.OBSWebSocket function in obs-websocket-js

To help you get started, we’ve selected a few obs-websocket-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GamesDoneQuick / agdq17-layouts / extension / obs-websocket.js View on Github external
module.exports = function (nodecg) {
	const currentScene = nodecg.Replicant('currentScene', {defaultValue: ''});

	// Start with a stub that we'll replace if we have all the config we need.
	module.exports.resetCropping = function () {};

	if (!nodecg.bundleConfig.obsWebsocket.address) {
		nodecg.log.error('"obsWebsocket" is not defined in cfg/agdq17-layouts.json! ' +
			'OBS Studio integration will be disabled.');
		return;
	}

	const ws = new OBSWebSocket();
	let notifiedConnectionFailed = false;

	ws.onConnectionOpened = function () {
		notifiedConnectionFailed = false;
		nodecg.log.info('[obs-websocket] Connected.');
	};

	ws.onAuthenticationSuccess = function () {
		nodecg.log.info('[obs-websocket] Authenticated.');
		getCurrentScene();
	};

	ws.onConnectionClosed = function () {
		nodecg.log.warn('[obs-websocket] Connection closed, attempting to reconnect in 5 seconds.');
		setTimeout(connectToOBS, 5000);
	};
github GamesDoneQuick / sgdq17-layouts / extension / obs-websocket.js View on Github external
module.exports = function (nodecg) {
	const currentScene = nodecg.Replicant('currentScene', {defaultValue: ''});

	// Start with a stub that we'll replace if we have all the config we need.
	module.exports.resetCropping = function () {};

	if (!nodecg.bundleConfig.obsWebsocket.address) {
		nodecg.log.error('"obsWebsocket" is not defined in cfg/sgdq17-layouts.json! ' +
			'OBS Studio integration will be disabled.');
		return;
	}

	const ws = new OBSWebSocket();
	let notifiedConnectionFailed = false;

	ws.onConnectionOpened = function () {
		notifiedConnectionFailed = false;
		nodecg.log.info('[obs-websocket] Connected.');
	};

	ws.onAuthenticationSuccess = function () {
		nodecg.log.info('[obs-websocket] Authenticated.');
		getCurrentScene();
	};

	ws.onConnectionClosed = function () {
		nodecg.log.warn('[obs-websocket] Connection closed, attempting to reconnect in 5 seconds.');
		setTimeout(connectToOBS, 5000);
	};

obs-websocket-js

OBS Websocket API in Javascript, consumes @Palakis/obs-websocket

MIT
Latest version published 4 months ago

Package Health Score

74 / 100
Full package analysis

Popular obs-websocket-js functions