Difference between revisions of "UNX511 Winter2012 TeamB Network Protocol"
Idshibanov (talk | contribs) (Created page with '== Project Platypus - Introduction == This semester we are developing a co-operative multiplayer game in UNX511. The project will include: a Unix-based server written in C and mu…') |
Idshibanov (talk | contribs) |
||
Line 1: | Line 1: | ||
− | == | + | == Network Core - General == |
− | + | *[https://github.com/idshibanov/project-platypus/tree/network-core Current source code] | |
− | + | All network protocol related source files are located in /net folder. | |
+ | To prevent confusion, everything with "Client" in its name (e.g. ClientStatus or ClientSocketHandler) works on the client side, and similarly everything with "Server" - on the server side. | ||
− | + | Basic algorithm: | |
− | + | *1. Client connects to a server, creates an instance of ClientSocketHandler class | |
+ | *2. To send data, client uses functions inside ClientSocketHandler class (e.g. SendChatMsg) | ||
+ | *3. Client runs select() function, and if there is something, uses RecvPacket() function | ||
− | == | + | == Authorization Process == |
− | |||
− | |||
− | |||
− | |||
− | = | + | <syntaxhighlight lang="cpp"> |
− | + | enum ClientStatus{ | |
+ | STATUS_CLIENT_OFFLINE, // initial state | ||
+ | STATUS_CLIENT_REGISTRATION, // trying to register | ||
+ | STATUS_CLIENT_CONNECTED, // just connected | ||
+ | STATUS_CLIENT_AUTHORIZED, // succesfully logged in | ||
+ | STATUS_CLIENT_JOINED, // joined game lobby (intermission) | ||
+ | STATUS_CLIENT_GAME_STARTED, // game is starting | ||
+ | STATUS_CLIENT_GAME_INIT, // downloading game map data | ||
+ | STATUS_CLIENT_GAME_READY, // ready to go | ||
+ | STATUS_CLIENT_GAME_ACTIVE, // playing | ||
+ | STATUS_CLIENT_END // always at the end | ||
+ | }; | ||
+ | </syntaxhighlight> | ||
− | |||
− | |||
− | + | == Network Packet == | |
+ | *[https://github.com/idshibanov/project-platypus/blob/network-core/net/packet.cpp packet.cpp] | ||
+ | *[https://github.com/idshibanov/project-platypus/blob/network-core/net/packet.h packet.h] | ||
− | |||
− | == | + | == Client Socket Handler == |
− | + | *[https://github.com/idshibanov/project-platypus/blob/network-core/net/client_socket.cpp client_socket.cpp] | |
+ | *[https://github.com/idshibanov/project-platypus/blob/network-core/net/client_socket.h client_socket.h] | ||
− | + | ClientSocketHandler is a derived class from a abstract SocketHanlder and contains member functions that work specifically on a client side. | |
− | Server | + | == Server Socket Handler == |
+ | *[https://github.com/idshibanov/project-platypus/blob/network-core/net/server_socket.cpp server_socket.cpp] | ||
+ | *[https://github.com/idshibanov/project-platypus/blob/network-core/net/server_socket.h server_socket.h] | ||
+ | Will be documented later. | ||
− | + | == Links == | |
− | + | *[https://github.com/idshibanov/project-platypus/network Committed progress graph] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | * | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 15:04, 2 April 2012
Contents
Network Core - General
All network protocol related source files are located in /net folder.
To prevent confusion, everything with "Client" in its name (e.g. ClientStatus or ClientSocketHandler) works on the client side, and similarly everything with "Server" - on the server side.
Basic algorithm:
- 1. Client connects to a server, creates an instance of ClientSocketHandler class
- 2. To send data, client uses functions inside ClientSocketHandler class (e.g. SendChatMsg)
- 3. Client runs select() function, and if there is something, uses RecvPacket() function
Authorization Process
enum ClientStatus{
STATUS_CLIENT_OFFLINE, // initial state
STATUS_CLIENT_REGISTRATION, // trying to register
STATUS_CLIENT_CONNECTED, // just connected
STATUS_CLIENT_AUTHORIZED, // succesfully logged in
STATUS_CLIENT_JOINED, // joined game lobby (intermission)
STATUS_CLIENT_GAME_STARTED, // game is starting
STATUS_CLIENT_GAME_INIT, // downloading game map data
STATUS_CLIENT_GAME_READY, // ready to go
STATUS_CLIENT_GAME_ACTIVE, // playing
STATUS_CLIENT_END // always at the end
};
Network Packet
Client Socket Handler
ClientSocketHandler is a derived class from a abstract SocketHanlder and contains member functions that work specifically on a client side.
Server Socket Handler
Will be documented later.