You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-11 13:10:58 +00:00
Allow setting websocket buffers sizes internally.
Needed by LSP.
This commit is contained in:
@@ -205,6 +205,12 @@ int EMWSClient::get_max_packet_size() const {
|
|||||||
return (1 << _in_buf_size) - PROTO_SIZE;
|
return (1 << _in_buf_size) - PROTO_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Error EMWSClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
|
||||||
|
_in_buf_size = nearest_shift(p_in_buffer - 1) + 10;
|
||||||
|
_in_pkt_size = nearest_shift(p_in_packets - 1);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
EMWSClient::EMWSClient() {
|
EMWSClient::EMWSClient() {
|
||||||
_in_buf_size = nearest_shift((int)GLOBAL_GET(WSC_IN_BUF) - 1) + 10;
|
_in_buf_size = nearest_shift((int)GLOBAL_GET(WSC_IN_BUF) - 1) + 10;
|
||||||
_in_pkt_size = nearest_shift((int)GLOBAL_GET(WSC_IN_PKT) - 1);
|
_in_pkt_size = nearest_shift((int)GLOBAL_GET(WSC_IN_PKT) - 1);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
bool _is_connecting;
|
bool _is_connecting;
|
||||||
|
|
||||||
|
Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
|
||||||
Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
|
Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
|
||||||
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
|
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
|
||||||
void disconnect_from_host(int p_code = 1000, String p_reason = "");
|
void disconnect_from_host(int p_code = 1000, String p_reason = "");
|
||||||
|
|||||||
@@ -79,6 +79,10 @@ int EMWSServer::get_max_packet_size() const {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Error EMWSServer::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
EMWSServer::EMWSServer() {
|
EMWSServer::EMWSServer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ class EMWSServer : public WebSocketServer {
|
|||||||
GDCIIMPL(EMWSServer, WebSocketServer);
|
GDCIIMPL(EMWSServer, WebSocketServer);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
|
||||||
Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
|
Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
|
||||||
void stop();
|
void stop();
|
||||||
bool is_listening() const;
|
bool is_listening() const;
|
||||||
|
|||||||
@@ -215,6 +215,17 @@ uint16_t LWSClient::get_connected_port() const {
|
|||||||
return 1025;
|
return 1025;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Error LWSClient::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
|
||||||
|
ERR_EXPLAIN("Buffers sizes can only be set before listening or connecting");
|
||||||
|
ERR_FAIL_COND_V(context != NULL, FAILED);
|
||||||
|
|
||||||
|
_in_buf_size = nearest_shift(p_in_buffer - 1) + 10;
|
||||||
|
_in_pkt_size = nearest_shift(p_in_packets - 1);
|
||||||
|
_out_buf_size = nearest_shift(p_out_buffer - 1) + 10;
|
||||||
|
_out_pkt_size = nearest_shift(p_out_packets - 1);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
LWSClient::LWSClient() {
|
LWSClient::LWSClient() {
|
||||||
_in_buf_size = nearest_shift((int)GLOBAL_GET(WSC_IN_BUF) - 1) + 10;
|
_in_buf_size = nearest_shift((int)GLOBAL_GET(WSC_IN_BUF) - 1) + 10;
|
||||||
_in_pkt_size = nearest_shift((int)GLOBAL_GET(WSC_IN_PKT) - 1);
|
_in_pkt_size = nearest_shift((int)GLOBAL_GET(WSC_IN_PKT) - 1);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ private:
|
|||||||
int _out_pkt_size;
|
int _out_pkt_size;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
|
||||||
Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
|
Error connect_to_host(String p_host, String p_path, uint16_t p_port, bool p_ssl, PoolVector<String> p_protocol = PoolVector<String>());
|
||||||
int get_max_packet_size() const;
|
int get_max_packet_size() const;
|
||||||
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
|
Ref<WebSocketPeer> get_peer(int p_peer_id) const;
|
||||||
|
|||||||
@@ -197,6 +197,17 @@ void LWSServer::disconnect_peer(int p_peer_id, int p_code, String p_reason) {
|
|||||||
get_peer(p_peer_id)->close(p_code, p_reason);
|
get_peer(p_peer_id)->close(p_code, p_reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Error LWSServer::set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) {
|
||||||
|
ERR_EXPLAIN("Buffers sizes can only be set before listening or connecting");
|
||||||
|
ERR_FAIL_COND_V(context != NULL, FAILED);
|
||||||
|
|
||||||
|
_in_buf_size = nearest_shift(p_in_buffer - 1) + 10;
|
||||||
|
_in_pkt_size = nearest_shift(p_in_packets - 1);
|
||||||
|
_out_buf_size = nearest_shift(p_out_buffer - 1) + 10;
|
||||||
|
_out_pkt_size = nearest_shift(p_out_packets - 1);
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
LWSServer::LWSServer() {
|
LWSServer::LWSServer() {
|
||||||
_in_buf_size = nearest_shift((int)GLOBAL_GET(WSS_IN_BUF) - 1) + 10;
|
_in_buf_size = nearest_shift((int)GLOBAL_GET(WSS_IN_BUF) - 1) + 10;
|
||||||
_in_pkt_size = nearest_shift((int)GLOBAL_GET(WSS_IN_PKT) - 1);
|
_in_pkt_size = nearest_shift((int)GLOBAL_GET(WSS_IN_PKT) - 1);
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ private:
|
|||||||
int _out_pkt_size;
|
int _out_pkt_size;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets);
|
||||||
Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
|
Error listen(int p_port, PoolVector<String> p_protocols = PoolVector<String>(), bool gd_mp_api = false);
|
||||||
void stop();
|
void stop();
|
||||||
bool is_listening() const;
|
bool is_listening() const;
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ public:
|
|||||||
void _on_disconnect(bool p_was_clean);
|
void _on_disconnect(bool p_was_clean);
|
||||||
void _on_error();
|
void _on_error();
|
||||||
|
|
||||||
|
virtual Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) = 0;
|
||||||
|
|
||||||
WebSocketClient();
|
WebSocketClient();
|
||||||
~WebSocketClient();
|
~WebSocketClient();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -62,6 +62,8 @@ public:
|
|||||||
void _on_disconnect(int32_t p_peer_id, bool p_was_clean);
|
void _on_disconnect(int32_t p_peer_id, bool p_was_clean);
|
||||||
void _on_close_request(int32_t p_peer_id, int p_code, String p_reason);
|
void _on_close_request(int32_t p_peer_id, int p_code, String p_reason);
|
||||||
|
|
||||||
|
virtual Error set_buffers(int p_in_buffer, int p_in_packets, int p_out_buffer, int p_out_packets) = 0;
|
||||||
|
|
||||||
WebSocketServer();
|
WebSocketServer();
|
||||||
~WebSocketServer();
|
~WebSocketServer();
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user