-
-
Notifications
You must be signed in to change notification settings - Fork 73
Server protocol discussion
My (Downlord's) thoughts about the current server protocol (not complete)
The relay protocol is used to exchange data between the FAF server and FA the game before and after the game, using the client as intermediary.
A message looks like this (off the top of my head): {"action": "JoinGame", "chuncks": ["1.1.1.1:6112", "Downlord", 1234]}
-
actiondenotes a lua function to be called IIRC. Beside being a potential security risk on the client side, I'm fine with the naming and content. An alternative name would befunction. - However
chuncksshouldn't be misspelled. But instead ofchunksI'd call itargsorarguments, because that's what it is; the arguments for the function to be called. - All
actions are CamelCase, exceptconnectedToHostandpong
The lobby protocol is used to exchange data between the FAF server and the FAF client.
A message looks like this (real example):
{"featured_mod_versions": {"1": 3644, "2": 3640, "3": 3634, "4": 1, "5": 1, "6": 1, "8": 1, "9": 1, "11": 3644, "12": 3644, "13": 3644, "14": 3644, "15": 3644, "17": 3644, "18": 3644, "19": 3644, "20": 3644, "21": 3644, "22": 3644}, "mapname": "scmp_020", "num_players": 4, "game_time": 1438724146.315859, "uid": 3721953, "title": "DOJOLEPOSAPPHIRE", "sim_mods": [], "game_type": 1, "host": "Shyur", "teams": {"1": ["sapph", "m4NTl5"], "2": ["Renatusmc"], "6": ["Shyur"]}, "access": "password", "state": "open", "command": "game_info", "featured_mod": "faf", "max_players": 6, "options": []}
- I understand
commandas "what to do". However,commandactually denotes the type of the message;game_info,player_info,mod_infoand so on. Therefore I'd call ittype,message_type,classor similar. -
game_timeis python's representation time since epoch. It's microseconds/1000000. I'd prefer just having milliseconds, which would be platform-independent. -
sessioncontains the session ID. I'd call itsession_idthen. It seems to always be a number, however it's serialized as a string. - After login, the user receives his e-mail address in
email. No idea why. - In a
game_infomessage, there's anoptionswith an array of booleans; I haven't yet figured out what that does. I heard it's deprecated? The client seems to write it to a fileoptions.lua. - The
socialcommand either contains a list of friends or foes or a list of IRC channels to join. That way the client needs to figure out which fields are set in order to decide what needs to be done. I'd rather have three different messages. - After each message sent to the server, the server
ACKs the number of bytes received. As a string. Using TCP, I don't see any benefit in doing this. - The server sends info- and error-messages as HTML string to be displayed in the client. That's really not something you wanna do.