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: