-
Notifications
You must be signed in to change notification settings - Fork 0
Network packet types
jSpace2d will have 2 main packet types: TCP and UDP. (you don't say :D)
TCP packets will be mainly used for two things: controlling the client connection to the game, and regularly broadcasting the map to clients.
UDP packets on the other side, are only used to update the client's world between a TCP "keyframe" and the next one. We plan on sending out 2 or 4 TCP keyframes per second, and 30 or 60 "delta UDP packets" per second. UDP packets only contain actions that may be performed by the client, so we don't need to send out absolute positions and velocities for every entity in the game (thus saving lots of bandwidth).
Every TCP packet has a 1 byte header to identify its type. Since java doesn't natively support unsigned bytes, we will indicate byte values that range from -128 to 127. (note: this only applies to java! If using unsigned bytes range obviously goes from 0->255)
byte | value |
---|---|
0 | TCP packet type |
1->... | TCP packet data |
TODO