Fixed some typos

2025-12-09 11:22:26 +00:00
parent cc5832e7a4
commit 58a0ecea16

@@ -1,107 +1,107 @@
# Getiyo WebSocket Bridge # WebSocket Lib Communication Standard
Document that describes the messaging standard that Getiyo uses for WebSocket communication with external software and tools. Document that describes the messaging standard that Getiyo uses for WebSocket communication with external software and tools.
## Connection ## 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). 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 ## 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](#message-type-error), if the authentication is succesful you'll receive the `SYSTEM` message [authOk](#authok). 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](#message-type-error), if the authentication is succesful you'll receive the `SYSTEM` message [authOk](#authok).
```JSON ```JSON
{ {
"packet": "AUTH", "packet": "AUTH",
"channelId": "fakeChannelId123", "channelId": "fakeChannelId123",
"moduleIds": [ "moduleIds": [
"fakeModuleId1", "fakeModuleId1",
"fadeModuleId2" "fadeModuleId2"
], ],
"apiKey": "fakeApiKey" "apiKey": "fakeApiKey"
} }
``` ```
## Message Encoding/Decoding ## 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. 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` ## Message type `NORMAL`
Normal messaging from module to external service. Normal messaging from module to external service.
```typescript ```typescript
api.Libs.getWebSocket().broadcast('setScore', 'fakePlayerId123', 10); api.Libs.getWebSocket().broadcast('setScore', 'fakePlayerId123', 10);
``` ```
```JSON ```JSON
{ {
"packet": "NORMAL", "packet": "NORMAL",
"header": "setScore", "header": "setScore",
"args": [ "args": [
"fakePlayerId123", "fakePlayerId123",
10 10
] ]
} }
``` ```
Messaging from external service to module. Messaging from external service to module.
```JSON ```JSON
{ {
"packet": "NORMAL", "packet": "NORMAL",
"moduleId": "fakeTargetModuleId", "moduleId": "fakeTargetModuleId",
"header": "setScore", "header": "setScore",
"args": [ "args": [
"fakePlayerId123", "fakePlayerId123",
10 10
] ]
} }
``` ```
## Message type `ERROR` ## 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. 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.
```JSON ```JSON
{ {
"packet": "SYSTEM", "packet": "ERROR",
"type": "auth", "type": "auth",
"message": "An error message." "message": "An error message."
} }
``` ```
### `auth` ### `auth`
Invalid authentication. Invalid authentication.
### `notExist` ### `notExist`
Channel/Module/WebSocket Listeners Channel/Module/WebSocket Listeners
## Message type `SYSTEM` ## 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. 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` ### `id`
The id of the socket client once authentication was completed. The id of the socket client once authentication was completed.
```JSON ```JSON
{ {
"packet": "SYSTEM", "packet": "SYSTEM",
"type": "id", "type": "id",
"id": "fakeSocketClientId123" "id": "fakeSocketClientId123"
} }
``` ```
### `authOk` ### `authOk`
Triggered when the authentication was completed. Triggered when the authentication was completed.
```JSON ```JSON
{ {
"packet": "SYSTEM", "packet": "SYSTEM",
"type": "authOk", "type": "authOk",
} }
``` ```