Skip to content

Disconnecting

Leaving on purpose

Done playing? Tell the server you are leaving with session.logout:

C: REQ <id> session.logout
S: RES <id> OK
  • <id>: your request ID. See Placeholders.
  • After the OK the server closes the connection. You don't have to close it yourself.
  • session.bye, session.leave and session.quit do the same as session.logout.
  • You can send it any time after your hello, also before you log in. Before your hello you get ERR HANDSHAKE_REQUIRED.

When the server closes the connection:

When you can't leave

You can't log out while you are in a match. A match starts with game.match_started and ends with your game.result. Placing your ships in Battleship counts as in a match.

C: REQ <id> session.logout
S: RES <id> ERR IN_MATCH {"reason": "<reason>", "matches": ["<m1>", "<m2>"]}
  • IN_MATCH doesn't disconnect you. You stay logged in.
  • matches lists the match IDs that keep you from leaving.
  • To leave anyway, send game.forfeit for each match in matches, then send session.logout again.
C: REQ <id1> <m1> game.forfeit
S: RES <id1> OK
S: EVT <m1> game.result {"result": "LOSS", "reason": "forfeit"}
C: REQ <id2> session.logout
S: RES <id2> OK
  • Each forfeit counts as a loss for you, the same as giving up.

Tournaments

While a tournament runs, you can't log out, also between two of your matches. The docs don't say yet how you know a tournament has ended.

Your lobby

  • Waiting in a lobby? Logging out takes you out of it. That is not a match, so you don't get IN_MATCH.
  • This also counts during the countdown.

What the other players see

Where They get
Your lobby lobby.update, without your name
A match you forfeited first game.result with "result": "WIN" and "reason": "forfeit"
  • In a match they see nothing about your logout, because you can't log out during a match.

Leaving or losing your connection?

You send session.logout Your connection drops
Session token stops working at once works until your waiting time runs out
Your name free at once yours until your waiting time runs out
Lobby place gone at once kept until your waiting time runs out
Matches you must end them first kept until your waiting time runs out
Come back? no. Log in again. yes, with session.reconnect
  • Close the connection without session.logout, and the server sees it as a drop. You get the waiting time.