mirror of
https://github.com/Links2004/arduinoWebSockets.git
synced 2025-12-22 23:13:00 +01:00
add getUrl method (#955)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
// #################################################################################
|
||||
// #################################################################################
|
||||
// #################################################################################
|
||||
|
||||
@@ -112,6 +112,7 @@ class WebSocketsClient : protected WebSockets {
|
||||
void disableHeartbeat();
|
||||
|
||||
bool isConnected(void);
|
||||
String getUrl(void);
|
||||
|
||||
protected:
|
||||
String _host;
|
||||
|
||||
Reference in New Issue
Block a user