mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-07-12 06:56:30 +02:00
add IPAddress remoteIP(uint8_t num)
update example
This commit is contained in:
@ -200,7 +200,7 @@ void WebSocketsServer::disconnect(void) {
|
||||
|
||||
/**
|
||||
* disconnect one client
|
||||
* @param num
|
||||
* @param num uint8_t client id
|
||||
*/
|
||||
void WebSocketsServer::disconnect(uint8_t num) {
|
||||
if(num >= WEBSOCKETS_SERVER_CLIENT_MAX) {
|
||||
@ -212,6 +212,22 @@ void WebSocketsServer::disconnect(uint8_t num) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get an IP for a client
|
||||
* @param num uint8_t client id
|
||||
* @return IPAddress
|
||||
*/
|
||||
IPAddress WebSocketsServer::remoteIP(uint8_t num) {
|
||||
if(num < WEBSOCKETS_SERVER_CLIENT_MAX) {
|
||||
WSclient_t * client = &_clients[num];
|
||||
if(clientIsConnected(client)) {
|
||||
return client->tcp.remoteIP();
|
||||
}
|
||||
}
|
||||
|
||||
return IPAddress();
|
||||
}
|
||||
|
||||
//#################################################################################
|
||||
//#################################################################################
|
||||
//#################################################################################
|
||||
|
Reference in New Issue
Block a user