mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-11 00:14:00 +00:00
fix: handle matchmaking session expiry
This commit is contained in:
@@ -6,12 +6,14 @@ extends Node
|
||||
|
||||
signal request_succeeded(operation: String, payload: Dictionary)
|
||||
signal request_failed(operation: String, http_code: int, detail: String)
|
||||
signal session_expired()
|
||||
|
||||
const DEFAULT_BASE_URL := "http://127.0.0.1:8080"
|
||||
const PERSIST_PATH := "user://matchmaking_state.cfg"
|
||||
|
||||
var base_url := DEFAULT_BASE_URL
|
||||
var access_token := ""
|
||||
var auth_expired := false
|
||||
var state: MatchmakingState
|
||||
var ranked_profile: RankedProfileState
|
||||
|
||||
@@ -38,6 +40,7 @@ func configure(url: String, token: String) -> bool:
|
||||
return false
|
||||
base_url = normalized
|
||||
access_token = normalized_token
|
||||
auth_expired = false
|
||||
return true
|
||||
|
||||
|
||||
@@ -161,8 +164,11 @@ func _on_request_completed(result: HTTPRequest.Result, response_code: int, _head
|
||||
if response_code < 200 or response_code >= 300:
|
||||
var detail := String(parsed.get("error", "request rejected"))
|
||||
if response_code == HTTPClient.RESPONSE_UNAUTHORIZED:
|
||||
access_token = ""
|
||||
auth_expired = true
|
||||
state.fail("Session expired; sign in again")
|
||||
ranked_profile.set_error("Session expired; sign in again")
|
||||
session_expired.emit()
|
||||
elif response_code == HTTPClient.RESPONSE_GONE and operation == "queue_recover":
|
||||
state.expire("Queue ticket expired")
|
||||
elif response_code == HTTPClient.RESPONSE_SERVICE_UNAVAILABLE:
|
||||
|
||||
Reference in New Issue
Block a user