-
Notifications
You must be signed in to change notification settings - Fork 0
Network Protocols
Kurtis edited this page Dec 31, 2020
·
2 revisions
The multiplayer networking for Gravity Box Arena is based on JavaScript WebSockets, and has a NodeJS backend.
This page will document various aspects of the networking.
Packets are individual packages of data that get sent to and from the server. This section will go over how a packet is structured, as well as any specific codes you will need.
Note: All numbers should be encoded in big endian for consistency.
Byte Index | Description |
---|---|
0 |
The packet type identifier. |
1-5 |
The player key. |
6- |
Any extra data. |
Byte Index | Description |
---|---|
0 |
The packet type identifier. |
1- |
Data. |
The packet type identifier is used to identify what kind of data a packet contains. Below is a table of identifiers and their meanings.
Identifier | Name | Description |
---|---|---|
1 |
REQUEST_AUTH | Request authorization from the server. The server will respond with a generated player key (5-byte string). |
2 |
REQUEST_JOIN_OR_CREATE_LOBBY | Request to join a lobby. If a lobby is not found, create and join one. The server will respond with the lobby ID (32-bit signed integer, big endian). |
3 |
SYNC_DATA | Sends the packet data to all other clients in the sender's lobby. |
Disconnect codes are sent when a user is disconnected by the server.
Code | Name | Description |
---|---|---|
1 |
BAD_PACKET | The server received a packet with a nonexistent identifier. |