1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Expose the resource name the client used to the websocket server

This information is exposed to the websocket server through the
client_connected-signal.

example.com/chat?id=10 gives the resource name "/chat?id=10"
This commit is contained in:
Meriipu
2020-06-17 08:14:58 +02:00
parent de83ee57e5
commit 1475f617a3
6 changed files with 26 additions and 21 deletions

View File

@@ -71,7 +71,7 @@ void WebSocketServer::_bind_methods() {
ADD_SIGNAL(MethodInfo("client_close_request", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::INT, "code"), PropertyInfo(Variant::STRING, "reason")));
ADD_SIGNAL(MethodInfo("client_disconnected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::BOOL, "was_clean_close")));
ADD_SIGNAL(MethodInfo("client_connected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "protocol")));
ADD_SIGNAL(MethodInfo("client_connected", PropertyInfo(Variant::INT, "id"), PropertyInfo(Variant::STRING, "protocol"), PropertyInfo(Variant::STRING, "resource_name")));
ADD_SIGNAL(MethodInfo("data_received", PropertyInfo(Variant::INT, "id")));
}
@@ -141,13 +141,13 @@ void WebSocketServer::_on_peer_packet(int32_t p_peer_id) {
}
}
void WebSocketServer::_on_connect(int32_t p_peer_id, String p_protocol) {
void WebSocketServer::_on_connect(int32_t p_peer_id, String p_protocol, String p_resource_name) {
if (_is_multiplayer) {
// Send add to clients
_send_add(p_peer_id);
emit_signal("peer_connected", p_peer_id);
} else {
emit_signal("client_connected", p_peer_id, p_protocol);
emit_signal("client_connected", p_peer_id, p_protocol, p_resource_name);
}
}