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

How to set server to non-blocking while in main loop ? #41

Closed
denden4444 opened this issue Oct 7, 2019 · 1 comment
Closed

How to set server to non-blocking while in main loop ? #41

denden4444 opened this issue Oct 7, 2019 · 1 comment

Comments

@denden4444
Copy link

denden4444 commented Oct 7, 2019

Hi Gil

How do you set the server to be non-blocking in the main loop , in other words to allow other code/functions to run ?
For example I have the following :

void loop() {

  server.handleClient();                      // run the web server
  //websockets server
  WebsocketsClient client = wsserver.accept();
  if (client.available()) {
    WebsocketsMessage msg = client.readBlocking();

    // log
    Serial.print("Got Message: ");
    Serial.println(msg.data());
  }

  // return echo
  client.send("Echo: " + msg.data());

  // close the connection
  client.close();
}//endof if client.available


//end of webSocket Server

SOME_OTHER_FUNCTION();
SOME_OTHER_FUNCTION_TWO();
//etc
//start from beginning of loop again
}

Look forward to your reply as always :-)

Den

@gilmaimon
Copy link
Owner

Hi Den...

  1. Please read my comment here webSockets client and server on same ESP ? #35 (comment)
  2. It's in the docs (Wiki)

Lets keep all of your question in a single thread or in some other medium.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants