updated with upstream, added subprotocol to client

This commit is contained in:
Bruno Tibério
2016-01-20 23:41:03 +00:00
parent ece771a275
commit 3e0b0bd377
3 changed files with 8 additions and 8 deletions

View File

@ -27,7 +27,7 @@
#include <Arduino.h> #include <Arduino.h>
//#define DEBUG_WEBSOCKETS(...) Serial1.printf( __VA_ARGS__ ) //#define DEBUG_WEBSOCKETS(...) Serial.printf( __VA_ARGS__ )
#ifndef DEBUG_WEBSOCKETS #ifndef DEBUG_WEBSOCKETS
#define DEBUG_WEBSOCKETS(...) #define DEBUG_WEBSOCKETS(...)

View File

@ -37,7 +37,7 @@ WebSocketsClient::~WebSocketsClient() {
/** /**
* calles to init the Websockets server * 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; _host = host;
_port = port; _port = port;
_fingerprint = ""; _fingerprint = "";
@ -55,7 +55,7 @@ void WebSocketsClient::begin(const char *host, uint16_t port, const char * url)
_client.cIsWebsocket = true; _client.cIsWebsocket = true;
_client.cKey = ""; _client.cKey = "";
_client.cAccept = ""; _client.cAccept = "";
_client.cProtocol = ""; _client.cProtocol = Protocol;
_client.cExtensions = ""; _client.cExtensions = "";
_client.cVersion = 0; _client.cVersion = 0;
@ -67,8 +67,8 @@ void WebSocketsClient::begin(const char *host, uint16_t port, const char * url)
#endif #endif
} }
void WebSocketsClient::begin(String host, uint16_t port, String url) { void WebSocketsClient::begin(String host, uint16_t port, String url, String Protocol) {
begin(host.c_str(), port, url.c_str()); begin(host.c_str(), port, url.c_str(), Protocol.c_str());
} }
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
@ -366,7 +366,7 @@ void WebSocketsClient::sendHeader(WSclient_t * client) {
"Connection: Upgrade\r\n" "Connection: Upgrade\r\n"
"User-Agent: arduino-WebSocket-Client\r\n" "User-Agent: arduino-WebSocket-Client\r\n"
"Sec-WebSocket-Version: 13\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"; "Sec-WebSocket-Key: " + client->cKey + "\r\n";
if(client->cExtensions.length() > 0) { if(client->cExtensions.length() > 0) {

View File

@ -36,8 +36,8 @@ class WebSocketsClient: private WebSockets {
WebSocketsClient(void); WebSocketsClient(void);
~WebSocketsClient(void); ~WebSocketsClient(void);
void begin(const char *host, uint16_t port, const char * 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 = "/"); void begin(String host, uint16_t port, String url = "/", String Protocol = "arduino");
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
void beginSSL(const char *host, uint16_t port, const char * url = "/", const char * = ""); void beginSSL(const char *host, uint16_t port, const char * url = "/", const char * = "");