minor refactoring

This commit is contained in:
Benjamin Sergeant 2020-03-18 11:45:28 -07:00
parent 696d802703
commit 6085839ef7
3 changed files with 14 additions and 7 deletions

View File

@ -203,7 +203,11 @@ namespace ix
WebSocketOpenInfo(status.uri, status.headers, status.protocol),
WebSocketCloseInfo()));
_ws.sendHeartBeat();
if (_pingIntervalSecs > 0)
{
// Send a heart beat right away
_ws.sendHeartBeat();
}
return status;
}
@ -232,7 +236,11 @@ namespace ix
WebSocketOpenInfo(status.uri, status.headers),
WebSocketCloseInfo()));
_ws.sendHeartBeat();
if (_pingIntervalSecs > 0)
{
// Send a heart beat right away
_ws.sendHeartBeat();
}
return status;
}

View File

@ -215,14 +215,12 @@ namespace ix
return now - _lastSendPingTimePoint > std::chrono::seconds(_pingIntervalSecs);
}
void WebSocketTransport::sendHeartBeat()
WebSocketSendInfo WebSocketTransport::sendHeartBeat()
{
if (_pingIntervalSecs <= 0) return;
_pongReceived = false;
std::stringstream ss;
ss << kPingMessage << "::" << _pingIntervalSecs << "s";
sendPing(ss.str());
return sendPing(ss.str());
}
bool WebSocketTransport::closingDelayExceeded()

View File

@ -105,7 +105,8 @@ namespace ix
void dispatch(PollResult pollResult, const OnMessageCallback& onMessageCallback);
size_t bufferedAmount() const;
void sendHeartBeat();
// internal
WebSocketSendInfo sendHeartBeat();
private:
std::string _url;