Skip to content

Commit

Permalink
Add system/disconnected event
Browse files Browse the repository at this point in the history
  • Loading branch information
geekingfrog committed Nov 24, 2024
1 parent 6d80303 commit d87345f
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/schema/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@

# System

System commands to manage the connection itself and get updates from the server.

* [disconnect](#disconnect) is the event to send to the server before
stopping the connection. If the client closes the connection without first
sending this event, it will be considered as a client crash by the server.

* [disconnected](#disconnected) is the dual of `disconnect` where the server
is terminating the connection and disconnecting the user. This can happen
if the server detects a timeout, either because no activity on the connection
or the server is expecting a response to a request and hasn't received it (and
all potential retries have been exhausted). `server_error` is sent when the
server encountered a fatal error for the user and the only way to recover is
to reconnect.

* [serverStats](#serverStats) can be used to request generic, user facing data
about the server like number of connecting players.

---
- [disconnect](#disconnect)
- [serverStats](#serverstats)
---
Expand Down
28 changes: 28 additions & 0 deletions schema/system/disconnected/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$id": "https://schema.beyondallreason.dev/tachyon/system/disconnected/event.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "SystemDisconnectedEvent",
"tachyon": {
"source": "server",
"target": "user",
"scopes": ["tachyon.lobby"]
},
"type": "object",
"properties": {
"type": { "const": "event" },
"messageId": { "type": "string" },
"commandId": { "const": "system/disconnected" },
"data": {
"title": "SystemDisconnectedEventData",
"type": "object",
"properties": {
"reason": {
"enum": ["protocol_violation", "server_error", "timeout"]
},
"details": { "type": "string" }
},
"required": ["reason"]
}
},
"required": ["type", "messageId", "commandId"]
}
16 changes: 16 additions & 0 deletions src/schema/system/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
System commands to manage the connection itself and get updates from the server.

* [disconnect](#disconnect) is the event to send to the server before
stopping the connection. If the client closes the connection without first
sending this event, it will be considered as a client crash by the server.

* [disconnected](#disconnected) is the dual of `disconnect` where the server
is terminating the connection and disconnecting the user. This can happen
if the server detects a timeout, either because no activity on the connection
or the server is expecting a response to a request and hasn't received it (and
all potential retries have been exhausted). `server_error` is sent when the
server encountered a fatal error for the user and the only way to recover is
to reconnect.

* [serverStats](#serverStats) can be used to request generic, user facing data
about the server like number of connecting players.

0 comments on commit d87345f

Please sign in to comment.