6
WebSocketLibCommuncationStandard
Mees van der Wijk edited this page 2025-12-09 16:15:50 +01:00

WebSocket Lib Communication Standard

Document that describes the messaging standard that Getiyo uses for WebSocket communication with external software and tools.

Connection

Connect with a WebSocket client to the address of the Getiyo instance, use the port that is specified in your Getiyo config (default 4081).

Authentication

Once you're connected to the WebSocket server it is very important you immediately send an AUTH message. If you are unable to authenticate within 5 seconds you'll be automatically disconnected. For authentication feedback see errors, if the authentication is succesful you'll receive the SYSTEM message authOk.

{
    "packet": "AUTH",
	"channelId": "fakeChannelId123",
	"moduleIds": [
        "fakeModuleId1",
        "fadeModuleId2"
    ],
	"apiKey": "fakeApiKey"
}

Message Encoding/Decoding

Messages are encoded as stringified JSON and always includes a packet attributes. This attributes specifies the packet type, see the types below. This format applies to both directions of communication.

Message type NORMAL

Normal messaging between a module and an external service.

When sending messages from an external service to a module make sure you specify the moduleId in your packet. See the 2nd example below.

api.Libs.getWebSocket().broadcast('setScore', 'fakePlayerId123', 10);
{
    "packet": "NORMAL",
    "header": "setScore",
    "args": [
        "fakePlayerId123",
        10
    ]
}

Messaging from external service to module.

{
    "packet": "NORMAL",
    "moduleId": "fakeTargetModuleId",
    "header": "setScore",
    "args": [
        "fakePlayerId123",
        10
    ]
}

Message type ERROR

There are a messages that can only be send by Getiyo and contain server-side errors. The system message packet always contains a type attribute which specifies the system message type and a message attribute that has the actual error.

{
    "packet": "ERROR",
    "type": "auth",
    "message": "An error message."
}

auth

Invalid authentication.

notExist

Channel/Module/WebSocket Listeners

invalid

Invalid operations.

Message type SYSTEM

There are a messages that can only be send by Getiyo and contain general data. The system message packet always contains a type attribute which specifies the system message type.

id

The id of the socket client once authentication was completed.

{
    "packet": "SYSTEM",
    "type": "id",
    "id": "fakeSocketClientId123"
}

authOk

Triggered when the authentication was completed.

{
    "packet": "SYSTEM",
    "type": "authOk",
}