Skip to content

Commit

Permalink
Update NetworkedMultiplayerCustom.xml with more explicit documentatio…
Browse files Browse the repository at this point in the history
…n to guide usage

Some suggestions based on the new `NetworkedMultiplayerCustom` class introduced in godotengine#63163.

@dsnopek I've made some suggestions to the docs based on what would have helped me through my first time. This in conjunction with godotengine#63628 and your new additions in godotengine#63637 should help new users understand what's going on without having to dig through the source code.

I'd also like some help improving the `deliver_packet` method docs since I haven't gotten around to really digging through how that gets propagated. I assume the `from_peer_id` is meant to be the unique network id the sender of that packet was initialized with? And am I correct in assuming the `target_id`/`target_peer` is what it uses to deliver it the right place locally? I think some further documentation here would be helpful to know how to use `set_target_peer` in conjunction with this.
  • Loading branch information
jarommadsen authored Jul 29, 2022
1 parent 97d7c7c commit 9053e8d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions doc/classes/NetworkedMultiplayerCustom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
<argument index="0" name="connection_status" type="int" enum="NetworkedMultiplayerPeer.ConnectionStatus" />
<description>
Set the state of the connection. See [enum NetworkedMultiplayerPeer.ConnectionStatus].
This will emit the [signal NetworkedMultiplayerPeer.connection_succeeded], [signal NetworkedMultiplayerPeer.connection_failed] or [signal NetworkedMultiplayerPeer.server_disconnected] signals depending on the status and if the peer has the unique network id of [code]1[/code].
This will emit the [signal NetworkedMultiplayerPeer.connection_succeeded] signal when set to [code]CONNECTION_CONNECTED[/code].
You can only change to [code]CONNECTION_CONNECTING[/code] from [code]CONNECTION_DISCONNECTED[/code] and to [code]CONNECTION_CONNECTED[/code] from [code]CONNECTION_CONNECTING[/code].
Setting this to [code]CONNECTION_DISCONNECTED[/code] will emit the [signal NetworkedMultiplayerPeer.connection_failed] if it was previously set to [code]CONNECTION_CONNECTING[/code] or [signal NetworkedMultiplayerPeer.server_disconnected] if previously [code]CONNECTION_CONNECTED[/code]. Note that this is only true if the peer is not in server mode (has the unique network id of [code]1[/code]), otherwise the connection status will be set to [code]CONNECTION_DISCONNECTED[/code] without emitting any signals.
</description>
</method>
<method name="set_max_packet_size">
Expand All @@ -49,8 +50,9 @@
<argument index="1" name="buffer" type="PoolByteArray" />
<argument index="2" name="transfer_mode" type="int" />
<description>
Emitted when the local [MultiplayerAPI] generates a packet.
Emitted when the local [MultiplayerAPI] generates a packet (e.g. when calling [method Node.rpc]).
Your script should take this packet and send it to the requested peer over the network (which should call [method deliver_packet] with the data when it's received).
The [code]peer_id[/code] is the [code]target_peer[/code] set by [method NetworkedMultiplayerPeer.set_target_peer].
</description>
</signal>
</signals>
Expand Down

0 comments on commit 9053e8d

Please sign in to comment.