Removes _networking_ prefix from some methods and members, now that multiplayer has been largely moved out of Node and SceneTree and is seperated into its own set of classes.
76 lines
5.2 KiB
XML
76 lines
5.2 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="WebRTCMultiplayerPeer" inherits="MultiplayerPeer" version="4.0">
|
|
<brief_description>
|
|
A simple interface to create a peer-to-peer mesh network composed of [WebRTCPeerConnection] that is compatible with the [MultiplayerAPI].
|
|
</brief_description>
|
|
<description>
|
|
This class constructs a full mesh of [WebRTCPeerConnection] (one connection for each peer) that can be used as a [member MultiplayerAPI.multiplayer_peer].
|
|
You can add each [WebRTCPeerConnection] via [method add_peer] or remove them via [method remove_peer]. Peers must be added in [constant WebRTCPeerConnection.STATE_NEW] state to allow it to create the appropriate channels. This class will not create offers nor set descriptions, it will only poll them, and notify connections and disconnections.
|
|
[signal MultiplayerPeer.connection_succeeded] and [signal MultiplayerPeer.server_disconnected] will not be emitted unless [code]server_compatibility[/code] is [code]true[/code] in [method initialize]. Beside that data transfer works like in a [MultiplayerPeer].
|
|
</description>
|
|
<tutorials>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="add_peer">
|
|
<return type="int" enum="Error" />
|
|
<argument index="0" name="peer" type="WebRTCPeerConnection" />
|
|
<argument index="1" name="peer_id" type="int" />
|
|
<argument index="2" name="unreliable_lifetime" type="int" default="1" />
|
|
<description>
|
|
Add a new peer to the mesh with the given [code]peer_id[/code]. The [WebRTCPeerConnection] must be in state [constant WebRTCPeerConnection.STATE_NEW].
|
|
Three channels will be created for reliable, unreliable, and ordered transport. The value of [code]unreliable_lifetime[/code] will be passed to the [code]maxPacketLifetime[/code] option when creating unreliable and ordered channels (see [method WebRTCPeerConnection.create_data_channel]).
|
|
</description>
|
|
</method>
|
|
<method name="close">
|
|
<return type="void" />
|
|
<description>
|
|
Close all the add peer connections and channels, freeing all resources.
|
|
</description>
|
|
</method>
|
|
<method name="get_peer">
|
|
<return type="Dictionary" />
|
|
<argument index="0" name="peer_id" type="int" />
|
|
<description>
|
|
Return a dictionary representation of the peer with given [code]peer_id[/code] with three keys. [code]connection[/code] containing the [WebRTCPeerConnection] to this peer, [code]channels[/code] an array of three [WebRTCDataChannel], and [code]connected[/code] a boolean representing if the peer connection is currently connected (all three channels are open).
|
|
</description>
|
|
</method>
|
|
<method name="get_peers">
|
|
<return type="Dictionary" />
|
|
<description>
|
|
Returns a dictionary which keys are the peer ids and values the peer representation as in [method get_peer].
|
|
</description>
|
|
</method>
|
|
<method name="has_peer">
|
|
<return type="bool" />
|
|
<argument index="0" name="peer_id" type="int" />
|
|
<description>
|
|
Returns [code]true[/code] if the given [code]peer_id[/code] is in the peers map (it might not be connected though).
|
|
</description>
|
|
</method>
|
|
<method name="initialize">
|
|
<return type="int" enum="Error" />
|
|
<argument index="0" name="peer_id" type="int" />
|
|
<argument index="1" name="server_compatibility" type="bool" default="false" />
|
|
<argument index="2" name="channels_config" type="Array" default="[]" />
|
|
<description>
|
|
Initialize the multiplayer peer with the given [code]peer_id[/code] (must be between 1 and 2147483647).
|
|
If [code]server_compatibilty[/code] is [code]false[/code] (default), the multiplayer peer will be immediately in state [constant MultiplayerPeer.CONNECTION_CONNECTED] and [signal MultiplayerPeer.connection_succeeded] will not be emitted.
|
|
If [code]server_compatibilty[/code] is [code]true[/code] the peer will suppress all [signal MultiplayerPeer.peer_connected] signals until a peer with id [constant MultiplayerPeer.TARGET_PEER_SERVER] connects and then emit [signal MultiplayerPeer.connection_succeeded]. After that the signal [signal MultiplayerPeer.peer_connected] will be emitted for every already connected peer, and any new peer that might connect. If the server peer disconnects after that, signal [signal MultiplayerPeer.server_disconnected] will be emitted and state will become [constant MultiplayerPeer.CONNECTION_CONNECTED].
|
|
You can optionally specify a [code]channels_config[/code] array of [enum TransferMode] which will be used to create extra channels (WebRTC only supports one transfer mode per channel).
|
|
</description>
|
|
</method>
|
|
<method name="remove_peer">
|
|
<return type="void" />
|
|
<argument index="0" name="peer_id" type="int" />
|
|
<description>
|
|
Remove the peer with given [code]peer_id[/code] from the mesh. If the peer was connected, and [signal MultiplayerPeer.peer_connected] was emitted for it, then [signal MultiplayerPeer.peer_disconnected] will be emitted.
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<members>
|
|
<member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" />
|
|
<member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="TransferMode" default="2" />
|
|
</members>
|
|
<constants>
|
|
</constants>
|
|
</class>
|