diff options
Diffstat (limited to 'modules/websocket')
-rw-r--r-- | modules/websocket/doc_classes/WebSocketClient.xml | 2 | ||||
-rw-r--r-- | modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml | 2 | ||||
-rw-r--r-- | modules/websocket/doc_classes/WebSocketPeer.xml | 12 | ||||
-rw-r--r-- | modules/websocket/doc_classes/WebSocketServer.xml | 2 | ||||
-rw-r--r-- | modules/websocket/emws_peer.cpp | 5 | ||||
-rw-r--r-- | modules/websocket/emws_peer.h | 1 | ||||
-rw-r--r-- | modules/websocket/websocket_peer.cpp | 1 | ||||
-rw-r--r-- | modules/websocket/websocket_peer.h | 1 | ||||
-rw-r--r-- | modules/websocket/websocket_server.cpp | 2 | ||||
-rw-r--r-- | modules/websocket/wsl_client.cpp | 1 | ||||
-rw-r--r-- | modules/websocket/wsl_peer.cpp | 10 | ||||
-rw-r--r-- | modules/websocket/wsl_peer.h | 1 | ||||
-rw-r--r-- | modules/websocket/wsl_server.cpp | 5 |
13 files changed, 37 insertions, 8 deletions
diff --git a/modules/websocket/doc_classes/WebSocketClient.xml b/modules/websocket/doc_classes/WebSocketClient.xml index 52a98d8c32..2549321db3 100644 --- a/modules/websocket/doc_classes/WebSocketClient.xml +++ b/modules/websocket/doc_classes/WebSocketClient.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="WebSocketClient" inherits="WebSocketMultiplayerPeer" category="Core" version="3.2"> +<class name="WebSocketClient" inherits="WebSocketMultiplayerPeer" version="4.0"> <brief_description> A WebSocket client implementation. </brief_description> diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml index 7070cfbdab..0679acf78a 100644 --- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml +++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="WebSocketMultiplayerPeer" inherits="NetworkedMultiplayerPeer" category="Core" version="3.2"> +<class name="WebSocketMultiplayerPeer" inherits="NetworkedMultiplayerPeer" version="4.0"> <brief_description> Base class for WebSocket server and client. </brief_description> diff --git a/modules/websocket/doc_classes/WebSocketPeer.xml b/modules/websocket/doc_classes/WebSocketPeer.xml index 3c943ccd24..5125956416 100644 --- a/modules/websocket/doc_classes/WebSocketPeer.xml +++ b/modules/websocket/doc_classes/WebSocketPeer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="WebSocketPeer" inherits="PacketPeer" category="Core" version="3.2"> +<class name="WebSocketPeer" inherits="PacketPeer" version="4.0"> <brief_description> A class representing a specific WebSocket connection. </brief_description> @@ -53,6 +53,16 @@ Returns [code]true[/code] if this peer is currently connected. </description> </method> + <method name="set_no_delay"> + <return type="void"> + </return> + <argument index="0" name="enabled" type="bool"> + </argument> + <description> + Disable Nagle's algorithm on the underling TCP socket (default). See [method StreamPeerTCP.set_no_delay] for more information. + [b]Note:[/b] Not available in the HTML5 export. + </description> + </method> <method name="set_write_mode"> <return type="void"> </return> diff --git a/modules/websocket/doc_classes/WebSocketServer.xml b/modules/websocket/doc_classes/WebSocketServer.xml index 2074a10fa9..f66e1bf54b 100644 --- a/modules/websocket/doc_classes/WebSocketServer.xml +++ b/modules/websocket/doc_classes/WebSocketServer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="WebSocketServer" inherits="WebSocketMultiplayerPeer" category="Core" version="3.2"> +<class name="WebSocketServer" inherits="WebSocketMultiplayerPeer" version="4.0"> <brief_description> A WebSocket server implementation. </brief_description> diff --git a/modules/websocket/emws_peer.cpp b/modules/websocket/emws_peer.cpp index d07360c525..effed8e4d9 100644 --- a/modules/websocket/emws_peer.cpp +++ b/modules/websocket/emws_peer.cpp @@ -139,6 +139,11 @@ uint16_t EMWSPeer::get_connected_port() const { ERR_FAIL_V_MSG(0, "Not supported in HTML5 export."); }; +void EMWSPeer::set_no_delay(bool p_enabled) { + + ERR_FAIL_MSG("'set_no_delay' is not supported in HTML5 export."); +} + EMWSPeer::EMWSPeer() { peer_sock = -1; write_mode = WRITE_MODE_BINARY; diff --git a/modules/websocket/emws_peer.h b/modules/websocket/emws_peer.h index 9fe7fb8edc..43b42f9be6 100644 --- a/modules/websocket/emws_peer.h +++ b/modules/websocket/emws_peer.h @@ -68,6 +68,7 @@ public: virtual WriteMode get_write_mode() const; virtual void set_write_mode(WriteMode p_mode); virtual bool was_string_packet() const; + virtual void set_no_delay(bool p_enabled); EMWSPeer(); ~EMWSPeer(); diff --git a/modules/websocket/websocket_peer.cpp b/modules/websocket/websocket_peer.cpp index 474b11f012..30a5972330 100644 --- a/modules/websocket/websocket_peer.cpp +++ b/modules/websocket/websocket_peer.cpp @@ -46,6 +46,7 @@ void WebSocketPeer::_bind_methods() { ClassDB::bind_method(D_METHOD("close", "code", "reason"), &WebSocketPeer::close, DEFVAL(1000), DEFVAL("")); ClassDB::bind_method(D_METHOD("get_connected_host"), &WebSocketPeer::get_connected_host); ClassDB::bind_method(D_METHOD("get_connected_port"), &WebSocketPeer::get_connected_port); + ClassDB::bind_method(D_METHOD("set_no_delay", "enabled"), &WebSocketPeer::set_no_delay); BIND_ENUM_CONSTANT(WRITE_MODE_TEXT); BIND_ENUM_CONSTANT(WRITE_MODE_BINARY); diff --git a/modules/websocket/websocket_peer.h b/modules/websocket/websocket_peer.h index c4e1984aa0..d4173600ec 100644 --- a/modules/websocket/websocket_peer.h +++ b/modules/websocket/websocket_peer.h @@ -64,6 +64,7 @@ public: virtual IP_Address get_connected_host() const = 0; virtual uint16_t get_connected_port() const = 0; virtual bool was_string_packet() const = 0; + virtual void set_no_delay(bool p_enabled) = 0; WebSocketPeer(); ~WebSocketPeer(); diff --git a/modules/websocket/websocket_server.cpp b/modules/websocket/websocket_server.cpp index 76e88d72b9..a7ced65543 100644 --- a/modules/websocket/websocket_server.cpp +++ b/modules/websocket/websocket_server.cpp @@ -114,7 +114,7 @@ NetworkedMultiplayerPeer::ConnectionStatus WebSocketServer::get_connection_statu return CONNECTION_CONNECTED; return CONNECTION_DISCONNECTED; -}; +} bool WebSocketServer::is_server() const { diff --git a/modules/websocket/wsl_client.cpp b/modules/websocket/wsl_client.cpp index 88a306c7f5..088f266f18 100644 --- a/modules/websocket/wsl_client.cpp +++ b/modules/websocket/wsl_client.cpp @@ -90,6 +90,7 @@ void WSLClient::_do_handshake() { data->is_server = false; data->id = 1; _peer->make_context(data, _in_buf_size, _in_pkt_size, _out_buf_size, _out_pkt_size); + _peer->set_no_delay(true); _on_connect(protocol); break; } diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp index 2f7f84c893..08079145e4 100644 --- a/modules/websocket/wsl_peer.cpp +++ b/modules/websocket/wsl_peer.cpp @@ -243,6 +243,10 @@ Error WSLPeer::put_packet(const uint8_t *p_buffer, int p_buffer_size) { msg.msg_length = p_buffer_size; wslay_event_queue_msg(_data->ctx, &msg); + if (wslay_event_send(_data->ctx) < 0) { + close_now(); + return FAILED; + } return OK; } @@ -314,6 +318,12 @@ uint16_t WSLPeer::get_connected_port() const { return _data->tcp->get_connected_port(); } +void WSLPeer::set_no_delay(bool p_enabled) { + + ERR_FAIL_COND(!is_connected_to_host() || _data->tcp.is_null()); + _data->tcp->set_no_delay(p_enabled); +} + void WSLPeer::invalidate() { if (_data) _data->valid = false; diff --git a/modules/websocket/wsl_peer.h b/modules/websocket/wsl_peer.h index 2fbb7aeec3..f1c45ee859 100644 --- a/modules/websocket/wsl_peer.h +++ b/modules/websocket/wsl_peer.h @@ -109,6 +109,7 @@ public: virtual WriteMode get_write_mode() const; virtual void set_write_mode(WriteMode p_mode); virtual bool was_string_packet() const; + virtual void set_no_delay(bool p_enabled); void make_context(PeerData *p_data, unsigned int p_in_buf_size, unsigned int p_in_pkt_size, unsigned int p_out_buf_size, unsigned int p_out_pkt_size); Error parse_message(const wslay_event_on_msg_recv_arg *arg); diff --git a/modules/websocket/wsl_server.cpp b/modules/websocket/wsl_server.cpp index c3dd79a89c..4db650a0c1 100644 --- a/modules/websocket/wsl_server.cpp +++ b/modules/websocket/wsl_server.cpp @@ -165,9 +165,7 @@ Error WSLServer::listen(int p_port, const Vector<String> p_protocols, bool gd_mp for (int i = 0; i < p_protocols.size(); i++) { pw[i] = p_protocols[i].strip_edges(); } - _server->listen(p_port, bind_ip); - - return OK; + return _server->listen(p_port, bind_ip); } void WSLServer::poll() { @@ -208,6 +206,7 @@ void WSLServer::poll() { Ref<WSLPeer> ws_peer = memnew(WSLPeer); ws_peer->make_context(data, _in_buf_size, _in_pkt_size, _out_buf_size, _out_pkt_size); + ws_peer->set_no_delay(true); _peer_map[id] = ws_peer; remove_peers.push_back(ppeer); |