Skip to content

Commit

Permalink
HttpServer: Wait 1 second before calling server.shutdown() (#1598)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikee47 authored and slaff committed Feb 6, 2019
1 parent fa42205 commit c8eb167
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion samples/HttpServer_WebSockets/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ void wsMessageReceived(WebsocketConnection& socket, const String& message)
if(message == "shutdown") {
String message = "The server is shutting down...";
socket.broadcast(message.c_str(), message.length());
server.shutdown();

// Don't shutdown immediately, wait a bit to allow messages to propagate
auto timer = new SimpleTimer;
timer->setCallback(
[](void* timer) {
delete static_cast<SimpleTimer*>(timer);
server.shutdown();
},
timer);
timer->startMs(1000);
return;
}

Expand Down

0 comments on commit c8eb167

Please sign in to comment.