-1

I have an application and a Node MCU which is coded using Arduino IDE. The connection is established using WebSocket and wifi. The application sends data that is to be received by NodeMCU. I have tried to implement the function OnEvent() and it gives an error telling that the function is not a member of WebSocketClient and also I am not sure if it works with the client i.e NodeMCU. How do I receive data using WebSocket and nodeMCU?

Pooja M A
  • 13
  • 2

1 Answers1

0

Can you post your code. it is not clear from here but still, I am giving you a brief example hope it helps

 WiFiClient client = server.available(); 
  if (client) {
  if (client.connected()) {
    delay(500);
  Serial.println("connected");
  String request = client.readStringUntil('\r');
  client.flush();
  client.println("Hello World");
      }
 client.stop();                         // disconnects the client
} 

Whenever posting the data to the server. first, the server will send the HTTP code connection String to the client till next line. that's why we are doing client.readStringUntil('\r'). after the check for next line, you can post whatever you want to the web server.

vaibhav sharma
  • 170
  • 1
  • 12