59 lines
2.0 KiB
C++
Executable File
59 lines
2.0 KiB
C++
Executable File
|
|
|
|
#include "websocket_interface_handler.h"
|
|
|
|
#include "Connection/connection_handler.h"
|
|
#include "Messages/message_handler.h"
|
|
#include "Messages/message_transmitter.h"
|
|
#include "dds_handler.h"
|
|
#include "exercise_manager.h"
|
|
|
|
namespace CombatNetRadio
|
|
{
|
|
namespace WebSocketInterface
|
|
{
|
|
|
|
WebSocketInterfaceHandler::WebSocketInterfaceHandler(ExerciseManager *exerciseManager)
|
|
: m_exerciseManager(exerciseManager)
|
|
, m_connectionHandler(nullptr)
|
|
, m_messageHandler(nullptr)
|
|
{
|
|
Q_ASSERT(exerciseManager);
|
|
}
|
|
|
|
WebSocketInterfaceHandler::~WebSocketInterfaceHandler()
|
|
{
|
|
delete m_connectionHandler;
|
|
delete m_messageHandler;
|
|
}
|
|
|
|
bool WebSocketInterfaceHandler::init()
|
|
{
|
|
Q_ASSERT(!m_connectionHandler);
|
|
|
|
m_connectionHandler = new Connection::ConnectionHandler;
|
|
|
|
QObject::connect(m_connectionHandler, &Connection::ConnectionHandler::newClientConnection, m_exerciseManager, &ExerciseManager::onNewClientConnection);
|
|
QObject::connect(m_connectionHandler, &Connection::ConnectionHandler::clientConnectionClosed, m_exerciseManager, &ExerciseManager::onClientConnectionClosed);
|
|
QObject::connect(m_connectionHandler, &Connection::ConnectionHandler::clearFrequencyPlanningStatus, m_exerciseManager, &ExerciseManager::onClearFrequencyPlanningStatus);
|
|
|
|
if (!m_connectionHandler->init())
|
|
{
|
|
ERROR_LOG(m_logger) << "Failed to initialise ConnectionHandler";
|
|
return false;
|
|
}
|
|
|
|
m_messageHandler = new Messages::MessageHandler(m_exerciseManager);
|
|
|
|
QObject::connect(m_connectionHandler, &Connection::ConnectionHandler::lastConnectionClosed, m_exerciseManager, &ExerciseManager::stopPositionsUpdate);
|
|
QObject::connect(m_connectionHandler, &Connection::ConnectionHandler::newTextMessageFromClient, m_messageHandler, &Messages::MessageHandler::onNewTextMessage);
|
|
QObject::connect(m_exerciseManager, &ExerciseManager::essentialsUpdate, m_connectionHandler, &Connection::ConnectionHandler::onUpdate);
|
|
QObject::connect(m_exerciseManager, &ExerciseManager::positionsUpdate, m_connectionHandler, &Connection::ConnectionHandler::onPositions);
|
|
|
|
return true;
|
|
}
|
|
|
|
}
|
|
|
|
}
|