diff --git a/ModuleServerAPI.md b/ModuleServerAPI.md index e6aa49f..6555a4c 100644 --- a/ModuleServerAPI.md +++ b/ModuleServerAPI.md @@ -57,7 +57,7 @@ Environment * [getScenes](./ModuleServerAPI#getscenes) * [getResolution](./ModuleServerAPI#getresolution) **Deprecated** --> -## Functions +## Sub Classes ### Libs @@ -69,6 +69,8 @@ api.Libs; **Returns** [Libs](./ModuleServerAPILibs) _Libs object_ +## Communication + ### on Register a listener for messages from the ModuleServerAPI. @@ -95,6 +97,103 @@ api.broadcast(header, ...args); | header | string | The header of the message. | | args | any[] | Data of any type. | +### finishServerCondition + +Finish a server condition. + +```javascript +api.finishServerCondition(conditionId); +``` + +| Argument | Type | Description | +| ----------- | ------ | ------------------------ | +| conditionId | string | The id of the condition. | + +### forceClientCondition + +Force a client condition. + +```javascript +api.forceClientCondition(conditionId); +``` + +| Argument | Type | Description | +| ----------- | ------ | ------------------------ | +| conditionId | string | The id of the condition. | + +## Events + +### onSceneChange + +Register for a listener when the module is part of a scene change. + +```javascript +api.onSceneChange(callback); +``` + +| Argument | Type | Description | +| -------- | ------------------------------------------------------------ | ---------------------------------------------------- | +| callback | ( displayId:string, origin:string, destination:string ):void | Function will be called when a scene change occures. | + +### onFileUpload + +Register for a listener for when a file is uploaded through the module file upload route. To use this send a HTTP post with the files in formData as the body to `http://serverIp:4080/:CHANNELNAME/upload/:MODULEID`. + +```javascript +api.onFileUpload(callback); +``` + +| Argument | Type | Description | +| -------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------- | +| callback | ( files: { filename:string, originalFilename:string, byUser:string, size:number }[] ):void | Function will be called when a file upload has finished. | + +### onTrigger + +Register a listener for when a trigger is called from a cue list. + +```javascript +api.onTrigger(triggerId, callback); +``` + +| Argument | Type | Description | +| --------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| triggerId | string | The trigger ID that the listener will receive. | +| callback | ( finish:function, status: (text:string)=>void, ...args:any[] ):void | Function will be called when the trigger is called from a cue list. The callback will receive the arguments in the same order they are defined in the [module.json](./ModuleJSON). | + +## Getters + +### getModuleID + +Get the current module id. + +```javascript +api.getModuleID(); +``` + +**Returns** string _Module ID_ + +### getScenes + +Get a list of all scenes this module is a part of. + +```javascript +api.getModuleID(); +``` + +**Returns** string[] _List of scene IDs_ + +### getResolution **Deprecated** + +**Deprecated** This will currently return the default channel resolution. This needs to be replaced by a function that can get a scene or display resolution + +Get the default channel resolution. + +```javascript +api.getResolution(); +``` + +## Clients + ### getClients Get all connected clients. @@ -137,7 +236,7 @@ api.hasClient(clientId); **Returns** boolean _Client connected_ -### onNewClient +### onClientConnects Assigns an event to be triggered when a new ModuleClientAPI connects. @@ -149,6 +248,20 @@ api.onNewClient(callback); | -------- | ------------------------------------------------- | ------------------------------------------------------------ | | callback | ( client:[Client](./ModuleServerAPIClient) ):void | Function will be called when a new ModuleClientAPI connects. | +### onClientDisconnects + +Assigns an event to be triggered when a new ModuleClientAPI disconnects. + +```javascript +api.onNewClient(callback); +``` + +| Argument | Type | Description | +| -------- | ------------------------------------------------- | --------------------------------------------------------------- | +| callback | ( client:[Client](./ModuleServerAPIClient) ):void | Function will be called when a new ModuleClientAPI disconnects. | + +## Properties + ### onModulePropertyUpdate Register a listener for when a module property updates. @@ -162,6 +275,44 @@ api.onModulePropertyUpdate(propertyId, callback); | propertyId | string | The property ID that the listener will receive. | | callback | ( value:any ):void | Function that receives the new property value. | +### getModuleProperties + +Get all properties of the module. + +```javascript +api.getModuleProperties(); +``` + +**Returns** { [ propertyId:string ]: [Property](./ModuleServerAPIProperty) } _All module properties_ + +### getModuleProperty + +Get a property of the module. + +```javascript +api.getModuleProperty(propertyId); +``` + +| Argument | Type | Description | +| ---------- | ------ | --------------------------------------- | +| propertyId | string | The id of the property you want to get. | + +**Returns** [Property](./ModuleServerAPIProperty) _Reference property_ + +### hasModuleProperty + +Check if the module has a property. + +```javascript +api.hasModuleProperty(propertyId); +``` + +| Argument | Type | Description | +| ---------- | ------ | ----------------------------------------- | +| propertyId | string | The id of the property you want to check. | + +**Returns** boolean _Has module property_ + ### onReferencePropertyUpdate Register a listener for when a reference property updates in a scene change. @@ -175,58 +326,6 @@ api.onReferencePropertyUpdate(propertyId, callback); | propertyId | string | The property ID that the listener will receive. | | callback | ( value:any ):void | Function that receives the new property value. | -### onSceneChange - -Register for a listener when the module is part of a scene change. - -```javascript -api.onSceneChange(callback); -``` - -| Argument | Type | Description | -| -------- | ------------------------------------------------------------ | ---------------------------------------------------- | -| callback | ( displayId:string, origin:string, destination:string ):void | Function will be called when a scene change occures. | - -### onFileUpload - -Register for a listener for when a file is uploaded through the module file upload route. To use this send a HTTP post with the files in formData as the body to `http://serverIp:4080/:CHANNELNAME/upload/:MODULEID`. - -```javascript -api.onFileUpload(callback); -``` - -| Argument | Type | Description | -| -------- | ------------------------------------------------------------------------------------------ | -------------------------------------------------------- | -| callback | ( files: { filename:string, originalFilename:string, byUser:string, size:number }[] ):void | Function will be called when a file upload has finished. | - -### onTrigger - -Register a listener for when a trigger is called from a cue list. - -```javascript -api.onTrigger(triggerId, callback); -``` - -| Argument | Type | Description | -| --------- | -------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| triggerId | string | The trigger ID that the listener will receive. | -| callback | ( finish:function, status: (text:string)=>void, ...args:any[] ):void | Function will be called when the trigger is called from a cue list. The callback will receive the arguments in the same order they are defined in the [module.json](./ModuleJSON). | - -### onInit **Deprecated**. - -**Deprecated:** This is no longer needed, any code that needs to be run on init can be placed in the root. - -Register a listener for when the module is first loaded. - -```javascript -api.onInit(callback); -``` - -| Argument | Type | Description | -| --------- | -------- | -------------------------------------------------------- | -| triggerId | string | The trigger ID that the listener will receive. | -| callback | function | Function will be called when the module is first loaded. | - ### getReferenceProperties Get all properties of a module reference in a scene. @@ -271,43 +370,15 @@ api.hasReferenceProperty(sceneId, propertyId); **Returns** boolean _Has reference property_ -### getModuleProperties +## Snapshots -Get all properties of the module. +### onSnapshotRestore **(TODO)** -```javascript -api.getModuleProperties(); -``` +### onSnapshotCreate **(TODO)** -**Returns** { [ propertyId:string ]: [Property](./ModuleServerAPIProperty) } _All module properties_ +### getRuntimeStorage **(TODO)** -### getModuleProperty - -Get a property of the module. - -```javascript -api.getModuleProperty(propertyId); -``` - -| Argument | Type | Description | -| ---------- | ------ | --------------------------------------- | -| propertyId | string | The id of the property you want to get. | - -**Returns** [Property](./ModuleServerAPIProperty) _Reference property_ - -### hasModuleProperty - -Check if the module has a property. - -```javascript -api.hasModuleProperty(propertyId); -``` - -| Argument | Type | Description | -| ---------- | ------ | ----------------------------------------- | -| propertyId | string | The id of the property you want to check. | - -**Returns** boolean _Has module property_ +## Last State ### getLastState @@ -331,6 +402,8 @@ api.setLastState(state); | -------- | ----------------------------------- | ---------------------------- | | state | [ModuleData](./ModuleServerAPIData) | New laststate of the module. | +## Filesystem + ### readJSON Read a file as JSON. @@ -431,107 +504,6 @@ api.hasHost(hostId); **Returns** boolean \*Host ID is active. -### hostFile **Deprecated** - -**Deprecated** Replaced by: [addHost](./ModuleServerAPI#addhost) - -Make a file accessable through the webserver. - -```javascript -api.hostFile(scope, filename); -``` - -| Argument | Type | Description | -| -------- | --------------------- | ------------------------------------------------------------------------ | -| scope | 'module' \| 'channel' | The scope of the file, see [file scopes](./ModuleServerAPI#file-scopes). | -| filename | string | The name of the file. | - -\*_Returns_ { hostID:string, relativeUrl:string} _The data of the hosted file._ - -### removeHostFile **Deprecated** - -**Deprecated** Replaced by: [addHost](./ModuleServerAPI#removehost) - -Remove a file that is currently hosted. - -```javascript -api.removeHostFile(hostId); -``` - -| Argument | Type | Description | -| -------- | ------ | -------------------------------------------------- | -| hostId | string | The host id of the hosted file you want to remove. | - -### hasHostFile **Deprecated** - -**Deprecated** Replaced by: [addHost](./ModuleServerAPI#hashost) - -Check if host ID is still being hosted. - -```javascript -api.hasHostFile(hostId); -``` - -| Argument | Type | Description | -| -------- | ------ | ------------------------------------------------- | -| hostId | string | The host id of the hosted file you want to check. | - -**Returns** boolean \*Host ID is active. - -### finishServerCondition - -Finish a server condition. - -```javascript -api.finishServerCondition(conditionId); -``` - -| Argument | Type | Description | -| ----------- | ------ | ------------------------ | -| conditionId | string | The id of the condition. | - -### forceClientCondition - -Force a client condition. - -```javascript -api.forceClientCondition(conditionId); -``` - -| Argument | Type | Description | -| ----------- | ------ | ------------------------ | -| conditionId | string | The id of the condition. | - -### getModuleID - -Get the current module id. - -```javascript -api.getModuleID(); -``` - -**Returns** string _Module ID_ - -### getScenes - -Get a list of all scenes this module is a part of. - -```javascript -api.getModuleID(); -``` - -**Returns** string[] _List of scene IDs_ - -### getResolution **Deprecated** - -**Deprecated** This will currently return the default channel resolution. This needs to be replaced by a function that can get a scene or display resolution - -Get the default channel resolution. - -```javascript -api.getResolution(); -``` - ## Information ### File Scopes