Disconnecting¶
Leaving on purpose¶
Done playing? Tell the server you are leaving with session.logout:
<id>: your request ID. See Placeholders.- After the
OKthe server closes the connection. You don't have to close it yourself. session.bye,session.leaveandsession.quitdo the same assession.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:
- Your session token stops working. A later
session.reconnectgetsERR SESSION_EXPIRED. - Your name is free again. Someone else can log in with it.
- You get no waiting time. To play again, connect and log in again.
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_MATCHdoesn't disconnect you. You stay logged in.matcheslists the match IDs that keep you from leaving.- To leave anyway, send
game.forfeitfor each match inmatches, then sendsession.logoutagain.
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.