Skip to content

Server protocol discussion

Michel Jung edited this page Sep 10, 2016 · 2 revisions

My (Downlord's) thoughts about the current server protocol (not complete)

Relay protocol

Summary

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]}

Thoughts

  1. action denotes 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 be function.
  2. However chuncks shouldn't be misspelled. But instead of chunks I'd call it args or arguments, because that's what it is; the arguments for the function to be called.
  3. All actions are CamelCase, except connectedToHost and pong

Lobby protocol

Summary

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": []}

Thoughts

  1. I understand command as "what to do". However, command actually denotes the type of the message; game_info, player_info, mod_info and so on. Therefore I'd call it type, message_type, class or similar.
  2. game_time is python's representation time since epoch. It's microseconds/1000000. I'd prefer just having milliseconds, which would be platform-independent.
  3. session contains the session ID. I'd call it session_id then. It seems to always be a number, however it's serialized as a string.
  4. After login, the user receives his e-mail address in email. No idea why.
  5. In a game_info message, there's an options with 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 file options.lua.
  6. The social command 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.
  7. 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.
  8. The server sends info- and error-messages as HTML string to be displayed in the client. That's really not something you wanna do.