|
@ -14,6 +14,7 @@ void IflytopFrontEndService::initialize(string ip) { |
|
|
m_workQueue->startWork(); |
|
|
m_workQueue->startWork(); |
|
|
|
|
|
|
|
|
m_server.reset(new WebSocketServer(19001, ip)); |
|
|
m_server.reset(new WebSocketServer(19001, ip)); |
|
|
|
|
|
m_server->enablePong(); |
|
|
SocketTLSOptions tlsOptions; |
|
|
SocketTLSOptions tlsOptions; |
|
|
// tlsOptions.tls = true;
|
|
|
// tlsOptions.tls = true;
|
|
|
m_server->setTLSOptions(tlsOptions); |
|
|
m_server->setTLSOptions(tlsOptions); |
|
@ -74,18 +75,25 @@ void IflytopFrontEndService::sendReport(json reportType, json report) { |
|
|
report["messageId"] = UUID().toString(); |
|
|
report["messageId"] = UUID().toString(); |
|
|
report["messageType"] = "Report"; |
|
|
report["messageType"] = "Report"; |
|
|
report["reportType"] = reportType; |
|
|
report["reportType"] = reportType; |
|
|
logger->debug("uplink msg: {}", report.dump()); |
|
|
|
|
|
|
|
|
|
|
|
auto clients = m_reportServer->getClients(); |
|
|
|
|
|
for (auto& each : clients) { |
|
|
|
|
|
each->sendText(report.dump()); |
|
|
|
|
|
} |
|
|
|
|
|
auto serverClients = m_server->getClients(); |
|
|
auto serverClients = m_server->getClients(); |
|
|
|
|
|
if (serverClients.size() != 0) { |
|
|
|
|
|
logger->debug(""); |
|
|
|
|
|
} |
|
|
for (auto& each : serverClients) { |
|
|
for (auto& each : serverClients) { |
|
|
if (each) { |
|
|
if (each) { |
|
|
each->sendText(report.dump()); |
|
|
|
|
|
|
|
|
logger->debug("send msg to clientId:{}", each->getUrl()); |
|
|
|
|
|
auto result = each->sendText(report.dump()); |
|
|
|
|
|
if (!result.success) { |
|
|
|
|
|
logger->debug("send failed,clientId:{},error:{}", each->getUrl(), result.compressionError); |
|
|
|
|
|
} else { |
|
|
|
|
|
logger->debug("send success,clientId:{},payloadSize:{},wireSize:{}", each->getUrl(), result.payloadSize, result.wireSize); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (serverClients.size() != 0) { |
|
|
|
|
|
logger->debug(""); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void IflytopFrontEndService::sendClassReport(string fromclass, string fromfn, const json& rely) { |
|
|
void IflytopFrontEndService::sendClassReport(string fromclass, string fromfn, const json& rely) { |
|
@ -103,6 +111,9 @@ void IflytopFrontEndService::sendClassReport(string fromclass, string fromfn, co |
|
|
// }
|
|
|
// }
|
|
|
|
|
|
|
|
|
void IflytopFrontEndService::onMessageCallback(weak_ptr<WebSocket> webSocket, shared_ptr<ConnectionState> connectionState, const ix::WebSocketMessagePtr& msg) { |
|
|
void IflytopFrontEndService::onMessageCallback(weak_ptr<WebSocket> webSocket, shared_ptr<ConnectionState> connectionState, const ix::WebSocketMessagePtr& msg) { |
|
|
|
|
|
auto ws = webSocket.lock(); |
|
|
|
|
|
if (!ws) return; |
|
|
|
|
|
|
|
|
if (msg->type == ix::WebSocketMessageType::Open) { |
|
|
if (msg->type == ix::WebSocketMessageType::Open) { |
|
|
logger->info("New connection"); |
|
|
logger->info("New connection"); |
|
|
logger->info("id : {}", connectionState->getId()); |
|
|
logger->info("id : {}", connectionState->getId()); |
|
@ -111,6 +122,9 @@ void IflytopFrontEndService::onMessageCallback(weak_ptr<WebSocket> webSocket, sh |
|
|
for (auto it : msg->openInfo.headers) { |
|
|
for (auto it : msg->openInfo.headers) { |
|
|
logger->info(" {}: {}", it.first, it.second); |
|
|
logger->info(" {}: {}", it.first, it.second); |
|
|
} |
|
|
} |
|
|
|
|
|
// ws->setPingInterval(2);
|
|
|
|
|
|
ws->enablePong(); |
|
|
|
|
|
ws->setUrl(fmt::format("{}:{}", connectionState->getRemoteIp(), connectionState->getRemotePort())); |
|
|
|
|
|
|
|
|
} else if (msg->type == ix::WebSocketMessageType::Message) { |
|
|
} else if (msg->type == ix::WebSocketMessageType::Message) { |
|
|
logger->debug("downlink msg: {}", msg->str); |
|
|
logger->debug("downlink msg: {}", msg->str); |
|
|