From 3e0b0bd377c56117716c162773ae9cbc53bb066b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Tib=C3=A9rio?= Date: Wed, 20 Jan 2016 23:41:03 +0000 Subject: [PATCH] updated with upstream, added subprotocol to client --- src/WebSockets.h | 2 +- src/WebSocketsClient.cpp | 10 +++++----- src/WebSocketsClient.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/WebSockets.h b/src/WebSockets.h index ffccf80..31a7db5 100644 --- a/src/WebSockets.h +++ b/src/WebSockets.h @@ -27,7 +27,7 @@ #include -//#define DEBUG_WEBSOCKETS(...) Serial1.printf( __VA_ARGS__ ) +//#define DEBUG_WEBSOCKETS(...) Serial.printf( __VA_ARGS__ ) #ifndef DEBUG_WEBSOCKETS #define DEBUG_WEBSOCKETS(...) diff --git a/src/WebSocketsClient.cpp b/src/WebSocketsClient.cpp index 3a0a039..05d3755 100644 --- a/src/WebSocketsClient.cpp +++ b/src/WebSocketsClient.cpp @@ -37,7 +37,7 @@ WebSocketsClient::~WebSocketsClient() { /** * calles to init the Websockets server */ -void WebSocketsClient::begin(const char *host, uint16_t port, const char * url) { +void WebSocketsClient::begin(const char *host, uint16_t port, const char * url, const char * Protocol) { _host = host; _port = port; _fingerprint = ""; @@ -55,7 +55,7 @@ void WebSocketsClient::begin(const char *host, uint16_t port, const char * url) _client.cIsWebsocket = true; _client.cKey = ""; _client.cAccept = ""; - _client.cProtocol = ""; + _client.cProtocol = Protocol; _client.cExtensions = ""; _client.cVersion = 0; @@ -67,8 +67,8 @@ void WebSocketsClient::begin(const char *host, uint16_t port, const char * url) #endif } -void WebSocketsClient::begin(String host, uint16_t port, String url) { - begin(host.c_str(), port, url.c_str()); +void WebSocketsClient::begin(String host, uint16_t port, String url, String Protocol) { + begin(host.c_str(), port, url.c_str(), Protocol.c_str()); } #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) @@ -366,7 +366,7 @@ void WebSocketsClient::sendHeader(WSclient_t * client) { "Connection: Upgrade\r\n" "User-Agent: arduino-WebSocket-Client\r\n" "Sec-WebSocket-Version: 13\r\n" - "Sec-WebSocket-Protocol: arduino\r\n" + "Sec-WebSocket-Protocol:" + client->cProtocol +"\r\n" "Sec-WebSocket-Key: " + client->cKey + "\r\n"; if(client->cExtensions.length() > 0) { diff --git a/src/WebSocketsClient.h b/src/WebSocketsClient.h index 589a0d7..2ba2e49 100644 --- a/src/WebSocketsClient.h +++ b/src/WebSocketsClient.h @@ -36,8 +36,8 @@ class WebSocketsClient: private WebSockets { WebSocketsClient(void); ~WebSocketsClient(void); - void begin(const char *host, uint16_t port, const char * url = "/"); - void begin(String host, uint16_t port, String url = "/"); + void begin(const char *host, uint16_t port, const char * url = "/", const char * Protocol = "arduino"); + void begin(String host, uint16_t port, String url = "/", String Protocol = "arduino"); #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) void beginSSL(const char *host, uint16_t port, const char * url = "/", const char * = "");