mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-10 16:04:04 +00:00
test(multiplayer): verify two-player proposal round trip
This commit is contained in:
@@ -32,6 +32,7 @@ var _websocket_status := "DISCONNECTED"
|
||||
var _websocket_retry_seconds := 0.0
|
||||
var _websocket_backoff := 1.0
|
||||
var _pending_assignment_match_id := ""
|
||||
var _pending_resync_resource_id := ""
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -356,6 +357,8 @@ func _on_request_completed(result: HTTPRequest.Result, response_code: int, _head
|
||||
request_failed.emit(operation, response_code, assignment.error_message)
|
||||
return
|
||||
request_succeeded.emit(operation, payload)
|
||||
if not _pending_resync_resource_id.is_empty():
|
||||
call_deferred("_run_pending_resync")
|
||||
|
||||
|
||||
func _handle_websocket_packet(packet: PackedByteArray) -> void:
|
||||
@@ -405,6 +408,21 @@ static func _valid_websocket_event(event: Dictionary) -> bool:
|
||||
|
||||
|
||||
func _on_resync_required(resource_id: String) -> void:
|
||||
if not _operation.is_empty():
|
||||
_pending_resync_resource_id = resource_id
|
||||
return
|
||||
_run_resync(resource_id)
|
||||
|
||||
|
||||
func _run_pending_resync() -> void:
|
||||
if not _operation.is_empty() or _pending_resync_resource_id.is_empty():
|
||||
return
|
||||
var resource_id := _pending_resync_resource_id
|
||||
_pending_resync_resource_id = ""
|
||||
_run_resync(resource_id)
|
||||
|
||||
|
||||
func _run_resync(resource_id: String) -> void:
|
||||
if resource_id == state.ticket_id and not state.ticket_id.is_empty():
|
||||
recover_queue(state.ticket_id)
|
||||
elif resource_id == state.proposal_id and not state.proposal_id.is_empty():
|
||||
|
||||
Reference in New Issue
Block a user