Refactor message bus and lobby networking flow
* Add local message bus emission with optional argument expansion * Improve message type validation and callback dispatch * Simplify lobby match join/disconnect handling * Move lobby server networking toward an overridable `ServerNetworking` base class * Update lobby scene to use the dedicated lobby server script * Remove obsolete window configuration and unused RPC stubs
This commit is contained in:
@@ -81,6 +81,14 @@ func match_list_remove_entry(match_id: String) -> void:
|
||||
_delete_from_match_pool(match_id)
|
||||
|
||||
func match_list_join_entry(match_id: String) -> void:
|
||||
if active_match_pool.has(match_id):
|
||||
push_error("Client Joining Match List Entry Failed. Already consumed. ", match_id)
|
||||
|
||||
# TODO: Need to signal to prospective client that match has been taken.
|
||||
# Server is in the midst of cleanup for it once clients disconnect
|
||||
# to join generated game server...
|
||||
return
|
||||
|
||||
var match_entry = match_pool.get(match_id)
|
||||
if not match_entry: return
|
||||
|
||||
@@ -100,22 +108,14 @@ func match_list_join_entry(match_id: String) -> void:
|
||||
client2.partner_id = client1.id
|
||||
|
||||
active_match_pool[match_id] = match_entry
|
||||
# NOTE: Cleanup of match info and client info
|
||||
# will/should happen on their disconnect...
|
||||
|
||||
client_pool.erase(client1.id)
|
||||
client_pool.erase(client2.id)
|
||||
|
||||
# TODO: Need to look into moving this out of here.
|
||||
# Maybe just have clients drop and internally call on their own?
|
||||
# Maybe just check here if we can even launch the game server?
|
||||
_launch_game_server(match_entry, client1, client2)
|
||||
|
||||
# NOTE: Needed for hash check to pass between client and server but isn't used by server...
|
||||
@rpc("authority", "reliable")
|
||||
func connect_to_game() -> void:
|
||||
pass
|
||||
|
||||
@rpc("authority", "reliable")
|
||||
func go_back_to_match_screen() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func server_client_connected(id: int) -> void:
|
||||
push_warning("Client Connected... ID: ", id)
|
||||
|
||||
@@ -134,32 +134,29 @@ func server_client_disconnected(id: int) -> void:
|
||||
push_warning("Client Disconnected... ID: ", id)
|
||||
|
||||
var client1 = client_pool.get(id)
|
||||
if not client1: return
|
||||
if not client1: return
|
||||
|
||||
var client2 = client_pool.get( client1.partner_id )
|
||||
var match_entry = _delete_from_match_pool(client1.match_id)
|
||||
if not match_entry: return
|
||||
|
||||
if not client1.match_id.is_empty() and not match_entry.is_empty():
|
||||
MessageBus.emit_propagation(
|
||||
"match_list_remove_entry", match_entry.match_id
|
||||
)
|
||||
push_warning("Removing Match... Match: ", match_entry)
|
||||
|
||||
for client in client_pool.values():
|
||||
if client.in_match: continue
|
||||
if client.id == id: continue
|
||||
MessageBus.emit_local(
|
||||
"match_list_remove_entry", match_entry.match_id
|
||||
)
|
||||
|
||||
MessageBus.emit_propagation_clients_only.rpc_id(
|
||||
client.id, "match_list_remove_entry", match_entry.match_id
|
||||
)
|
||||
|
||||
match_pool.erase(client1.match_id)
|
||||
MessageBus.emit_propagation_clients_only.rpc(
|
||||
"match_list_remove_entry", match_entry.match_id
|
||||
)
|
||||
|
||||
client_pool.erase(client1.id)
|
||||
if not client2: return
|
||||
|
||||
if active_match_pool.get(client2.match_id):
|
||||
match_pool.erase(client2.match_id)
|
||||
|
||||
var _id = client2.id
|
||||
client2 = CLIENT_DICT.duplicate_deep()
|
||||
client2.id = _id
|
||||
# NOTE: Needed for hash check to pass between client and server but isn't used by server...
|
||||
@rpc("authority", "reliable")
|
||||
func connect_to_game() -> void:
|
||||
pass
|
||||
|
||||
@rpc("authority", "reliable")
|
||||
func go_back_to_match_screen() -> void:
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user