diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2018-09-23 21:14:20 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2018-09-24 01:50:37 +0200 |
commit | 5d91e87c64f757fb1c20f43a0a30db3c73073625 (patch) | |
tree | 29000bb4eabc80bb8f208d71bafd6291d9df9868 /modules/websocket/websocket_client.cpp | |
parent | 399910ddd82e84f078ebefb3ed2c51d2ef989235 (diff) | |
download | redot-engine-5d91e87c64f757fb1c20f43a0a30db3c73073625.tar.gz |
Implement WebSocket close notify.
Diffstat (limited to 'modules/websocket/websocket_client.cpp')
-rw-r--r-- | modules/websocket/websocket_client.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/modules/websocket/websocket_client.cpp b/modules/websocket/websocket_client.cpp index 7701163085..8211a7c361 100644 --- a/modules/websocket/websocket_client.cpp +++ b/modules/websocket/websocket_client.cpp @@ -107,6 +107,11 @@ void WebSocketClient::_on_connect(String p_protocol) { } } +void WebSocketClient::_on_close_request(int p_code, String p_reason) { + + emit_signal("server_close_request", p_code, p_reason); +} + void WebSocketClient::_on_disconnect() { if (_is_multiplayer) { @@ -127,7 +132,7 @@ void WebSocketClient::_on_error() { void WebSocketClient::_bind_methods() { ClassDB::bind_method(D_METHOD("connect_to_url", "url", "protocols", "gd_mp_api"), &WebSocketClient::connect_to_url, DEFVAL(PoolVector<String>()), DEFVAL(false)); - ClassDB::bind_method(D_METHOD("disconnect_from_host"), &WebSocketClient::disconnect_from_host); + ClassDB::bind_method(D_METHOD("disconnect_from_host", "code", "reason"), &WebSocketClient::disconnect_from_host, DEFVAL(1000), DEFVAL("")); ClassDB::bind_method(D_METHOD("set_verify_ssl_enabled", "enabled"), &WebSocketClient::set_verify_ssl_enabled); ClassDB::bind_method(D_METHOD("is_verify_ssl_enabled"), &WebSocketClient::is_verify_ssl_enabled); @@ -135,6 +140,7 @@ void WebSocketClient::_bind_methods() { ADD_SIGNAL(MethodInfo("data_received")); ADD_SIGNAL(MethodInfo("connection_established", PropertyInfo(Variant::STRING, "protocol"))); + ADD_SIGNAL(MethodInfo("server_close_request", PropertyInfo(Variant::INT, "code"), PropertyInfo(Variant::STRING, "reason"))); ADD_SIGNAL(MethodInfo("connection_closed")); ADD_SIGNAL(MethodInfo("connection_error")); } |