/
WebRTCMultiplayer.hx
109 lines (87 loc) · 7.15 KB
/
WebRTCMultiplayer.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Automatically generated Godot externs: DO NOT EDIT
// MIT licensed, see LICENSE.md
package godot;
import cs.system.*;
/**
This class constructs a full mesh of `godot.WebRTCPeerConnection` (one connection for each peer) that can be used as a `godot.MultiplayerAPI.networkPeer`.
You can add each `godot.WebRTCPeerConnection` via `godot.WebRTCMultiplayer.addPeer` or remove them via `godot.WebRTCMultiplayer.removePeer`. Peers must be added in `godot.WebRTCPeerConnection_ConnectionState.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.connection_succeeded` and `NetworkedMultiplayerPeer.server_disconnected` will not be emitted unless `server_compatibility` is `true` in `godot.WebRTCMultiplayer.initialize`. Beside that data transfer works like in a `godot.NetworkedMultiplayerPeer`.
**/
@:libType
@:csNative
@:native("Godot.WebRTCMultiplayer")
@:autoBuild(godot.Godot.buildUserClass())
extern class WebRTCMultiplayer extends godot.NetworkedMultiplayerPeer {
@:native("new")
public function new():Void;
#if doc_gen
/**
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 `godot.NetworkedMultiplayerPeer_ConnectionStatus.connected` and `NetworkedMultiplayerPeer.connection_succeeded` will not be emitted.
If `server_compatibilty` is `true` the peer will suppress all `NetworkedMultiplayerPeer.peer_connected` signals until a peer with id `godot.NetworkedMultiplayerPeer.targetPeerServer` connects and then emit `NetworkedMultiplayerPeer.connection_succeeded`. After that the signal `NetworkedMultiplayerPeer.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 `NetworkedMultiplayerPeer.server_disconnected` will be emitted and state will become `godot.NetworkedMultiplayerPeer_ConnectionStatus.connected`.
**/
@:native("Initialize")
public function initialize(peerId:Int, ?serverCompatibility:Bool):godot.Error;
#else
/**
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 `godot.NetworkedMultiplayerPeer_ConnectionStatus.connected` and `NetworkedMultiplayerPeer.connection_succeeded` will not be emitted.
If `server_compatibilty` is `true` the peer will suppress all `NetworkedMultiplayerPeer.peer_connected` signals until a peer with id `godot.NetworkedMultiplayerPeer.targetPeerServer` connects and then emit `NetworkedMultiplayerPeer.connection_succeeded`. After that the signal `NetworkedMultiplayerPeer.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 `NetworkedMultiplayerPeer.server_disconnected` will be emitted and state will become `godot.NetworkedMultiplayerPeer_ConnectionStatus.connected`.
**/
@:native("Initialize")
public overload function initialize(peerId:Int):godot.Error;
/**
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 `godot.NetworkedMultiplayerPeer_ConnectionStatus.connected` and `NetworkedMultiplayerPeer.connection_succeeded` will not be emitted.
If `server_compatibilty` is `true` the peer will suppress all `NetworkedMultiplayerPeer.peer_connected` signals until a peer with id `godot.NetworkedMultiplayerPeer.targetPeerServer` connects and then emit `NetworkedMultiplayerPeer.connection_succeeded`. After that the signal `NetworkedMultiplayerPeer.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 `NetworkedMultiplayerPeer.server_disconnected` will be emitted and state will become `godot.NetworkedMultiplayerPeer_ConnectionStatus.connected`.
**/
@:native("Initialize")
public overload function initialize(peerId:Int, serverCompatibility:Bool):godot.Error;
#end
#if doc_gen
/**
Add a new peer to the mesh with the given `peer_id`. The `godot.WebRTCPeerConnection` must be in state `godot.WebRTCPeerConnection_ConnectionState.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 `godot.WebRTCPeerConnection.createDataChannel`).
**/
@:native("AddPeer")
public function addPeer(peer:godot.WebRTCPeerConnection, peerId:Int, ?unreliableLifetime:Int):godot.Error;
#else
/**
Add a new peer to the mesh with the given `peer_id`. The `godot.WebRTCPeerConnection` must be in state `godot.WebRTCPeerConnection_ConnectionState.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 `godot.WebRTCPeerConnection.createDataChannel`).
**/
@:native("AddPeer")
public overload function addPeer(peer:godot.WebRTCPeerConnection, peerId:Int):godot.Error;
/**
Add a new peer to the mesh with the given `peer_id`. The `godot.WebRTCPeerConnection` must be in state `godot.WebRTCPeerConnection_ConnectionState.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 `godot.WebRTCPeerConnection.createDataChannel`).
**/
@:native("AddPeer")
public overload function addPeer(peer:godot.WebRTCPeerConnection, peerId:Int, unreliableLifetime:Int):godot.Error;
#end
/**
Remove the peer with given `peer_id` from the mesh. If the peer was connected, and `NetworkedMultiplayerPeer.peer_connected` was emitted for it, then `NetworkedMultiplayerPeer.peer_disconnected` will be emitted.
**/
@:native("RemovePeer")
public function removePeer(peerId:Int):Void;
/**
Returns `true` if the given `peer_id` is in the peers map (it might not be connected though).
**/
@:native("HasPeer")
public function hasPeer(peerId:Int):Bool;
/**
Return a dictionary representation of the peer with given `peer_id` with three keys. `connection` containing the `godot.WebRTCPeerConnection` to this peer, `channels` an array of three `godot.WebRTCDataChannel`, and `connected` a boolean representing if the peer connection is currently connected (all three channels are open).
**/
@:native("GetPeer")
public function getPeer(peerId:Int):godot.collections.Dictionary;
/**
Returns a dictionary which keys are the peer ids and values the peer representation as in `godot.WebRTCMultiplayer.getPeer`.
**/
@:native("GetPeers")
public function getPeers():godot.collections.Dictionary;
/**
Close all the add peer connections and channels, freeing all resources.
**/
@:native("Close")
public function close():Void;
}