mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-13 05:02:09 +00:00
feat: classify matchmaking recovery failures
This commit is contained in:
@@ -140,8 +140,17 @@ func _on_request_completed(result: HTTPRequest.Result, response_code: int, _head
|
||||
return
|
||||
if response_code < 200 or response_code >= 300:
|
||||
var detail := String(parsed.get("error", "request rejected"))
|
||||
if operation == "ranked_profile":
|
||||
if response_code == HTTPClient.RESPONSE_UNAUTHORIZED:
|
||||
state.fail("Session expired; sign in again")
|
||||
ranked_profile.set_error("Session expired; sign in again")
|
||||
elif response_code == HTTPClient.RESPONSE_GONE and operation == "queue_recover":
|
||||
state.expire("Queue ticket expired")
|
||||
elif response_code == HTTPClient.RESPONSE_SERVICE_UNAVAILABLE:
|
||||
state.set_notice("Matchmaking is temporarily unavailable; retrying is safe")
|
||||
elif operation == "ranked_profile":
|
||||
ranked_profile.set_error(detail)
|
||||
elif response_code == HTTPClient.RESPONSE_NOT_FOUND and (operation == "queue_recover" or operation == "proposal_recover"):
|
||||
state.fail("Matchmaking record is no longer available")
|
||||
elif operation == "queue_create" or operation == "queue_recover" or operation == "proposal_recover":
|
||||
state.fail(detail)
|
||||
else:
|
||||
|
||||
@@ -140,6 +140,12 @@ func fail(reason: String) -> void:
|
||||
_emit_changed()
|
||||
|
||||
|
||||
func expire(reason: String = "Matchmaking expired") -> void:
|
||||
phase = EXPIRED
|
||||
message = reason
|
||||
_emit_changed()
|
||||
|
||||
|
||||
func set_notice(notice: String) -> void:
|
||||
message = notice
|
||||
_emit_changed()
|
||||
|
||||
@@ -66,6 +66,15 @@ func test_assignment_lifecycle_has_explicit_connecting_and_live_states() -> void
|
||||
assert_eq(state.phase, MatchmakingState.LIVE, "live match is visible")
|
||||
|
||||
|
||||
func test_expiry_is_distinct_from_generic_failure_and_remains_visible() -> void:
|
||||
var state := MatchmakingState.new()
|
||||
state.begin_queue("ticket-1", "casual")
|
||||
state.expire("Queue ticket expired")
|
||||
assert_eq(state.phase, MatchmakingState.EXPIRED, "expired ticket has a terminal expiry state")
|
||||
assert_eq(state.message, "Queue ticket expired", "expiry reason is visible")
|
||||
assert_true(not state.can_cancel(), "expired ticket cannot be cancelled")
|
||||
|
||||
|
||||
func test_restart_restore_requires_valid_identity_and_requests_authoritative_recovery() -> void:
|
||||
var state := MatchmakingState.new()
|
||||
assert_true(state.restore_snapshot({"phase": "QUEUED", "ticket_id": "ticket-1", "playlist": "casual", "revision": 2}), "valid active snapshot restores")
|
||||
|
||||
Reference in New Issue
Block a user