WebRTCMultiplayer

A simple interface to create a peer-to-peer mesh network composed of WebRTCPeerConnection that is compatible with the MultiplayerAPI.

This class constructs a full mesh of WebRTCPeerConnection (one connection for each peer) that can be used as a MultiplayerAPI.networkPeer. You can add each WebRTCPeerConnection via addPeer or remove them via removePeer. 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. NetworkedMultiplayerPeer.connectionSucceeded and NetworkedMultiplayerPeer.serverDisconnected will not be emitted unless server_compatibility is true in initialize. Beside that data transfer works like in a NetworkedMultiplayerPeer.

Members

Aliases

BaseClasses
alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses)
Undocumented in source.

Functions

addPeer
GodotError addPeer(WebRTCPeerConnection peer, long peer_id, long unreliable_lifetime)

Add a new peer to the mesh with the given peer_id. The WebRTCPeerConnection must be in state constant WebRTCPeerConnection.STATE_NEW. Three channels will be created for reliable, unreliable, and ordered transport. The value of unreliable_lifetime will be passed to the maxPacketLifetime option when creating unreliable and ordered channels (see WebRTCPeerConnection.createDataChannel).

close
void close()

Close all the add peer connections and channels, freeing all resources.

getPeer
Dictionary getPeer(long peer_id)

Return a dictionary representation of the peer with given peer_id with three keys. connection containing the WebRTCPeerConnection to this peer, channels an array of three WebRTCDataChannel, and connected a boolean representing if the peer connection is currently connected (all three channels are open).

getPeers
Dictionary getPeers()

Returns a dictionary which keys are the peer ids and values the peer representation as in getPeer.

hasPeer
bool hasPeer(long peer_id)

Returns true if the given peer_id is in the peers map (it might not be connected though).

initialize
GodotError initialize(long peer_id, bool server_compatibility)

Initialize the multiplayer peer with the given peer_id (must be between 1 and 2147483647). If server_compatibilty is false (default), the multiplayer peer will be immediately in state constant NetworkedMultiplayerPeer.CONNECTION_CONNECTED and NetworkedMultiplayerPeer.connectionSucceeded will not be emitted. If server_compatibilty is true the peer will suppress all NetworkedMultiplayerPeer.peerConnected signals until a peer with id constant NetworkedMultiplayerPeer.TARGET_PEER_SERVER connects and then emit NetworkedMultiplayerPeer.connectionSucceeded. After that the signal NetworkedMultiplayerPeer.peerConnected will be emitted for every already connected peer, and any new peer that might connect. If the server peer disconnects after that, signal NetworkedMultiplayerPeer.serverDisconnected will be emitted and state will become constant NetworkedMultiplayerPeer.CONNECTION_CONNECTED.

opAssign
typeof(null) opAssign(typeof(null) n)
opEquals
bool opEquals(WebRTCMultiplayer other)
opEquals
bool opEquals(typeof(null) n)
removePeer
void removePeer(long peer_id)

Remove the peer with given peer_id from the mesh. If the peer was connected, and NetworkedMultiplayerPeer.peerConnected was emitted for it, then NetworkedMultiplayerPeer.peerDisconnected will be emitted.

toHash
size_t toHash()

Mixins

__anonymous
mixin baseCasts
Undocumented in source.

Static functions

_new
WebRTCMultiplayer _new()

Construct a new instance of WebRTCMultiplayer. Note: use memnew!WebRTCMultiplayer instead.

Static variables

_classBindingInitialized
bool _classBindingInitialized;
Undocumented in source.

Structs

GDNativeClassBinding
struct GDNativeClassBinding
Undocumented in source.

Unions

__anonymous
union __anonymous
Undocumented in source.

Variables

_GODOT_internal_name
enum string _GODOT_internal_name;
Undocumented in source.

Mixed In Members

From mixin baseCasts

as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(To) as()
Undocumented in source. Be warned that the author may not have intended to support it.
as
inout(ToRef) as()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(To)
Undocumented in source.
opCast
template opCast(ToRef)
Undocumented in source.
opCast
void* opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
godot_object opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opCast
bool opCast()
Undocumented in source. Be warned that the author may not have intended to support it.

Meta