Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socketIO for low level programming Board #1535

Open
yash2020 opened this issue Mar 25, 2022 · 0 comments
Open

socketIO for low level programming Board #1535

yash2020 opened this issue Mar 25, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@yash2020
Copy link

yash2020 commented Mar 25, 2022

hi, i am try to connect the socketIO server v4 using Arduino and building library for socketIO at low level communication. but i did't find the work flow of client and server handshake and hard to connect to socketIO server using Arduino
boards list:
Arduino UNO + EthernetShield For ENC28J60 or W5100
Arduino + WifiShield For ESP8266 or ESP32

Following code to rebuilt:
#include "Arduino.h"

#if defined(W5100)
#include <Ethernet.h>
#include "SPI.h" //For W5100
#elif defined(ENC28J60)
#include <UIPEthernet.h>
#include "SPI.h" //For ENC28J60
#elif defined(ESP8266)
#include <ESP8266WiFi.h> //For ESP8266
#elif defined(ESP32)
#include <WiFi.h> //For ESP32
#elif (!defined(ESP32) && !defined(ESP8266) && !defined(W5100) && !defined(ENC28J60)) //If no interface is defined
#error "Please specify an interface such as W5100, ENC28J60, ESP8266 or ESP32"
#error "above your includes like so : #define ESP8266 "
#endif

// Length of static data buffers
#define DATA_BUFFER_LEN 120
#define SID_LEN 24

class SocketIOClient {
public:
bool connect(char hostname[], int port = 80, char query[] = "");
bool connectHTTP(char hostname[], int port = 80);
bool connected();
void disconnect();
bool reconnect(char hostname[], int port = 80, char query[] = "");
bool monitor();
void sendMessage(String message = "");
void send(String RID, String Rname, String Rcontent);
void sendNSP();
void sendJSON(String RID, String JSON);
void heartbeat(int select);
void clear();
void getREST(String path);
void postREST(String path, String type, String data);
void putREST(String path, String type, String data);
void deleteREST(String path);
private:
void parser(int index);
void sendHandshake(char hostname[], char query[] = "");
#if defined(W5100) || defined(ENC28J60)
EthernetClient client; //For ENC28J60 or W5100
#endif
#if defined(ESP8266) || defined(ESP32)
WiFiClient client; //For ESP8266 or ESP32
#endif

bool readHandshake();
void readLine();
char *dataptr;
char databuffer[DATA_BUFFER_LEN];
char sid[SID_LEN];
char key[28];
int pingInterval;
int pingTimeout;
char *upgrades;

char *hostname;
char *query;
char *nsp;
int port;

void findColon(char which);
void terminateCommand(void);
bool waitForInput(void);
void eatHeader(void);

};

@yash2020 yash2020 added the enhancement New feature or request label Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant