Fix game state push type and reconnect flow in Game.gd
- Server pushes "game.state_update" not "game.state_update.push" - On "AlreadyStarted" ack (reconnect), explicitly fetch state via game.get_state instead of expecting state in the ready ack (it's never there) 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:
@@ -124,6 +124,18 @@ func board_height() -> int:
|
||||
|
||||
func send_ready() -> void:
|
||||
Network.request("game.ready",
|
||||
{ "sessionId": session_id },
|
||||
func(_t: String, p: Variant) -> void:
|
||||
var d := p as Dictionary
|
||||
if d.get("status", "") == "AlreadyStarted":
|
||||
_fetch_state()
|
||||
else:
|
||||
_apply_state_from_payload(p),
|
||||
func(_c: String, _m: String) -> void: pass)
|
||||
|
||||
|
||||
func _fetch_state() -> void:
|
||||
Network.request("game.get_state",
|
||||
{ "sessionId": session_id },
|
||||
func(_t: String, p: Variant) -> void: _apply_state_from_payload(p),
|
||||
func(_c: String, _m: String) -> void: pass)
|
||||
@@ -231,7 +243,7 @@ func _on_server_push(type: String, payload: Variant) -> void:
|
||||
opponent_name = oname
|
||||
match_found.emit(sid, oname, orank)
|
||||
|
||||
"game.state_update.push":
|
||||
"game.state_update":
|
||||
var d := payload as Dictionary
|
||||
var s := d.get("state", {}) as Dictionary
|
||||
if not s.is_empty():
|
||||
|
||||
Reference in New Issue
Block a user