Skip to content

Commit

Permalink
pingpong
Browse files Browse the repository at this point in the history
  • Loading branch information
abhaybd committed Aug 12, 2023
1 parent 1251fab commit 2cf43b5
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/network/websocket/WebSocketServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ SingleClientWSServer::SingleClientWSServer(const std::string& serverName, uint16
[&](connection_hdl hdl, message_t msg) { this->onMessage(hdl, msg); });
server.set_pong_timeout_handler(
[&](connection_hdl hdl, std::string payload) { this->onPongTimeout(hdl, payload); });
server.set_pong_handler([](connection_hdl, std::string s) { log(LOG_INFO, "Pong from %s\n", s.c_str());});
}

SingleClientWSServer::~SingleClientWSServer() {
Expand Down Expand Up @@ -87,6 +88,7 @@ bool SingleClientWSServer::addProtocol(std::unique_ptr<WebSocketProtocol> protoc
auto eventID = pingScheduler.scheduleEvent(pongInfo->first / 2, [this, path]() {
const auto& pd = this->protocolMap.at(path);
if (pd.client.has_value()) {
log(LOG_INFO, "Ping!\n");
server.ping(pd.client.value(), path);
}
});
Expand Down

0 comments on commit 2cf43b5

Please sign in to comment.