From c10921b5d1fdad515ed0f413ff7cea58723cace0 Mon Sep 17 00:00:00 2001 From: Matt Loesby Date: Mon, 30 Oct 2023 19:37:47 -0600 Subject: [PATCH] Fix documentation in MultiplayerAPIExtension Fix documentation in MultiplayerAPIExtension.xml In implementing a MultiplayerAPIExtension, I found that the example from documentation did not function even in the Multiplayer tutorial example. Eventually, I found that the issue was that base_multiplayer will not poll unless told to by the LogMultiplayer implementation. I also corrected a spelling issue and a few out-of-date return types. --- doc/classes/MultiplayerAPIExtension.xml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/classes/MultiplayerAPIExtension.xml b/doc/classes/MultiplayerAPIExtension.xml index 4a2d397260f..7f6e7951b2a 100644 --- a/doc/classes/MultiplayerAPIExtension.xml +++ b/doc/classes/MultiplayerAPIExtension.xml @@ -15,7 +15,7 @@ var base_multiplayer = SceneMultiplayer.new() func _init(): - # Just passthourgh base signals (copied to var to avoid cyclic reference) + # Just passthrough base signals (copied to var to avoid cyclic reference) var cts = connected_to_server var cf = connection_failed var pc = peer_connected @@ -25,13 +25,16 @@ base_multiplayer.peer_connected.connect(func(id): pc.emit(id)) base_multiplayer.peer_disconnected.connect(func(id): pd.emit(id)) + func _poll(): + return base_multiplayer.poll() + # Log RPC being made and forward it to the default multiplayer. - func _rpc(peer: int, object: Object, method: StringName, args: Array) -> int: # Error + func _rpc(peer: int, object: Object, method: StringName, args: Array) -> Error: print("Got RPC for %d: %s::%s(%s)" % [peer, object, method, args]) return base_multiplayer.rpc(peer, object, method, args) # Log configuration add. E.g. root path (nullptr, NodePath), replication (Node, Spawner|Synchronizer), custom. - func _object_configuration_add(object, config: Variant) -> int: # Error + func _object_configuration_add(object, config: Variant) -> Error: if config is MultiplayerSynchronizer: print("Adding synchronization configuration for %s. Synchronizer: %s" % [object, config]) elif config is MultiplayerSpawner: @@ -39,7 +42,7 @@ return base_multiplayer.object_configuration_add(object, config) # Log configuration remove. E.g. root path (nullptr, NodePath), replication (Node, Spawner|Synchronizer), custom. - func _object_configuration_remove(object, config: Variant) -> int: # Error + func _object_configuration_remove(object, config: Variant) -> Error: if config is MultiplayerSynchronizer: print("Removing synchronization configuration for %s. Synchronizer: %s" % [object, config]) elif config is MultiplayerSpawner: