The project uses protlib
, which uses a custom protocol described in its README.
This is merely a description of the format that the server
and client
use for communication.
Note that the format of messages with the same head may have a different meaning and structure depending on whether it comes from the client or the server.
These are all the message formats:
Head | From a client | From the server |
---|---|---|
ACC |
0 arguments Connection accepted |
|
REF |
0 arguments Connection refused |
|
MSG |
1 argument The message to be sent to everyone |
2 arguments The sender of the message, The text of the message |
NIC |
1 argument Request to use a nick |
1 argument The new nick assigned/confirmed by the server |
There are obviously ways to optimise this (such as caching nicknames client-side), one example
optimisation that I made is actually the NIC
message, which caches nicks on the server side.
(\0
represents the NULL character)
Client -> Server
NICJacob\0\0
- Change my nick toJacob
MSGHello, world!\0\0
- Send the messageHello, world!
to everyone under my nickname
Server -> Client
ACC\0
- I accept your connectionNICGuest\0\0
- I assign you the nick ofGuest1
MSGJacob\0Hello, world!\0\0
-Jacob
has sent the messageHello, world!