|
@ -154,9 +154,9 @@ void IflytopFrontEndService::onMessageCallback(weak_ptr<WebSocket> webSocket, sh |
|
|
logger->error(" Wait time(ms) : {}", msg->errorInfo.wait_time); |
|
|
logger->error(" Wait time(ms) : {}", msg->errorInfo.wait_time); |
|
|
logger->error(" HTTP Status : {}", msg->errorInfo.http_status); |
|
|
logger->error(" HTTP Status : {}", msg->errorInfo.http_status); |
|
|
} else if (msg->type == ix::WebSocketMessageType::Ping) { |
|
|
} else if (msg->type == ix::WebSocketMessageType::Ping) { |
|
|
logger->debug("WebSocket ping received"); |
|
|
|
|
|
|
|
|
logger->info("WebSocket ping received"); |
|
|
} else if (msg->type == ix::WebSocketMessageType::Pong) { |
|
|
} else if (msg->type == ix::WebSocketMessageType::Pong) { |
|
|
logger->debug("WebSocket pong received"); |
|
|
|
|
|
|
|
|
logger->info("WebSocket pong received"); |
|
|
} else { |
|
|
} else { |
|
|
logger->warn("Unknown WebSocket message type: {}", static_cast<int>(msg->type)); |
|
|
logger->warn("Unknown WebSocket message type: {}", static_cast<int>(msg->type)); |
|
|
} |
|
|
} |
|
@ -165,6 +165,10 @@ void IflytopFrontEndService::processRxMessage(weak_ptr<WebSocket> webSocket, str |
|
|
string msgtext = rxmsg; |
|
|
string msgtext = rxmsg; |
|
|
json message; |
|
|
json message; |
|
|
|
|
|
|
|
|
|
|
|
if (rxmsg == "{\"type\":\"ping\"}") { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
shared_ptr<WebSocket> ws = webSocket.lock(); |
|
|
shared_ptr<WebSocket> ws = webSocket.lock(); |
|
|
if (!ws) { |
|
|
if (!ws) { |
|
@ -174,13 +178,22 @@ void IflytopFrontEndService::processRxMessage(weak_ptr<WebSocket> webSocket, str |
|
|
|
|
|
|
|
|
json command = json::parse(msgtext); |
|
|
json command = json::parse(msgtext); |
|
|
json receipt; |
|
|
json receipt; |
|
|
receipt["messageId"] = command["messageId"]; |
|
|
|
|
|
receipt["ackcode"] = 0; |
|
|
|
|
|
receipt["messageType"] = "Ack"; |
|
|
|
|
|
receipt["timeStamp"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
onMessage(webSocket, command, receipt); |
|
|
|
|
|
ws->sendText(receipt.dump(1)); |
|
|
|
|
|
|
|
|
if (command["messageType"] == "Ping") { |
|
|
|
|
|
receipt["messageType"] = "Pong"; |
|
|
|
|
|
receipt["messageId"] = command["messageId"]; |
|
|
|
|
|
receipt["timeStamp"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); |
|
|
|
|
|
ws->sendText(receipt.dump()); |
|
|
|
|
|
} else { |
|
|
|
|
|
receipt["messageId"] = command["messageId"]; |
|
|
|
|
|
receipt["ackcode"] = 0; |
|
|
|
|
|
receipt["messageType"] = "Ack"; |
|
|
|
|
|
receipt["timeStamp"] = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count(); |
|
|
|
|
|
onMessage(webSocket, command, receipt); |
|
|
|
|
|
ws->sendText(receipt.dump(1)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} catch (const detail::parse_error& e) { |
|
|
} catch (const detail::parse_error& e) { |
|
|
// json parse error
|
|
|
// json parse error
|
|
|
logger->error("process rx json failed,exception:{},{}", e.what(), msgtext); |
|
|
logger->error("process rx json failed,exception:{},{}", e.what(), msgtext); |
|
|