From 27f6d106770e931beef8b47d80bf7c0b5cc29d2a Mon Sep 17 00:00:00 2001 From: arc-alex Date: Sun, 26 Nov 2023 20:41:01 +0100 Subject: [PATCH 1/2] actually disable/enable osc output --- .../src/services/integration-service/OscIntegration.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/server/src/services/integration-service/OscIntegration.ts b/apps/server/src/services/integration-service/OscIntegration.ts index f9c730a28..8c3071cf5 100644 --- a/apps/server/src/services/integration-service/OscIntegration.ts +++ b/apps/server/src/services/integration-service/OscIntegration.ts @@ -26,7 +26,15 @@ export class OscIntegration implements IIntegration { * Initializes oscClient */ init(config: OSCSettings) { - const { targetIP, portOut, subscriptions } = config; + const { targetIP, portOut, subscriptions, enabledOut } = config; + + if (!enabledOut) { + this.oscClient?.close(); + return { + success: false, + message: 'OSC output disabled', + }; + } this.initSubscriptions(subscriptions); From 715fa664447cab273cef4b51b3c88a02d35ec4ac Mon Sep 17 00:00:00 2001 From: arc-alex Date: Sun, 26 Nov 2023 20:41:33 +0100 Subject: [PATCH 2/2] disable/enable from ui without restart --- apps/server/src/controllers/ontimeController.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/server/src/controllers/ontimeController.ts b/apps/server/src/controllers/ontimeController.ts index 9ebb2ae1f..fd2463791 100644 --- a/apps/server/src/controllers/ontimeController.ts +++ b/apps/server/src/controllers/ontimeController.ts @@ -16,6 +16,7 @@ import { deleteAllEvents, notifyChanges } from '../services/rundown-service/Rund import { deepmerge } from 'ontime-utils'; import { runtimeCacheStore } from '../stores/cachingStore.js'; import { delayedRundownCacheKey } from '../services/rundown-service/delayedRundown.utils.js'; +import { integrationService } from '../services/integration-service/IntegrationService.js'; // Create controller for GET request to '/ontime/poll' // Returns data for current state @@ -315,10 +316,16 @@ export const postOSC = async (req, res) => { const oscSettings = req.body; await DataProvider.setOsc(oscSettings); + integrationService.unregister(oscIntegration); + // TODO: this update could be more granular, checking that relevant data was changed - const { message } = oscIntegration.init(oscSettings); + const { success, message } = oscIntegration.init(oscSettings); logger.info(LogOrigin.Tx, message); + if (success) { + integrationService.register(oscIntegration); + } + res.send(oscSettings).status(200); } catch (error) { res.status(400).send({ message: error.toString() });