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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user