summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-06-15 17:13:26 +0200
committerFabio Alessandrelli <fabio.alessandrelli@gmail.com>2019-06-15 17:21:08 +0200
commit5b2f098ed4444572432eb2e67c154f89852039ec (patch)
tree5ebc7fdcad6dff1e48fc4fece39000d28a2b22d1
parentee90da4acbf8769d37b32e971434733d051a5e49 (diff)
Expose WebSocket set_buffers and document it.
-rw-r--r--modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml18
-rw-r--r--modules/websocket/websocket_multiplayer_peer.cpp1
-rw-r--r--modules/websocket/websocket_multiplayer_peer.h1
3 files changed, 20 insertions, 0 deletions
diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
index 8548d21323..103dbd771b 100644
--- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml
+++ b/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">
diff --git a/modules/websocket/websocket_multiplayer_peer.cpp b/modules/websocket/websocket_multiplayer_peer.cpp
index 6aab8a7e81..23cbf916eb 100644
--- a/modules/websocket/websocket_multiplayer_peer.cpp
+++ b/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")));
diff --git a/modules/websocket/websocket_multiplayer_peer.h b/modules/websocket/websocket_multiplayer_peer.h
index b050449ee0..089bc25fe9 100644
--- a/modules/websocket/websocket_multiplayer_peer.h
+++ b/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);