Procházet zdrojové kódy

Expose WebSocket set_buffers and document it.

Fabio Alessandrelli před 6 roky
rodič
revize
5b2f098ed4

+ 18 - 0
modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml

@@ -18,6 +18,24 @@
 				Returns the [WebSocketPeer] associated to the given [code]peer_id[/code].
 			</description>
 		</method>
+		<method name="set_buffers">
+			<return type="int" enum="Error">
+			</return>
+			<argument index="0" name="input_buffer_size_kb" type="int">
+			</argument>
+			<argument index="1" name="input_max_packets" type="int">
+			</argument>
+			<argument index="2" name="output_buffer_size_kb" type="int">
+			</argument>
+			<argument index="3" name="output_max_packets" type="int">
+			</argument>
+			<description>
+				Configure the buffers sizes for this WebSocket peer. Default values can be specified in project settings under [code]network/limits[/code]. For server, values are meant per connected peer.
+				The first two parameters define the size and queued packets limits of the input buffer, the last two of the output buffer.
+				Buffer sizes are expressed in KiB, so [code]4 = 2^12 = 4096 bytes[/code]. All parameters will be rounded up to the nearest power of two.
+				NOTE: HTML5 exports only use the input buffer since the output one is managed by browsers.
+			</description>
+		</method>
 	</methods>
 	<signals>
 		<signal name="peer_packet">

+ 1 - 0
modules/websocket/websocket_multiplayer_peer.cpp

@@ -87,6 +87,7 @@ void WebSocketMultiplayerPeer::_clear() {
 
 void WebSocketMultiplayerPeer::_bind_methods() {
 
+	ClassDB::bind_method(D_METHOD("set_buffers", "input_buffer_size_kb", "input_max_packets", "output_buffer_size_kb", "output_max_packets"), &WebSocketMultiplayerPeer::set_buffers);
 	ClassDB::bind_method(D_METHOD("get_peer", "peer_id"), &WebSocketMultiplayerPeer::get_peer);
 
 	ADD_SIGNAL(MethodInfo("peer_packet", PropertyInfo(Variant::INT, "peer_source")));

+ 1 - 0
modules/websocket/websocket_multiplayer_peer.h

@@ -97,6 +97,7 @@ public:
 	virtual Error put_packet(const uint8_t *p_buffer, int p_buffer_size);
 
 	/* WebSocketPeer */
+	virtual Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) = 0;
 	virtual Ref<WebSocketPeer> get_peer(int p_peer_id) const = 0;
 
 	void _process_multiplayer(Ref<WebSocketPeer> p_peer, uint32_t p_peer_id);