echo_server now checks for a special command to stop listening for new connections

This commit is contained in:
Peter Thorson committed 2015-04-14 08:14:47 -04:00
1 parent d076e38e00
commit 2c843b9343
1 file changed
+7
+7
View File
@@ -19,6 +19,13 @@ void on_message(server* s, websocketpp::connection_hdl hdl, message_ptr msg) {
<< " and message: " << msg->get_payload()
<< std::endl;
// check for a special command to instruct the server to stop listening so
// it can be cleanly exited.
if (msg->get_payload() == "stop-listening") {
s->stop_listening();
return;
}
try {
s->send(hdl, msg->get_payload(), msg->get_opcode());
} catch (const websocketpp::lib::error_code& e) {