client: force WebSocket reconnect on logout so auth arrives on a fresh connection

logout() now calls Network.force_reconnect() to tear down the existing Phase-5
connection; the next auth.login / auth.register is then the very first message
on the new connection, which is the only point where ConnectionLoop handles auth.

Also adds Network.force_reconnect() public method.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-01 22:55:45 -05:00
co-authored by Claude Happy
parent ad611ee4ca
commit 2508fe1297
2 changed files with 12 additions and 0 deletions
+1
View File
@@ -86,6 +86,7 @@ func logout() -> void:
session_token = ""
needs_starter_deck = false
_save_session()
Network.force_reconnect()
# ── Private ───────────────────────────────────────────────────────────────────
+11
View File
@@ -136,6 +136,17 @@ func send(type: String, payload: Variant = {}) -> void:
func is_online() -> bool:
return _state == _State.CONNECTED
## Force-close the current connection and schedule a reconnect.
## Call on logout so the next auth.login / auth.register arrives on a fresh
## connection — the server only accepts those as the very first message.
func force_reconnect() -> void:
if _ws != null and _ws.get_ready_state() in \
[WebSocketPeer.STATE_OPEN, WebSocketPeer.STATE_CONNECTING]:
_ws.close(1000, "client_logout")
# STATE_CLOSED is detected on the next _process() poll,
# which calls _on_ws_closed() → _schedule_reconnect() automatically.
# ── Connection helpers ────────────────────────────────────────────────────────
func _connect_now() -> void: