We have also now added the ability for the HippoAPI to generate “Callbacks” to users webpages to inform them of certain actions such as New Media has been added, media has been changed, timeline has been added, preset added etc…We do this by using WebSockets which can be accessed in javascript code from the users webpage.

Creating callbacks

To use websockets, the user has to first connect to the websocket server by using the following URL syntax:

URL Syntax

ws://<serverhost>:40513    // <serverhost> is replaced with the servers access url or ip address.

Example

ws://192.168.0.50:40513

Once the connection is established, the user must then subscribe to the event categories that they want to receive notifications about, currently the categories are:

  • MEDIA : events related to media such as mediamap changed, media added, media changed, media deleted
  • PRESETS: events related to add, delete and modification of presets
  • SYSTEM: events related to system status or configuration

An example piece of code for subscribing to these events is given here:

const apiBaseURL = window.location.hostname; 
const prefix = 'ws://'; 
const websocketURL = prefix.concat(apiBaseURL,':40513'); 
const ws = new WebSocket(websocketURL); 
ws.addEventListener('open', (event) => { 
const subscription = [ 
    {"subscribe" : {
        "category" : "MEDIA"
        }}, 
    {"subscribe" : {
        "category" : "SYSTEM"
        }}, 
    {"subscribe" : {
        "category" : "PRESETS"
    }}
    ] 
    const message = JSON.stringify(subscription); 
    ws.send(message);
    }); 
ws.addEventListener('message', (event) => {
    // process the event data here 
    // the actual event is inside event.data
    })

Responses


MEDIA Subscription

Event

MEDIAMAP_CHANGED

Description

Event is raised when the mediamap is changed in any way, file added, file removed or file moved

Response

event.data =
{
    “category” : “MEDIA”, 
    “event” : “MEDIAMAP_CHANGED”
}


Event

MEDIAFILES_ADDED

Description

Event is raised when the and new media is added to the database by any means, data contains the mediaID of the added media

Response

event.data =
{ 
    “category” : “MEDIA”, 
    “event” : “MEDIAFILES_ADDED”, 
    “data” : [
        {
            “mediaID”:” 00c82c53-156d-4601- 
        aed8e97c175e0479_00B50D458F9E755CC817B142F80B1FB2_2e823641-da0d-602e-b7e2- 
        446f47b0c0a0”
        }, 
        {
            “mediaID”:” 1a76a123-2dbe-4a6f-be58- 
            d2a843e47724_5748CF198C351138C8C0B3EE40106E34_dbc0cfe2-caad-e1b9-c71c- 
            7844bb1b1155”
        }, 
        {
            “mediaID”:” 9ed8aaf0-ec7c-433c-8ef0- 
            cc81da621f09_69C2DAEB3952F75A990AC3947B934D27_c9250c48-db07-88be-8460- 
            96aa5524c775”
        }
        ] 
        }


Event

MEDIAFILE_DELETED

Description

Event is raised when a media file is deleted from the database, data contains the mediaID of the file that was deleted

Response

event.data =
{
    “category” : “MEDIA”, 
    “event” : “MEDIAFILE_DELETED”, 
    “data” : “00c82c53-156d-4601-             
    aed8e97c175e0479_00B50D458F9E755CC817B142F80B1FB2_2e823641-da0d-602e-b7e2-        
    446f47b0c0a0”
}


Event

MEDIAFILE_CHANGED

Description

Event is raised when a media file is changed data contains the mediaID of the file that was changed

Response

event.data =
{
    “category” : “MEDIA”, 
    “event” : “MEDIAFILE_CHANGED”, 
    “data” : “00c82c53-156d-4601-     
    aed8e97c175e0479_00B50D458F9E755CC817B142F80B1FB2_2e823641-da0d-602e-b7e2-    
    446f47b0c0a0” 
}

PRESETS Subscription

Event

PRESET_ADDED

Description

Event is raised when a new preset has been added, data contains the bank and slot of the preset and the type of the preset added.

Response

event.data =
{ “category” : “PRESETS”, “event” : “PRESET_ADDED”, “data” : { “presetid”:” 00c82c53-156d-4601-aed8e97c175e0479”, “bank”:”5”, “slot”:”16”, “type”:”layer” }
}



Event

PRESET_DELETED

Description

Event is raised when a preset is deleted, data contains the preset ID of the preset that was deleted

Response

event.data =
{
    “category” : “PRESETS”, 
    “event” : “PRESET_DELETED”, 
    “data” : “00c82c53-156d-4601-aed8e97c175e0479” 
}


Event

PRESET_CHANGED

Description

Event is raised when a preset has been modified or moved, data contains the bank and slot of the preset and the type of the preset changed.

Response

event.data =
{
    “category” : “PRESETS”, 
    “event” : “PRESET_CHANGED”, 
    “data” : { 
        “presetid”:” 00c82c53-156d-4601-aed8e97c175e0479”, 
        “bank”:”5”, 
        “slot”:”16”, 
        “type”:”layer” 
        } 
}


Event

PRESETS_RESET

Description

Event is raised when the preset manager is reset and all presets are deleted

Response

event.data =
{
    “category” : “PRESETS”, 
    “event” : “PRESES_RESET”, 
}

SYSTEM Subscription

Event

CONFIG_CHANGED

Description

Event is raised when the system config has been changed, outputs added, mixes changed etc..

Response

event.data =
{
    “category” : “SYSTEM”, 
    “event” : “CONFIG_CHANGED”, 
}


Event

SYSTEM_STATUS_CHANGED

Description

Event is raised when the output system status has changed ie. If the system is rendering or not.

Response

event.data =
{
    “category” : “SYSTEM”, 
    “event” : “SYSTEM_STATUS_CHANGED”, 
    “data” : “Configuring” 
}

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Please do not use this for support questions.
Green Hippo Forum

Post Comment