refactor: decouple game networking from lobby client
* Replace direct client/server networking references with GameClient/GameServer scenes * Refactor message bus to support local emission and argument expansion * Move lobby connection lifecycle handling to message bus events * Remove multiplayer connection wait helpers and direct lobby client coupling * Rename Server to ServerNetworking and update lobby client references * Update scene resources and export configuration
This commit is contained in:
@@ -11,8 +11,8 @@ 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
|
||||
@@ -21,22 +21,23 @@ func emit(id: String, data: Variant) -> void:
|
||||
@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:
|
||||
@@ -44,12 +45,15 @@ func emit_propagation(id: String, data: Variant, expand: bool = false) -> void:
|
||||
|
||||
@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:
|
||||
|
||||
Reference in New Issue
Block a user