* Move networking scenes under `controllers/networking` * Move data bridge scene under `scenes/data` * Rename the bridge node to `data_bridge` * Update lobby UI scene path * Remove unused lobby RPC node/script
32 lines
779 B
GDScript
32 lines
779 B
GDScript
class_name GameServer extends ServerNetworking
|
|
|
|
|
|
func _ready() -> void:
|
|
setup_signals()
|
|
|
|
|
|
func setup_signals() -> void:
|
|
pass
|
|
|
|
func server_client_connected(id: int) -> void:
|
|
push_warning("Client Connected... ID: ", id)
|
|
|
|
if not Globals.game_data.client1:
|
|
Globals.game_data.client1 = id
|
|
elif not Globals.game_data.client2:
|
|
Globals.game_data.client2 = id
|
|
|
|
if Globals.game_data.client1 and Globals.game_data.client2:
|
|
Globals.multiplayer_data.init_match()
|
|
|
|
# TODO: Add watch match feature...
|
|
|
|
func server_client_disconnected(id: int) -> void:
|
|
push_warning("Client Disconnected... ID: ", id)
|
|
|
|
MessageBus.emit_propagation_clients_only.rpc("game_peer_disconnected", null)
|
|
|
|
await get_tree().create_timer(5.0).timeout
|
|
# NOTE: Quits game server instance.
|
|
get_tree().quit()
|