** Commands: * All messages should be in ASCII-text format (easy to debug), exept cases noted explicitly. * No answer in some period of time means error. We should add some error handlers here. * Login * Ping * Get maps * Choose map/connect to game * Move/Update Every command should be packed as following: ---------------------------------------------------- |Header:4b|PacketSize:2b|Packet:PacketSize|CRC32:4b| ---------------------------------------------------- Header == "HOMM" (4bytes) CRC32 must be computed against Header, PacketSize and Packet. ** Login: Q: <<"L=":2b, PlayerName:VariableSize>> A: <<"L=OK":4b, "ID=":4b, PlayerID:16b>> A: <<"L=FAIL":6b, "REASON=":7b, ErrorReason:?b>> Notes: * PlayerName - some textual name ("Crag Hack", "Conan The Destroyer", "Jaunty Jackalope") * PlayerID - some text, probably hexnumber (0x123, 0xDEADBEEF, 123456@127.0.0.1) * ErrorReason - some number (0x00001, 12345, 0543). Maybe better to use some text messages? ** Ping Q: <<"Ping":4b, PlayerID:16b>> A: <<"Pong":4b>> A: <<"NOTFOUND":8b>> Notes: * If ping from server to (probably NAT'ed) client, then client must check PlayerId against its own. Client may reply with "NOTFOUND" * If ping from client to server, then server should update address of PlayerID (if found) or reply with "NOTFOUND" otherwise. * Server must ping all clients periodically ** Get maps Q: <<"Maps":4b, "F=":2b, FromNumber:2b, "T=":2b, ToNumber:2b>> A: <<"Map":3b, "N=":2b, MapNumber:2b, "F=":2b, TotalMapsNumber:2b>> ++ <> A: <<"Map":3b, "N=":2b, MapNumber:2b, "NOTFOUND":8b>> Notes: * Firstly, user should query maps from 0 to 0, and server starts sending all maps * User also may request maps starting from 0 to 1, and from 1 to 2, and so on, to create list of maps one by one. * NOTFOUND means end of maps list. ** Choose map/Connect to map Q: <<"Game":4b, MapNumber:2b, PlayerID:16b, PlayAs:2b>> A: <<"Game":4b, MapNumber:2b, PlayerID:16b, PlayAs:2b, "OK":2b, GameID:16b>> A: <<"Game":4b, MapNumber:2b, PlayerID:16b, PlayAs:2b, "ERR":3b>> ** Move/Update Q: <<"UPDATE":6b, "GameID=":7b, GameID:16b, "Player=":7b, PlayerID:16b, "Object=":7b, ObjectID:16b, UpdateID:16b>> ++ <> A: <<"UPDATE":6b, "GameID=":7b, GameID:16b, "Player=":7b, PlayerID:16b, "Object=":7b, ObjectID:16b, UpdateID:16b, "OK":2b>> A: <<"UPDATE":6b, "GameID=":7b, GameID:16b, "Player=":7b, PlayerID:16b, "Object=":7b, ObjectID:16b, UpdateID:16b, "ERR":3b>> Notes: * All updates should pass through server (it validates them and rejects cheats and malformed updates) * We should add game monster's updates as well * Each update must be immediately sent to all connected clients (probably to initial sender too) * Server can generate updates too * Every update which sends/retransmits from Server to clients must have correct Player field and value