1 /**
2 
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.webrtcdatachannel;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.packetpeer;
24 import godot.reference;
25 /**
26 
27 */
28 @GodotBaseClass struct WebRTCDataChannel
29 {
30 	package(godot) enum string _GODOT_internal_name = "WebRTCDataChannel";
31 public:
32 @nogc nothrow:
33 	union { /** */ godot_object _godot_object; /** */ PacketPeer _GODOT_base; }
34 	alias _GODOT_base this;
35 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
36 	package(godot) __gshared bool _classBindingInitialized = false;
37 	package(godot) static struct GDNativeClassBinding
38 	{
39 		__gshared:
40 		@GodotName("close") GodotMethod!(void) close;
41 		@GodotName("get_id") GodotMethod!(long) getId;
42 		@GodotName("get_label") GodotMethod!(String) getLabel;
43 		@GodotName("get_max_packet_life_time") GodotMethod!(long) getMaxPacketLifeTime;
44 		@GodotName("get_max_retransmits") GodotMethod!(long) getMaxRetransmits;
45 		@GodotName("get_protocol") GodotMethod!(String) getProtocol;
46 		@GodotName("get_ready_state") GodotMethod!(WebRTCDataChannel.ChannelState) getReadyState;
47 		@GodotName("get_write_mode") GodotMethod!(WebRTCDataChannel.WriteMode) getWriteMode;
48 		@GodotName("is_negotiated") GodotMethod!(bool) isNegotiated;
49 		@GodotName("is_ordered") GodotMethod!(bool) isOrdered;
50 		@GodotName("poll") GodotMethod!(GodotError) poll;
51 		@GodotName("set_write_mode") GodotMethod!(void, long) setWriteMode;
52 		@GodotName("was_string_packet") GodotMethod!(bool) wasStringPacket;
53 	}
54 	/// 
55 	pragma(inline, true) bool opEquals(in WebRTCDataChannel other) const
56 	{ return _godot_object.ptr is other._godot_object.ptr; }
57 	/// 
58 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
59 	{ _godot_object.ptr = n; return null; }
60 	/// 
61 	pragma(inline, true) bool opEquals(typeof(null) n) const
62 	{ return _godot_object.ptr is n; }
63 	/// 
64 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
65 	mixin baseCasts;
66 	/// Construct a new instance of WebRTCDataChannel.
67 	/// Note: use `memnew!WebRTCDataChannel` instead.
68 	static WebRTCDataChannel _new()
69 	{
70 		static godot_class_constructor constructor;
71 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("WebRTCDataChannel");
72 		if(constructor is null) return typeof(this).init;
73 		return cast(WebRTCDataChannel)(constructor());
74 	}
75 	@disable new(size_t s);
76 	/// 
77 	enum WriteMode : int
78 	{
79 		/**
80 		Tells the channel to send data over this channel as text. An external peer (non-Godot) would receive this as a string.
81 		*/
82 		writeModeText = 0,
83 		/**
84 		Tells the channel to send data over this channel as binary. An external peer (non-Godot) would receive this as array buffer or blob.
85 		*/
86 		writeModeBinary = 1,
87 	}
88 	/// 
89 	enum ChannelState : int
90 	{
91 		/**
92 		The channel was created, but it's still trying to connect.
93 		*/
94 		stateConnecting = 0,
95 		/**
96 		The channel is currently open, and data can flow over it.
97 		*/
98 		stateOpen = 1,
99 		/**
100 		The channel is being closed, no new messages will be accepted, but those already in queue will be flushed.
101 		*/
102 		stateClosing = 2,
103 		/**
104 		The channel was closed, or connection failed.
105 		*/
106 		stateClosed = 3,
107 	}
108 	/// 
109 	enum Constants : int
110 	{
111 		stateConnecting = 0,
112 		writeModeText = 0,
113 		stateOpen = 1,
114 		writeModeBinary = 1,
115 		stateClosing = 2,
116 		stateClosed = 3,
117 	}
118 	/**
119 	Closes this data channel, notifying the other peer.
120 	*/
121 	void close()
122 	{
123 		checkClassBinding!(typeof(this))();
124 		ptrcall!(void)(GDNativeClassBinding.close, _godot_object);
125 	}
126 	/**
127 	Returns the id assigned to this channel during creation (or auto-assigned during negotiation).
128 	If the channel is not negotiated out-of-band the id will only be available after the connection is established (will return `65535` until then).
129 	*/
130 	long getId() const
131 	{
132 		checkClassBinding!(typeof(this))();
133 		return ptrcall!(long)(GDNativeClassBinding.getId, _godot_object);
134 	}
135 	/**
136 	Returns the label assigned to this channel during creation.
137 	*/
138 	String getLabel() const
139 	{
140 		checkClassBinding!(typeof(this))();
141 		return ptrcall!(String)(GDNativeClassBinding.getLabel, _godot_object);
142 	}
143 	/**
144 	Returns the `maxPacketLifeTime` value assigned to this channel during creation.
145 	Will be `65535` if not specified.
146 	*/
147 	long getMaxPacketLifeTime() const
148 	{
149 		checkClassBinding!(typeof(this))();
150 		return ptrcall!(long)(GDNativeClassBinding.getMaxPacketLifeTime, _godot_object);
151 	}
152 	/**
153 	Returns the `maxRetransmits` value assigned to this channel during creation.
154 	Will be `65535` if not specified.
155 	*/
156 	long getMaxRetransmits() const
157 	{
158 		checkClassBinding!(typeof(this))();
159 		return ptrcall!(long)(GDNativeClassBinding.getMaxRetransmits, _godot_object);
160 	}
161 	/**
162 	Returns the sub-protocol assigned to this channel during creation. An empty string if not specified.
163 	*/
164 	String getProtocol() const
165 	{
166 		checkClassBinding!(typeof(this))();
167 		return ptrcall!(String)(GDNativeClassBinding.getProtocol, _godot_object);
168 	}
169 	/**
170 	Returns the current state of this channel, see $(D channelstate).
171 	*/
172 	WebRTCDataChannel.ChannelState getReadyState() const
173 	{
174 		checkClassBinding!(typeof(this))();
175 		return ptrcall!(WebRTCDataChannel.ChannelState)(GDNativeClassBinding.getReadyState, _godot_object);
176 	}
177 	/**
178 	
179 	*/
180 	WebRTCDataChannel.WriteMode getWriteMode() const
181 	{
182 		checkClassBinding!(typeof(this))();
183 		return ptrcall!(WebRTCDataChannel.WriteMode)(GDNativeClassBinding.getWriteMode, _godot_object);
184 	}
185 	/**
186 	Returns `true` if this channel was created with out-of-band configuration.
187 	*/
188 	bool isNegotiated() const
189 	{
190 		checkClassBinding!(typeof(this))();
191 		return ptrcall!(bool)(GDNativeClassBinding.isNegotiated, _godot_object);
192 	}
193 	/**
194 	Returns `true` if this channel was created with ordering enabled (default).
195 	*/
196 	bool isOrdered() const
197 	{
198 		checkClassBinding!(typeof(this))();
199 		return ptrcall!(bool)(GDNativeClassBinding.isOrdered, _godot_object);
200 	}
201 	/**
202 	Reserved, but not used for now.
203 	*/
204 	GodotError poll()
205 	{
206 		checkClassBinding!(typeof(this))();
207 		return ptrcall!(GodotError)(GDNativeClassBinding.poll, _godot_object);
208 	}
209 	/**
210 	
211 	*/
212 	void setWriteMode(in long write_mode)
213 	{
214 		checkClassBinding!(typeof(this))();
215 		ptrcall!(void)(GDNativeClassBinding.setWriteMode, _godot_object, write_mode);
216 	}
217 	/**
218 	Returns `true` if the last received packet was transferred as text. See $(D writeMode).
219 	*/
220 	bool wasStringPacket() const
221 	{
222 		checkClassBinding!(typeof(this))();
223 		return ptrcall!(bool)(GDNativeClassBinding.wasStringPacket, _godot_object);
224 	}
225 	/**
226 	The transfer mode to use when sending outgoing packet. Either text or binary.
227 	*/
228 	@property WebRTCDataChannel.WriteMode writeMode()
229 	{
230 		return getWriteMode();
231 	}
232 	/// ditto
233 	@property void writeMode(long v)
234 	{
235 		setWriteMode(v);
236 	}
237 }