diff --git a/Client/origin-client/autoloads/Network.gd b/Client/origin-client/autoloads/Network.gd index b736f3c..efd133f 100644 --- a/Client/origin-client/autoloads/Network.gd +++ b/Client/origin-client/autoloads/Network.gd @@ -169,11 +169,27 @@ func _on_ws_closed() -> void: if debug_log_packets: print("[Net] Closed code=%d reason=%s" % [code, reason]) + # Map server-encoded close reasons to error codes so callers (e.g. Auth.gd) + # can take the right action. Godot discards buffered data packets when the + # close frame arrives, so the reason field is the only signal we have. + var error_code: String + var error_msg: String + match reason: + "auth_failed": + error_code = "AUTH_FAILED" + error_msg = "Session expired or revoked." + "auth_required": + error_code = "AUTH_REQUIRED" + error_msg = "Authentication required." + _: + error_code = "DISCONNECTED" + error_msg = "Connection lost." + # Fail all pending requests immediately. for seq in _pending.keys(): var cb: Dictionary = _pending[seq] if cb[&"on_error"].is_valid(): - cb[&"on_error"].call("DISCONNECTED", "Connection lost.") + cb[&"on_error"].call(error_code, error_msg) _pending.clear() _ping_seq = -1 _ping_sent_at = -1.0