Files
code_of_conquest_dnd/client/scripts/net/dm_response.gd

26 lines
770 B
GDScript

class_name DmResponse
extends RefCounted
## The raw outcome of one HTTP attempt, independent of any game meaning.
## `status` is 0 when the transport never reached the server; `body` is the
## parsed JSON dict, or null when the body was absent or not JSON.
var status: int
var body # Variant: parsed JSON (Dictionary) or null
var transport_ok: bool
var error: String
func _init(p_status := 0, p_body = null, p_transport_ok := false, p_error := "") -> void:
status = p_status
body = p_body
transport_ok = p_transport_ok
error = p_error
static func ok(p_status: int, p_body) -> DmResponse:
return DmResponse.new(p_status, p_body, true, "")
static func failed(p_error: String) -> DmResponse:
return DmResponse.new(0, null, false, p_error)