add stop and start directives to ws_connect + display close info

This commit is contained in:
Benjamin Sergeant 2018-10-31 10:27:17 -07:00
parent 5b333f91f6
commit 9c81eeace0

View File

@ -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;