Minor Update
- Refactor the Player.gd - Attempt to fix joining the available room, via Room ID
This commit is contained in:
@@ -33,12 +33,17 @@ func _process(_delta):
|
||||
if socket:
|
||||
pass
|
||||
|
||||
func connect_to_nakama_async(email: String = "", password: String = "") -> void:
|
||||
func connect_to_nakama_async(email: String = "", password: String = "") -> bool:
|
||||
if is_connected_to_nakama():
|
||||
print("Already connected to Nakama.")
|
||||
emit_signal("connected_to_nakama")
|
||||
return true
|
||||
|
||||
# 1. Authenticate
|
||||
if email == "":
|
||||
var device_id = OS.get_unique_id()
|
||||
# For testing, append a random number to device ID to simulate unique users on one machine
|
||||
# device_id = device_id + str(randi())
|
||||
device_id = device_id + str(randi())
|
||||
session = await client.authenticate_device_async(device_id)
|
||||
else:
|
||||
session = await client.authenticate_email_async(email, password)
|
||||
@@ -46,7 +51,7 @@ func connect_to_nakama_async(email: String = "", password: String = "") -> void:
|
||||
if session.is_exception():
|
||||
printerr("Auth Error: ", session.get_exception().message)
|
||||
emit_signal("connection_failed", session.get_exception().message)
|
||||
return
|
||||
return false
|
||||
|
||||
# 2. Connect Socket
|
||||
socket = Nakama.create_socket_from(client)
|
||||
@@ -55,7 +60,7 @@ func connect_to_nakama_async(email: String = "", password: String = "") -> void:
|
||||
if socket_result.is_exception():
|
||||
printerr("Socket Error: ", socket_result.get_exception().message)
|
||||
emit_signal("connection_failed", socket_result.get_exception().message)
|
||||
return
|
||||
return false
|
||||
|
||||
# 3. Initialize Multiplayer Bridge
|
||||
# This links Nakama's socket to Godot's High-Level Multiplayer API
|
||||
@@ -71,6 +76,7 @@ func connect_to_nakama_async(email: String = "", password: String = "") -> void:
|
||||
|
||||
print("Connected to Nakama and Bridge Initialized.")
|
||||
emit_signal("connected_to_nakama")
|
||||
return true
|
||||
|
||||
# --- Match Management ---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user