Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 1.4 KB

format.md

File metadata and controls

30 lines (23 loc) · 1.4 KB

The message format

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.

Examples

(\0 represents the NULL character)

Client -> Server

  • NICJacob\0\0 - Change my nick to Jacob
  • MSGHello, world!\0\0 - Send the message Hello, world! to everyone under my nickname

Server -> Client

  • ACC\0 - I accept your connection
  • NICGuest\0\0 - I assign you the nick of Guest1
  • MSGJacob\0Hello, world!\0\0 - Jacob has sent the message Hello, world!