Protocol Design (Draft version 0.1)

Introduction

Currently, we will divide the protocol into three parts: Server-Server Communication, Server-Client Communication and Client-Client Communication.

Server-Client Communication

Packet Format (Client Side)

Length Content (if fixed) Designation Description
2 bytes 01 00 VERSION Protocol version (First version)
1 byte 01 PACKET_TYPE Indicate it is server to client packet
4 bytes xx xx xx xx UNICHAT_NO Your (the client's) Number
4 bytes xx xx xx xx SESSION_ID Used to prevent 'spoofing'.
2 bytes xx xx COMMAND See below for list of commands
2 bytes xx xx SEQ_NUM Starts at 1 (Use for acknowledgement)
4 bytes xx xx xx xx CHECKCODE Use for valid the packet
variable xx ... PARAMETERS Parameters for the command being sent

These commands will be included (Client Side):

Command Name Command Code Description
CLI_LOGIN 00 01 For Login to UNICHAT Server
CLI_LOGOUT 00 02 For Logout from UNICHAT Server
CLI_ACK 00 03 (Indicate the client has received the packet from UNICHAT Server
CLI_SEND_MSG 00 04 Send a message to other user through UNICHAT Server
CLI_KEEP_ALIVE 00 05 Inform UNICHAT Server that the client still online
(Send every 2 minutes)
CLI_SEND_CONTACT 00 06 Indicate the client wish to receive online events from these people
CLI_REG_NEW 00 07 Register a new user through UNICHAT Server
CLI_SELF_STATUS 00 08 Indicate the client's status (online or offline)
CLI_ADD_USER 00 09 Add friend into contact list
CLI_DEL_USER 00 0A Delete friend from contact list
CLI_INI_SRH 00 0B Initial a search with UNICHAT number as key


Packet Format (Server Side)

Length Content (if fixed) Designation Description
2 bytes 01 00 VERSION Protocol version (First version)
1 byte 02 ZERO Indicate it is client to server packet
4 bytes xx xx xx xx SESSION_ID Same as in your login packet.
2 bytes xx xx COMMAND See below for list of commands
2 bytes xx xx SEQ_NUM Sequence number for acknowledgement
4 bytes xx xx xx xx UNICHAT_NO Your (the client's) Number
4 bytes xx xx xx xx CHECKCODE Use for valid the packet
variable xx ... PARAMETERS Parameters for the command being sent

These commands will be included (Server Side):

Command Name Command Code Description
SRV_LOGIN_REPLY 00 01 Indicate valid login for client
SRV_ACK 00 03 Indicate server has receive the packet from client
SRV_RECV_MSG 00 04 Indicate a user has send messge to the client through server
SRV_USER_STATUS 00 05 Indicate a user has change status
SRV_AWAY 00 06 Indicate server is away from client
SRV_SRH_RESULT 00 0B Indicate it is search result packet

Server-Server Communication

Under Construction

Client-Client Communication

Under Construction (If we only support web-based client, then Client-Client Communication must be implemented by Java Applet. However, for such structure, special port need to open which made not be supported in the client side)

If you have any suggestion, free feel to contact us