ping / pong support / fix bug in dispatching received message type

This commit is contained in:
Benjamin Sergeant 2018-10-25 14:40:58 -07:00
parent eae2f7d113
commit 208c693088
3 changed files with 19 additions and 2 deletions

View File

@ -70,6 +70,18 @@ namespace
<< str;
log(ss.str());
}
else if (messageType == ix::WebSocket_MessageType_Ping)
{
ss << "ws_connect: received ping message: "
<< str;
log(ss.str());
}
else if (messageType == ix::WebSocket_MessageType_Pong)
{
ss << "ws_connect: received pong message: "
<< str;
log(ss.str());
}
else if (messageType == ix::WebSocket_MessageType_Error)
{
ss << "Connection error: " << error.reason << std::endl;
@ -78,7 +90,7 @@ namespace
ss << "HTTP Status: " << error.http_status << std::endl;
log(ss.str());
}
else if (messageType == ix::WebSocket_MessageType_Pong)
else
{
ss << "Invalid ix::WebSocketMessageType";
log(ss.str());

View File

@ -1,4 +1,9 @@
#!/bin/sh
test -d build || {
mkdir -p build
cd build
cmake ..
}
(cd build ; make)
./build/ping_pong ws://localhost:5678

View File

@ -199,7 +199,7 @@ namespace ix {
} break;
}
_onMessageCallback(WebSocket_MessageType_Message, msg, WebSocketErrorInfo());
_onMessageCallback(webSocketMessageType, msg, WebSocketErrorInfo());
WebSocket::invokeTrafficTrackerCallback(msg.size(), true);
});