Trilarion / imperialism-remake

Imperialism remake
https://remake.twelvepm.de/
GNU General Public License v3.0
54 stars 19 forks source link

Server - client communication, strategies for delayed or missing responses to requests #29

Open Trilarion opened 7 years ago

Trilarion commented 7 years ago

Something like at least once every 5s and disconnect if fail for third time. Maybe send special kind of message including a random number which just needs to be echoed in order to pass.

krs013 commented 7 years ago

Does the server initiate transactions regularly? If not, it may be more appropriate for the client to periodically send an I'm alive packet of some sort to the server, and if the server doesn't receive one after some timeout (say, 60 seconds), it can just drop the connection. I'm no expert, but I think that form is more normal for this use case.

Trilarion commented 7 years ago

Now that I thought more about this, I even wonder why I wanted to have this feature. The network connection kind of keeps itself alive by itself (the socket gets closed if either client or server somehow disappears). For all other requests you would have to set sensible timeouts anyway.

Example:

Client sends request X to server, what if server doesn't answer by amount of time Y? Case 1: Client doesn't need response to X anymore, just gives up. Case 2: Client tries again. Case 3: Client is in a "bad" state, informs user and/or closes connection to server.

The same holds true for the server. The potential strategies may vary for each request.

Currently there is no support for this, we currently expect to always receive a response (within a reasonable time). This is probably not enough.