feat: update

This commit is contained in:
2026-06-11 18:28:25 +08:00
parent 8520f9db3c
commit 8a2fb36a98
65 changed files with 4407 additions and 572 deletions
@@ -130,11 +130,31 @@ class AsyncRequest:
else:
return type.create(ns, data.get(result_key))
func _resume_conn(p_err : int):
func _socket_exception_from_error(p_error) -> NakamaException:
if p_error is NakamaException:
return p_error
if typeof(p_error) == TYPE_INT:
var message := "Socket connection failed"
match p_error:
ERR_TIMEOUT:
message = "Socket connection timed out"
ERR_CANT_CONNECT:
message = "Socket connection refused or closed"
ERR_CANT_RESOLVE:
message = "Socket host could not be resolved"
ERR_CONNECTION_ERROR:
message = "Socket connection error"
ERR_UNAVAILABLE:
message = "Socket connection unavailable"
return NakamaException.new(message, p_error)
return NakamaException.new(str(p_error), -1)
func _resume_conn(p_error = OK):
if _conn:
if p_err: # Exception
logger.warning("Connection error: %d" % p_err)
_conn.resume(NakamaAsyncResult.new(NakamaException.new()))
if p_error != OK:
var exception := _socket_exception_from_error(p_error)
logger.warning("Connection error: %s" % exception.message)
_conn.resume(NakamaAsyncResult.new(exception))
else:
logger.info("Connected!")
_conn.resume(NakamaAsyncResult.new())