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:
2026-08-09 18:36:28 -05:00
parent 5ab970aec5
commit 1eb057fefd
8 changed files with 76 additions and 64 deletions

View File

@@ -11,46 +11,49 @@ func subscribe(id: String, callback: Callable) -> void:
message_types.get(id).append(callback)
func emit(id: String, data: Variant) -> void:
emit_propagation(id, data)
func emit_local(id: String, data: Variant, expand: bool = false) -> void:
emit_propagation(id, data, expand)
# TODO: Need to actually validate client request. Also, message bus is more
# about server talking to clients than clients to server. I.E, reducing
# the number of needed @rpc method decorator bindings.
# the number of needed @rpc method decorator bindings.
@rpc("any_peer", "call_remote", "reliable")
func emit_request(id: String, data: Variant, expand: bool = false) -> void:
if not multiplayer.is_server(): return
var listeners: Array = message_types.get(id)
if not listeners:
push_error("'%s' not an existing message type to send...", [id])
if not message_types.has(id):
push_error("'%s' not an existing message type to handle...", [id])
return
emit_propagation(id, data, expand)
@rpc("authority", "call_local", "reliable")
func emit_propagation(id: String, data: Variant, expand: bool = false) -> void:
var listeners: Array = message_types.get(id)
if not listeners:
push_error("'%s' not an existing message type to send...", [id])
if not message_types.has(id):
push_error("'%s' not an existing message type to handle...", [id])
return
for callback: Callable in listeners:
for callback: Callable in message_types.get(id):
if data == null:
callback.call()
continue
if not expand:
callback.call(data)
else:
callback.callv(data)
@rpc("authority", "call_remote", "reliable")
func emit_propagation_clients_only(id: String, data: Variant, expand: bool = false) -> void:
var listeners: Array = message_types.get(id)
if not listeners:
push_error("'%s' not an existing message type to send...", [id])
if not message_types.has(id):
push_error("'%s' not an existing message type to handle...", [id])
return
for callback: Callable in listeners:
for callback: Callable in message_types.get(id):
if data == null:
callback.call()
continue
if not expand:
callback.call(data)
else: