Game Development Reference
In-Depth Information
Initialize
Create new Session
Session 0
Check for
new connections
Read from socket
Session 1
Read
Write to socket
Session N
Write
Message
The message contains a series of bytes starting with a header followed by the
message itself. The message implementation in this example is simple.
Body
Header
Type
(int)
Body Length
(int)
The message header typically consists of the description of the message body, and
the previous screenshot shows that the there are two fields:
• Message type
• Message body length
The message type determines how the message is encoded and what it represents.
In the example, we have two messages: login and chat. Each message has its set of
data that is stored in the message body, thus the client and server must encode and
decode in the same way.
 
Search WWH ::




Custom Search