Skip to content

Commit

Permalink
Add examples to the networking docs (#786)
Browse files Browse the repository at this point in the history
  • Loading branch information
Indy2222 authored Feb 22, 2024
1 parent faa88ee commit 62e7ea1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/src/multiplayer/connector/protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,32 @@ participants. This is indicated by the fourth highest bit of the flags byte

Package payload comprises the user data intended for delivery.

### Examples

The datagram carrying a semi-reliable package with ID 107907,
targeted to the server and containing the payload bytes `0x12 0x34 0x56`, would
look like this: `0x50 0x01 0xA5 0x83 0x12 0x34 0x56`.

1. `0x50` (`0b0101_0000`) – flags: semi-reliable, server targeted
1. `0x01 0xA5 0x83` – package ID: 107,907
1. `0x12 0x34 0x56` – package payload

## Protocol Control

Currently, the only type of control datagram is the delivery confirmation
datagram. All bits in the header of these datagrams, except for the first one,
are set to 0. The payload consists of IDs for all user data datagrams that have
been sent reliably and delivered successfully. Each ID is encoded using 3
bytes.

### Examples

A datagram confirming three packages with IDs 1238, 17, and 2443, respectively,
would look like this: `0x80 0x00 0x00 0x00 0x00 0x04 0xD6 0x00 0x00 0x11 0x00
0x09 0x8B`.

1. `0x80` (`0b1000_0000`) – protocol control flag
1. `0x00 0x00 0x00` – always zeros
1. `0x00 0x04 0xD6` – first confirmed package ID equal to 1238
1. `0x00 0x00 0x11` – second confirmed package ID equal to 17
1. `0x00 0x09 0x8B` – third confirmed package ID equal to 2443

0 comments on commit 62e7ea1

Please sign in to comment.