mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 06:59:09 +00:00
Merge pull request #623 from cpvalente/osc-enabledOut
Osc disable/enable output
This commit is contained in:
@@ -16,6 +16,7 @@ import { deleteAllEvents, notifyChanges } from '../services/rundown-service/Rund
|
|||||||
import { deepmerge } from 'ontime-utils';
|
import { deepmerge } from 'ontime-utils';
|
||||||
import { runtimeCacheStore } from '../stores/cachingStore.js';
|
import { runtimeCacheStore } from '../stores/cachingStore.js';
|
||||||
import { delayedRundownCacheKey } from '../services/rundown-service/delayedRundown.utils.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'
|
// Create controller for GET request to '/ontime/poll'
|
||||||
// Returns data for current state
|
// Returns data for current state
|
||||||
@@ -315,10 +316,16 @@ export const postOSC = async (req, res) => {
|
|||||||
const oscSettings = req.body;
|
const oscSettings = req.body;
|
||||||
await DataProvider.setOsc(oscSettings);
|
await DataProvider.setOsc(oscSettings);
|
||||||
|
|
||||||
|
integrationService.unregister(oscIntegration);
|
||||||
|
|
||||||
// TODO: this update could be more granular, checking that relevant data was changed
|
// 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);
|
logger.info(LogOrigin.Tx, message);
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
integrationService.register(oscIntegration);
|
||||||
|
}
|
||||||
|
|
||||||
res.send(oscSettings).status(200);
|
res.send(oscSettings).status(200);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(400).send({ message: error.toString() });
|
res.status(400).send({ message: error.toString() });
|
||||||
|
|||||||
@@ -26,7 +26,15 @@ export class OscIntegration implements IIntegration {
|
|||||||
* Initializes oscClient
|
* Initializes oscClient
|
||||||
*/
|
*/
|
||||||
init(config: OSCSettings) {
|
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);
|
this.initSubscriptions(subscriptions);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user