diff --git a/ModuleServerAPI.md b/ModuleServerAPI.md index b2ce626..f267a09 100644 --- a/ModuleServerAPI.md +++ b/ModuleServerAPI.md @@ -24,6 +24,52 @@ api.Libs; **Return** [Libs](./ModuleServerAPILibs) _Included libraries_ +## System Events + +### onDestroy + +Register a listener for when the module is destroyed from a channel. Make sure you stop your clocks and render loops here. + +```javascript +api.onDestroy(callback); +``` + +| Argument | Type | Description | +| -------- | -------- | ------------------------------------------------------------ | +| callback | ( ):void | Function that will be called when the module gets destroyed. | + +## Getters + +### getModuleId + +Get the current module id. + +```javascript +api.getModuleId(); +``` + +**Returns** string _Module ID_ + +### getChannelId + +Get the current channel id. + +```javascript +api.getChannelId(); +``` + +**Returns** string _Channel ID_ + +### inDevelopmentMode + +Check if Getiyo is running in development mode. + +```javascript +api.inDevelopmentMode(); +``` + +**Returns** boolean _Development mode active_ + ## Communication ### on @@ -52,6 +98,21 @@ api.broadcast(header, ...args); | header | string | The header of the message. | | args | any[] | Data of any type. | +### registerWebhook + +Register a webhook that can be called externally on address /:channelHostname/m/wh/:webhookId/:arg1?/:arg2? + +```javascript +api.registerWebhook(webhookId, callback); +``` + +| Argument | Type | Description | +| --------- | --------------------- | ------------------------------------------------- | +| webhookId | string | The ID the webhook will use. | +| callback | (...args:any[] ):void | Callback with arguments provided through the url. | + +## Cues + ### finishServerCondition Finish a server condition. @@ -76,44 +137,6 @@ api.forceClientCondition(conditionId); | ----------- | ------ | ------------------------ | | conditionId | string | The id of the condition. | -## Events - -### onDestroy - -Register a listener for when the module is destroyed from a channel. Make sure you stop your clocks and render loops here. - -```javascript -api.onDestroy(callback); -``` - -| Argument | Type | Description | -| -------- | -------- | ------------------------------------------------------------ | -| callback | ( ):void | Function that will be called when the module gets destroyed. | - -### 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. @@ -127,38 +150,6 @@ api.onTrigger(triggerId, callback); | 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_ - -### getChannelId - -Get the current channel id. - -```javascript -api.getChannelId(); -``` - -**Returns** string _Channel ID_ - -### getScenes - -Get a list of all scenes this module is a part of. - -```javascript -api.getScenes(); -``` - -**Returns** string[] _List of scene IDs_ - ## Clients ### getClients @@ -337,6 +328,40 @@ api.hasReferenceProperty(sceneId, propertyId); **Returns** boolean _Has reference property_ +## Scenes + +### getScenes + +Get a list of all scenes this module is a part of. + +```javascript +api.getScenes(); +``` + +**Returns** string[] _List of scene IDs_ + +### getModuleScenes + +Get a list of all scenes this module is in. + +```javascript +api.getModuleScenes(); +``` + +**Returns** string[] _List of scene IDs_ + +### 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. | + ## Snapshots ### onSnapshotRestore @@ -499,6 +524,18 @@ api.hasHost(hostId); **Returns** boolean \*Host ID is active. +### 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. | + ## Information ### File Scopes