add getUrl method (#955)

This commit is contained in:
Razvan Grigore
2025-10-17 18:22:47 +03:00
committed by GitHub
parent 3af6593a00
commit 6801736f98
2 changed files with 14 additions and 0 deletions

View File

@@ -478,6 +478,19 @@ bool WebSocketsClient::isConnected(void) {
return (_client.status == WSC_CONNECTED);
}
/**
* RFC 6455
* get the full URL/URI of the connection
*/
String WebSocketsClient::getUrl(void) {
#if defined(HAS_SSL)
String protocol = (_client.isSSL) ? WEBSOCKETS_STRING("wss://") : WEBSOCKETS_STRING("ws://");
#else
String protocol = WEBSOCKETS_STRING("ws://");
#endif
return protocol + _host + ":" + String(_port) + _client.cUrl;
}
// #################################################################################
// #################################################################################
// #################################################################################

View File

@@ -112,6 +112,7 @@ class WebSocketsClient : protected WebSockets {
void disableHeartbeat();
bool isConnected(void);
String getUrl(void);
protected:
String _host;