command
In some cases, you might be interested in a complete log of what the device was doing during its operation. All of your business or technical logs can be stored in our storage for later usage. You can identify which events happened or even trigger self-repairing logic.
All commands will be available in Applet Command REST API and can be downloaded historically as CSV export.
Methods
dispatch()
The dispatch()
method dispatches a new log record to the signageOS.
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>;
Params
Name | Type | Description |
---|---|---|
command | TCommand | The command to be dispatched. |
Possible errors
- If type contains invalid characters, allowed to are
/^[a-zA-Z0-9\.\-_]+$/g
- If the command type is longer then 100 characters limit.
- If the command is not an object or is missing required properties.
Example
await sos.command.dispatch({
type: 'Files.StartLoading',
fileName: 'my-file',
fileType: 'txt'
});
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;
Params
Name | Type | Description |
---|---|---|
listener | (command: ICommandEvent) => void | The listener to be called when a new command is received. |
Return value
Resolves when the listener is successfully set up.
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);
});
});