|
|
@ -68,7 +68,9 @@ void IflytopFrontEndService::sendReport(json& report) { |
|
|
|
* @brief 广播消息给所有连接的客户端 |
|
|
|
*/ |
|
|
|
|
|
|
|
report["timeStamp"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); |
|
|
|
report["timeStamp"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); |
|
|
|
report["messageId"] = UUID().toString(); |
|
|
|
report["messageType"] = "Report"; |
|
|
|
logger->debug("uplink msg: {}", report.dump()); |
|
|
|
|
|
|
|
auto clients = m_reportServer->getClients(); |
|
|
@ -77,6 +79,12 @@ void IflytopFrontEndService::sendReport(json& report) { |
|
|
|
each->sendText(report.dump()); |
|
|
|
} |
|
|
|
} |
|
|
|
auto serverClients = m_server->getClients(); |
|
|
|
for (auto& each : serverClients) { |
|
|
|
if (each) { |
|
|
|
each->sendText(report.dump()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void IflytopFrontEndService::onMessageCallback(weak_ptr<WebSocket> webSocket, shared_ptr<ConnectionState> connectionState, const ix::WebSocketMessagePtr& msg) { |
|
|
@ -120,9 +128,10 @@ void IflytopFrontEndService::processRxMessage(weak_ptr<WebSocket> webSocket, str |
|
|
|
|
|
|
|
json command = json::parse(msgtext); |
|
|
|
json receipt; |
|
|
|
receipt["messageId"] = command["messageId"]; |
|
|
|
receipt["ackcode"] = 0; |
|
|
|
receipt["timeStamp"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); |
|
|
|
receipt["messageId"] = command["messageId"]; |
|
|
|
receipt["ackcode"] = 0; |
|
|
|
receipt["messageType"] = "Ack"; |
|
|
|
receipt["timeStamp"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); |
|
|
|
try { |
|
|
|
onMessage(webSocket, command, receipt); |
|
|
|
ws->sendText(receipt.dump(1)); |
|
|
@ -163,7 +172,6 @@ void IflytopFrontEndService::processRxMessage(weak_ptr<WebSocket> webSocket, str |
|
|
|
ws->sendText(receipt.dump(1)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (const std::exception& e) { |
|
|
|
logger->error("m_iflytopWSService:onMessag,parse json failed,exception:{},{}", e.what(), msgtext); |
|
|
|
return; |
|
|
|