-
Notifications
You must be signed in to change notification settings - Fork 7
Communication
TCP/IP is used, rather than UDP. The reason is that some large blocks of data is sometimes sent, and TCP/IP helps assemble the messages and sort them in correct order.
All messages follow the same basic protocol:
LL LH ID M M M M ...
Where the length of the message is coded into the first two bytes. LL is the low byte of the 16 bit word, and LH the high byte. The length information includes the complete message (that is, the length bytes also).
Every message has an ID that identifies what type of message it is. The IDs (also called commands) are defined in Source/client_prot.h. Messages can be sent from several places in the client application, but always using the main process and the SendMsg function. All received messages are handled by parse(), also from the main process.
On the server side, a unique goroutine (light weight thread) is created for each connected player. They have one socket each. All incoming messages for a player is read and parsed by ManageOneClient2_WLuWLqWLmBlWLcWLw. The sending of messages from the server is done from many places, but they all pass through writeBlocking_Bl, in the goroutine allocated for the player.