[MP] Let MultiplayerAPI handle packet relaying and peer signaling.

MultiplayerPeer changes:

- Adds is_server_relay_supported virtual method

Informs the upper MultiplayerAPI layer if it can signal peers connected
to the server to other clients, and perform packet relaying among them.

- Adds get_packet_channel and get_packet_mode virtual methods

Allows the MultiplayerAPI to retrieve the channel and transfer modes to
use when relaying the last received packet.

SceneMultiplayerPeer changes:

- Implement peer signaling and packet relaying when the MultiplayerPeer
  advertise they are supported.

ENet, WebRTC, WebSocket changes:

- Removed custom code for relaying from WebSocket and ENet, and let it
  be handled by the upper layer.
- Update WebRTC to split create_client, create_server, and create_mesh,
  with the latter behaving like the old initialize with
  "server_compatibility = false", and the first two supporting the upper
  layer relaying protocol.
This commit is contained in:
Fabio Alessandrelli
2022-10-08 20:50:19 +02:00
parent 03e5de37ae
commit 7536d15fe3
17 changed files with 465 additions and 446 deletions

View File

@ -25,10 +25,22 @@
Returns the current state of the connection. See [enum ConnectionStatus].
</description>
</method>
<method name="get_packet_channel" qualifiers="const">
<return type="int" />
<description>
Returns the channel over which the next available packet was received. See [method PacketPeer.get_available_packet_count].
</description>
</method>
<method name="get_packet_mode" qualifiers="const">
<return type="int" enum="MultiplayerPeer.TransferMode" />
<description>
Returns the [enum MultiplayerPeer.TransferMode] the remote peer used to send the next available packet. See [method PacketPeer.get_available_packet_count].
</description>
</method>
<method name="get_packet_peer" qualifiers="const">
<return type="int" />
<description>
Returns the ID of the [MultiplayerPeer] who sent the most recent packet.
Returns the ID of the [MultiplayerPeer] who sent the next available packet. See [method PacketPeer.get_available_packet_count].
</description>
</method>
<method name="get_unique_id" qualifiers="const">
@ -37,6 +49,12 @@
Returns the ID of this [MultiplayerPeer].
</description>
</method>
<method name="is_server_relay_supported" qualifiers="const">
<return type="bool" />
<description>
Returns true if the server can act as a relay in the current configuration (i.e. if the higher level [MultiplayerAPI] should notify connected clients of other peers, and implement a relay protocol to allow communication between them).
</description>
</method>
<method name="poll">
<return type="void" />
<description>