diff --git a/plugins/caspar/README.md b/plugins/caspar/README.md index 867a1b3..302ec3a 100644 --- a/plugins/caspar/README.md +++ b/plugins/caspar/README.md @@ -11,6 +11,19 @@ Enables communication with Caspar CG and provides caspar-specific type options t ## API This plugin exposes a number of commands that can be invoked using the commands api. +### `caspar.listServers()` +Add a new server to the workspace and returns +its id for further reference + +**Example** +```javascript +/* +Variable 'servers' gets defined as +an array of server descriptor objects +*/ +const servers = await bridge.commands.executeCommand('caspar.listServers') +``` + ### `caspar.addServer(serverDescription)` Add a new server to the workspace and returns its id for further reference diff --git a/plugins/caspar/lib/commands.js b/plugins/caspar/lib/commands.js index 96c7c7f..a6b6f4c 100644 --- a/plugins/caspar/lib/commands.js +++ b/plugins/caspar/lib/commands.js @@ -152,6 +152,16 @@ async function editServer (serverId, description) { exports.editServer = editServer bridge.commands.registerCommand('caspar.editServer', editServer) +/** + * Get a list of all configured servers + * @returns { Promise. } + */ +async function listServers () { + return (await bridge.state.get(`${paths.STATE_SETTINGS_PATH}.servers`)) || [] +} +exports.listServers = listServers +bridge.commands.registerCommand('caspar.listServers', listServers) + /** * Reconnect a server using * a new connection init