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

Implement get_peer_[address|port] in ENet/WSServer

Also implement get_connected_host and get_connected_port in WebSocketPeer
(not supported in HTML5 due to browser limitation).
Add shorthand disconnect_peer(id) for get_peer(id)->close() like in ENet to
WebSocketServer.
This commit is contained in:
Fabio Alessandrelli
2018-04-10 17:52:10 +02:00
parent 23fc8ca223
commit 6b9ec810c6
11 changed files with 121 additions and 5 deletions

View File

@@ -164,6 +164,24 @@ Ref<WebSocketPeer> LWSServer::get_peer(int p_id) const {
return _peer_map[p_id];
}
IP_Address LWSServer::get_peer_address(int p_peer_id) const {
ERR_FAIL_COND_V(!has_peer(p_peer_id), IP_Address());
return _peer_map[p_peer_id]->get_connected_host();
}
int LWSServer::get_peer_port(int p_peer_id) const {
ERR_FAIL_COND_V(!has_peer(p_peer_id), 0);
return _peer_map[p_peer_id]->get_connected_port();
}
void LWSServer::disconnect_peer(int p_peer_id) {
ERR_FAIL_COND(!has_peer(p_peer_id));
get_peer(p_peer_id)->close();
}
LWSServer::LWSServer() {
context = NULL;
_lws_ref = NULL;