timum-viw / socket.io-client

A socket.io-client implementation for ESP8266 and Arduino
228 stars 90 forks source link

setExtraHeaders support #71

Closed gilphilbert closed 3 years ago

gilphilbert commented 4 years ago

Add support for extraHeaders.

Useful for connecting to SocketIO servers that use session-based authentication (i.e., the SocketIO authentication comes from a shared server framework)

Usage:

...
#include <WebSocketsClient.h>
#include <SocketIoClient.h>

SocketIoClient webSocket;
...
void setup() {
  // get token, etc., deliminate headers with \n
  char* headers = "Origin: https://someplace.com\n Cookie: SESSION=1234";
  ...
  webSocket.on("event", eventHandler);
  webSocket.setExtraHeaders(headers);
  webSocket.beginSSL("my.server.com", 443, "/socket.io/?transport=websocket", rootFingerprint);
}
gilphilbert commented 3 years ago

Disappointing, any reason for not merging this?

timum-viw commented 3 years ago

Hey there, sorry, but I found that this library is actually deprecated since the underlying library WebSockets already supports a SocketIO client. Please just use that one and set the headers directly in there 🙂