refactor: reorganize networking and data bridge scenes
* 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
This commit is contained in:
42
controllers/networking/game_client.gd
Normal file
42
controllers/networking/game_client.gd
Normal file
@@ -0,0 +1,42 @@
|
||||
class_name GameClient extends ClientNetworking
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
setup_signals()
|
||||
|
||||
|
||||
func setup_signals() -> void:
|
||||
MessageBus.subscribe("game_start_client", _start_client)
|
||||
|
||||
MessageBus.subscribe("game_wait_for_connection", _wait_for_connection)
|
||||
MessageBus.subscribe("game_close_connection", _wait_close_connection)
|
||||
MessageBus.subscribe("game_peer_disconnected", _on_game_peer_disconnected)
|
||||
|
||||
func _start_client(address: String = "127.0.0.1", port: int = 8080) -> void:
|
||||
if peer: return
|
||||
start_client(address, port)
|
||||
|
||||
func _on_game_peer_disconnected() -> void:
|
||||
close_connection()
|
||||
|
||||
Globals.multiplayer_data.reset()
|
||||
Globals.lobby_data.go_back_to_match_screen()
|
||||
MessageBus.clear_voided_listeners()
|
||||
|
||||
func client_connected_to_server() -> void:
|
||||
push_warning("Connected to server!")
|
||||
|
||||
func close_connection() -> void:
|
||||
if not peer: return
|
||||
|
||||
push_warning("Disconnected from, server...")
|
||||
|
||||
unset_client()
|
||||
|
||||
func client_disconnected_from_server() -> void:
|
||||
push_warning("Disconnected from, server...")
|
||||
|
||||
func client_connection_failed_to_server() -> void:
|
||||
push_warning("Connection failed!")
|
||||
|
||||
unset_client()
|
||||
Reference in New Issue
Block a user