command
The sos.command
API groups together methods for sending logs and receiving commands from signageOS.
Methods
dispatch()
The dispatch()
method dispatches a new log record to the signageOS.
Dispatch throttling
Sending commands from an applet is throttled, this means that after if the dispatch frequency is too high, some commands may be discarded. Currently the limit is 30 commands per 30 seconds, although this may not be fully accurate and it's not possible to know the exact limit.
dispatch<TCommand extends ICommand>(command: TCommand): Promise<void>;
Example
await sos.command.dispatch({
type: 'Files.StartLoading',
fileName: 'my-file',
fileType: 'txt'
});
GitHub Example
onCommand()
The onCommand()
method sets up a listener, which is called whenever a new command from signageOS is received.
onCommand(listener: (command: ICommandEvent) => void): void;
GitHub Example
API Example
import { sos } from '@signageos/front-applet';
void sos.onReady(async () => {
/* Example of dispatching information about file download */
await sos.command.dispatch({
type: 'Files.StartLoading', // mandatory *type* with custom value
fileName: 'my-file', // custom parameter and value
fileType: 'txt', // custom parameter and value
});
sos.command.onCommand((command) => {
console.log(`new command ${command.type} received, with data:`, command.command);
});
});