mirror of
https://github.com/Telecominfraproject/wlan-cloud-owls.git
synced 2026-01-27 10:22:52 +00:00
37 lines
1.3 KiB
C++
37 lines
1.3 KiB
C++
//
|
|
// Created by stephane bourque on 2023-04-12.
|
|
//
|
|
#include <Poco/NObserver.h>
|
|
|
|
#include "OWLSclient.h"
|
|
#include "SimulationRunner.h"
|
|
#include "SimStats.h"
|
|
#include "OWLSclientEvents.h"
|
|
|
|
namespace OpenWifi::OWLSClientEvents {
|
|
|
|
void WSPing(const std::shared_ptr<OWLSclient> &Client, SimulationRunner *Runner) {
|
|
if(!Runner->Running()) {
|
|
return;
|
|
}
|
|
std::lock_guard<std::mutex> ClientGuard(Client->Mutex_);
|
|
if(Client->Valid_ && Client->Connected_) {
|
|
Runner->Report().ev_wsping++;
|
|
try {
|
|
Client->WS_->sendFrame(
|
|
"", 0, Poco::Net::WebSocket::FRAME_OP_PING | Poco::Net::WebSocket::FRAME_FLAG_FIN);
|
|
Runner->Scheduler().in(std::chrono::seconds(60 * 3),
|
|
OWLSClientEvents::WSPing, Client, Runner);
|
|
return;
|
|
} catch (const Poco::Exception &E) {
|
|
std::cout << "WSPing failed; " << Client->SerialNumber_ << " - : " << E.message() << std::endl;
|
|
DEBUG_LINE("exception1");
|
|
Client->Logger().log(E);
|
|
} catch (const std::exception &E) {
|
|
DEBUG_LINE("exception2");
|
|
}
|
|
OWLSClientEvents::Disconnect(__func__, ClientGuard, Client, Runner, "Error in WSPing", true);
|
|
}
|
|
}
|
|
|
|
} |