From 7117c741429227f0b26eea5cb38e95045b422d03 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Wed, 31 Oct 2018 10:27:17 -0700 Subject: [PATCH] add stop and start directives to ws_connect + display close info --- examples/ws_connect/ws_connect.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/examples/ws_connect/ws_connect.cpp b/examples/ws_connect/ws_connect.cpp index dfb78505..d5c0692c 100644 --- a/examples/ws_connect/ws_connect.cpp +++ b/examples/ws_connect/ws_connect.cpp @@ -65,7 +65,10 @@ namespace } else if (messageType == ix::WebSocket_MessageType_Close) { - log("ws_connect: disconnected"); + ss << "ws_connect: connection closed:"; + ss << " code " << closeInfo.code; + ss << " reason " << closeInfo.reason << std::endl; + log(ss.str()); } else if (messageType == ix::WebSocket_MessageType_Message) { @@ -108,6 +111,20 @@ namespace std::cout << "> " << std::flush; std::getline(std::cin, text); + if (text == "/stop") + { + std::cout << "Stopping connection..." << std::endl; + webSocketChat.stop(); + continue; + } + + if (text == "/start") + { + std::cout << "Starting connection..." << std::endl; + webSocketChat.start(); + continue; + } + if (!std::cin) { break;