Skip to content

Commit 6cbcca7

Browse files
committed
add getUrl method
1 parent 6eee4c6 commit 6cbcca7

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/WebSocketsClient.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,14 @@ bool WebSocketsClient::isConnected(void) {
478478
return (_client.status == WSC_CONNECTED);
479479
}
480480

481+
/**
482+
* RFC 6455
483+
* get the full URL/URI of the connection
484+
*/
485+
String WebSocketsClient::getUrl(void) {
486+
return ((_client.isSSL) ? WEBSOCKETS_STRING("wss://") : WEBSOCKETS_STRING("ws://")) + _host + ":" + String(_port) + _client.cUrl;
487+
}
488+
481489
// #################################################################################
482490
// #################################################################################
483491
// #################################################################################

src/WebSocketsClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class WebSocketsClient : protected WebSockets {
112112
void disableHeartbeat();
113113

114114
bool isConnected(void);
115+
String getUrl(void);
115116

116117
protected:
117118
String _host;

0 commit comments

Comments
 (0)