<< Chapter < Page | Chapter >> Page > |
8. A Simple Chat Protocol
SERVERINFO
cmd_serverinfo {
byte type = 0;byte cmd = 0;
};status_serverinfo {
byte type = 1;byte cmd = 0;
byte status = N; // 0 = OK, 1 = FAILbyte length = M; // Size of message
byte[]message;
};OUTPUT: [SERVER] – Copyright 2004 Your Name Here, CSE4/521OUTPUT: [SERVER] – ERROR : SERVERINFO Command Failed
LOGIN<nickname>
cmd_login {
byte type = 0;byte cmd = 1;
byte length = N;byte[] nickname;};
status_login {byte type = 1;
byte cmd = 1;byte status = N; // 0 = OK, 1 =FAIL
// 2 = Nickname in use// 3 = Already logged in
};OUTPUT: [SERVER] – User<nickname>logged in.
OUTPUT: [SERVER]– ERROR : LOGIN error.
OUTPUT: [SERVER]– ERROR : LOGIN nickname<nickname>in use.
OUTPUT: [SERVER]– ERROR : LOGIN user already logged in.
LOGOUT
cmd_logout {
byte type = 0;byte cmd = 2;
};status_logout {
byte type = 1;byte cmd = 2;
byte status = N; // 0 = OK, 1 FAIL// 2 = Not logged in
};OUTPUT: [SERVER] – User<nickname>logged out.
OUTPUT: [SERVER]– ERROR : LOGOUT error.
OUTPUT: [SERVER]– ERROR : User not logged in.
WHOSINROOM
cmd_whoroom {
byte type = 0;byte cmd = 3;
};status_whoroom {
byte type = 1;byte cmd = 3;
byte status = N; // 0 = OK, 1 FAIL};
data_whoroom {byte type = 2;
byte cmd = 3;byte entry = count; // nickname count
byte pos = X; // 0 = Middle, 1 = First, 2 = Lastbyte length = L; // message length
byte[]msg; // Single message Entry
};OUTPUT: [SERVER] – ERROR : WHOSINROOM error.OUTPUT: [SERVER] – User :<X>NickName:<nickname>(As many data N data message representing N nicknames will be sent)
SEND<message>
cmd_send {
byte type = 0;byte cmd = 4;
byte length = N;byte[] message;};
status_send {byte type = 1;
byte cmd = 4;byte status = N; // 0 = OK, 1 FAIL
// 2 = Not in room};
bcast_send {byte type = 3;
byte cmd = 4;byte length = N;
byte[]msg; // Single message Entry
};OUTPUT: [SERVER] – ERROR : SEND error.OUTPUT: [SERVER] – ERROR : SEND not in room.OUTPUT: [<nickname>] –<msg>Send message is sent from a client to the server, which then broadcasts to all the clients.
WHISPER<nickname><message>
cmd_whisper {
byte type = 0;byte cmd = 5;
byte nlength = M;byte[] nickname;byte length = N;
byte[]message;
};status_whisper {
byte type = 1;byte cmd = 5;
byte status = N; // 0 = OK, 1 FAIL// 2 = Not in room
// 3 = nickname not found};
bcast_whisper {byte type = 3;
byte cmd = 5;byte length = N;
byte[]msg; // Single message Entry
};OUTPUT: [SERVER] – ERROR : WHISPER error.OUTPUT: [SERVER] – ERROR : WHISPER not in room.OUTPUT: [*<nickname>*] –<msg>
QUIT
This command on the server side shuts the server down and cleans up all the space. (On the client side Logout command itself will terminate the server program.)
Important Note: You are required to follow strictly the protocol given. This will allow us to test your sever with our client during the demo for the project. Please do not implement any more commands than specified above. You may not have time to do that. I would rather prefer you spend your time to implement the commands given in section 8.
Notification Switch
Would you like to follow the 'Operating systems' conversation and receive update notifications?