From 2508fe1297461cf2d8de95d6184a27660a7eff1c Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 1 Mar 2026 22:55:07 -0500 Subject: [PATCH] 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 Co-Authored-By: Happy --- Client/origin-client/autoloads/Auth.gd | 1 + Client/origin-client/autoloads/Network.gd | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Client/origin-client/autoloads/Auth.gd b/Client/origin-client/autoloads/Auth.gd index cb27fba..f3b6e26 100644 --- a/Client/origin-client/autoloads/Auth.gd +++ b/Client/origin-client/autoloads/Auth.gd @@ -86,6 +86,7 @@ func logout() -> void: session_token = "" needs_starter_deck = false _save_session() + Network.force_reconnect() # ── Private ─────────────────────────────────────────────────────────────────── diff --git a/Client/origin-client/autoloads/Network.gd b/Client/origin-client/autoloads/Network.gd index efd133f..732576a 100644 --- a/Client/origin-client/autoloads/Network.gd +++ b/Client/origin-client/autoloads/Network.gd @@ -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: