UFO2000 Wiki   Main /
ServerProtocol
SearchWiki
Main.RecentChanges
Edit Page
Page Revisions

Please also see proposed ServerProtocolExtensions.
NetworkProblemsMitigation? page is also relevant.

Most of server related information can be obtained from sources of the game (server_protocol.* and server_transport.* files)

In general, client connects to the server by creating a socket in stream mode. Logically, the stream of data consists from packets each having a header with first 4 bytes being the size of a packet in bytes, next 4 bytes - packet id and the rest - packet data. Packet size and ID are 32-bit values in network byte order.

The packets can have one of the following ID values:

 
// server replies
#define SRV_FAIL               0
#define SRV_OK                 1

// commands
#define SRV_LOGIN              2
#define SRV_MESSAGE            3
#define SRV_CHALLENGE          4
#define SRV_GAME_START_HOST    5
#define SRV_GAME_START_JOIN    6

// user status update notifications
#define SRV_USER_ONLINE        7
#define SRV_USER_OFFLINE       8
#define SRV_USER_CHALLENGE_IN  9
#define SRV_USER_CHALLENGE_OUT 10
#define SRV_USER_BUSY          11

#define SRV_GAME_PACKET        12
#define SRV_ENDGAME            13

#define SRV_DEBUG_MESSAGE      14


By the way, all the packets that are received by server are logged, so you can start standard ufo2000 server, connect to it with your test client and view log to see if the server interprets what you send to it as expected.

lxnt:
I rewrote the server in Python. This required understanding the protocol, so here's how I understood it:

First packet is always from client to server, and is always SRV_LOGIN, payload being username and password separated by colon (':').

Second packet is always from server to client, and is the result of authentication - SRV_OK or SRV_FAIL. The latter may contain error message as payload.

In my implementation, after having sent SRV_FAIL, server does not drop the connection, so that client can retry authenticating.

After successful SRV_LOGIN, client is in 'online' state. It is considered being in the chatroom.

Client can send packets of type (PACKET_TYPE [payload] description):

Server currently does send SRV_FAIL messages if some action has failed. Hovewer, in the absence of explicit protocol synchronization, client can not determine exactly which packet caused what error. "User-visible" errors are sent as SRV_MESSAGEs , with 'Server: ' prefix.

Client must be prepared to receive packets of type:

In gameplay mode server only accepts three types of packets: Information on this page is not complete and corrections are welcome.


Edit Page - Page Revisions - WikiHelp - SearchWiki - RecentChanges
Page last modified on August 29, 2004, at 12:13 PM