-
Notifications
You must be signed in to change notification settings - Fork 61
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]}
-
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 befunction
. - However
chuncks
shouldn't be misspelled. But instead ofchunks
I'd call itargs
orarguments
, because that's what it is; the arguments for the function to be called. - All
action
s are CamelCase, exceptconnectedToHost
andpong
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
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 ittype
,message_type
,class
or similar. -
game_time
is python's representation time since epoch. It's microseconds/1000000. I'd prefer just having milliseconds, which would be platform-independent. -
session
contains the session ID. I'd call itsession_id
then. 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_info
message, there's anoptions
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 fileoptions.lua
. - 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. - After each message sent to the server, the server
ACK
s 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.