Client remote control (#930)

---------

Co-authored-by: kellhogs <fabianpos99@gmail.com>
Co-authored-by: Carlos Valente <carlosvalente@pm.me>
Co-authored-by: Carlos Valente <34649812+cpvalente@users.noreply.github.com>
This commit is contained in:
Alex Christoffer Rasmussen
2024-06-15 12:26:41 +02:00
committed by GitHub
parent 70e8fbf327
commit a15eb0db4c
33 changed files with 868 additions and 169 deletions
@@ -10,6 +10,7 @@ import { eventStore } from '../stores/EventStore.js';
import * as assert from '../utils/assert.js';
import { isEmptyObject } from '../utils/parserUtils.js';
import { parseProperty, updateEvent } from './integration.utils.js';
import { socket } from '../adapters/WebsocketAdapter.js';
import { throttle } from '../utils/throttle.js';
import { willCauseRegeneration } from '../services/rundown-service/rundownCacheUtils.js';
@@ -240,6 +241,33 @@ const actionHandlers: Record<string, ActionHandler> = {
}
throw new Error('No matching method provided');
},
/* Client */
client: (payload) => {
assert.isObject(payload);
if (!('target' in payload) || typeof payload.target != 'string') {
throw new Error('No or invalid client target');
}
if ('rename' in payload && typeof payload.rename == 'string') {
const { target, rename } = payload;
socket.renameClient(target, rename);
return { payload: 'success' };
}
if ('redirect' in payload && typeof payload.redirect == 'string') {
const { target, redirect } = payload;
socket.redirectClient(target, redirect);
return { payload: 'success' };
}
if ('identify' in payload && typeof payload.identify == 'boolean') {
const { target, identify } = payload;
socket.identifyClient(target, identify);
return { payload: 'success' };
}
throw new Error('No matching method provided');
},
};
/**