Adds immediate migration results in progress
This commit is contained in:
2102 files changed
+17482
-15071
No files matched your search
+14
-15
@@ -15,12 +15,11 @@
|
||||
namespace HighLevelArchitecture
|
||||
{
|
||||
|
||||
WebSocketHandler::WebSocketHandler(int exerciseId, MainHandler *mainHandler, QObject *parent)
|
||||
: QObject(parent)
|
||||
WebSocketHandler::WebSocketHandler(int exerciseId, MainHandler *mainHandler, QObject *parent) : QObject(parent)
|
||||
, m_webSocketServer(new QWebSocketServer(QStringLiteral("WLS"), QWebSocketServer::NonSecureMode, this))
|
||||
, m_mainHandler(mainHandler)
|
||||
, m_exerciseId(exerciseId)
|
||||
{}
|
||||
, m_exerciseId(exerciseId),
|
||||
m_logger(NGL::NGLLoggerBootstrap::getLogger()) {}
|
||||
|
||||
WebSocketHandler::~WebSocketHandler()
|
||||
{
|
||||
@@ -32,7 +31,7 @@ bool WebSocketHandler::init(quint16 listenPort)
|
||||
{
|
||||
if (!m_webSocketServer->listen(QHostAddress::Any, listenPort))
|
||||
{
|
||||
WARNING_LOG() << "Can not listen on port " << listenPort << " - aborting";
|
||||
WARNING_LOG(m_logger) << "Can not listen on port " << listenPort << " - aborting";
|
||||
return false;
|
||||
}
|
||||
connect(m_webSocketServer, &QWebSocketServer::newConnection,
|
||||
@@ -51,7 +50,7 @@ bool WebSocketHandler::sendTelegramInternal(const TrainingAreaBase::TetraIcd::Tr
|
||||
|
||||
|
||||
const QString jsonStr = QString::fromUtf8(QJsonDocument(obj).toJson(QJsonDocument::Compact));
|
||||
DEBUG_LOG() << "jsonStr: " << jsonStr;
|
||||
DEBUG_LOG(m_logger) << "jsonStr: " << jsonStr;
|
||||
|
||||
bool bOk = false;
|
||||
for (const auto &wsw : std::as_const(m_webSockets))
|
||||
@@ -68,12 +67,12 @@ void WebSocketHandler::sendHlaConnectionState()
|
||||
TrainingAreaBase::TetraIcd::ProxyConnectionState connState;
|
||||
connState.connectedToSystem = m_mainHandler->isConnectedToHla();
|
||||
sendTelegram(&connState, m_exerciseId);
|
||||
DEBUG_LOG() << "sendHlaConnectionState, isConnected: " << connState.connectedToSystem;
|
||||
DEBUG_LOG(m_logger) << "sendHlaConnectionState, isConnected: " << connState.connectedToSystem;
|
||||
}
|
||||
|
||||
void WebSocketHandler::sendParticipantConnectionStates()
|
||||
{
|
||||
DEBUG_LOG() << "sendParticipantConnectionStates";
|
||||
DEBUG_LOG(m_logger) << "sendParticipantConnectionStates";
|
||||
TrainingAreaBase::TetraIcd::WlsParticipantsConnectionState partConnState;
|
||||
partConnState.equipmentNumber = -1;
|
||||
partConnState.dataCommunicationPossible = false;
|
||||
@@ -81,7 +80,7 @@ void WebSocketHandler::sendParticipantConnectionStates()
|
||||
|
||||
if (!m_mainHandler->isConnectedToHla())
|
||||
{
|
||||
INFO_LOG() << "We are (not) yet connected to HLA - don't send participant connection states";
|
||||
INFO_LOG(m_logger) << "We are (not) yet connected to HLA - don't send participant connection states";
|
||||
return;
|
||||
}
|
||||
const auto externalEquipmentNumbers = m_mainHandler->ngsHandler()->ppmHandler()->externalEquipmentNumbers();
|
||||
@@ -117,7 +116,7 @@ void WebSocketHandler::onNewConnection()
|
||||
QWebSocket *ws = m_webSocketServer->nextPendingConnection();
|
||||
if (!ws)
|
||||
return;
|
||||
DEBUG_LOG() << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
|
||||
DEBUG_LOG(m_logger) << "New websocket connection from " << ws->peerAddress().toString() << ":" << ws->peerPort();
|
||||
auto wsw = std::make_shared<WebSocketWrapper>(ws);
|
||||
|
||||
connect(wsw.get(), &WebSocketWrapper::textMessageReceived,
|
||||
@@ -132,11 +131,11 @@ void WebSocketHandler::onTextMessageReceived(const QByteArray &baJson)
|
||||
{
|
||||
using namespace TrainingAreaBase::TetraIcd;
|
||||
|
||||
TRACE_LOG() << "WebSocketHandler::onTextMessageReceived: " << baJson;
|
||||
TRACE_LOG(m_logger) << "WebSocketHandler::onTextMessageReceived: " << baJson;
|
||||
WebSocketWrapper *wsw = qobject_cast<WebSocketWrapper *>(sender());
|
||||
if (!wsw)
|
||||
{
|
||||
ERROR_LOG() << "Internal error - sender is no WebSocketWrapper";
|
||||
ERROR_LOG(m_logger) << "Internal error - sender is no WebSocketWrapper";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -156,7 +155,7 @@ void WebSocketHandler::onTextMessageReceived(const QByteArray &baJson)
|
||||
const QJsonValue typeId = obj.value(QStringLiteral("typeId"));
|
||||
if (!typeId.isDouble())
|
||||
{
|
||||
ERROR_LOG() << "Can not read type id: " << baJson;
|
||||
ERROR_LOG(m_logger) << "Can not read type id: " << baJson;
|
||||
return;
|
||||
}
|
||||
const QJsonObject data = obj.value(QStringLiteral("data")).toObject();
|
||||
@@ -185,14 +184,14 @@ void WebSocketHandler::onTextMessageReceived(const QByteArray &baJson)
|
||||
emit vulnerabilityStateRequest(DemandVulnerabilityStateChange::fromJson(data));
|
||||
break;
|
||||
default:
|
||||
WARNING_LOG() << "Handler for telegram Id " << typeId.toInt()
|
||||
WARNING_LOG(m_logger) << "Handler for telegram Id " << typeId.toInt()
|
||||
<< " not yet implemented (" << baJson << ")";
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (const std::exception &e)
|
||||
{
|
||||
WARNING_LOG() << "Could not parse json: " << e.what() << " (" << baJson << ")";
|
||||
WARNING_LOG(m_logger) << "Could not parse json: " << e.what() << " (" << baJson << ")";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user