Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/WebSocketsClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

// #################################################################################
// #################################################################################
// #################################################################################
Expand Down
1 change: 1 addition & 0 deletions src/WebSocketsClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class WebSocketsClient : protected WebSockets {
void disableHeartbeat();

bool isConnected(void);
String getUrl(void);

protected:
String _host;
Expand Down