mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-28 19:55:48 +03:00
refact1
This commit is contained in:
168
LibServer/Systems/commonclienthandler.cpp
Normal file
168
LibServer/Systems/commonclienthandler.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
#include "commonclienthandler.h"
|
||||
|
||||
CommonClientHandler::CommonClientHandler(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CommonClientHandler::initialize(QMap<int, ClientHandler *> *clientsMap, ProcessingSystem *processingSystem, DataParser *dataParser)
|
||||
{
|
||||
this->clientsMap = clientsMap;
|
||||
this->processingSystem = processingSystem;
|
||||
this->dataParser = dataParser;
|
||||
}
|
||||
|
||||
void CommonClientHandler::sendNewVersionListToAllClient()
|
||||
{
|
||||
foreach(int idSocket,clientsMap->keys())
|
||||
{
|
||||
ClientHandler *handler = clientsMap->value(idSocket);
|
||||
|
||||
if (!handler->getClient()->getIsLoggedIn()) continue;
|
||||
|
||||
handler->sendVersionList();
|
||||
}
|
||||
}
|
||||
|
||||
void CommonClientHandler::sendCurrentVersionToAllClient()
|
||||
{
|
||||
foreach(int idSocket,clientsMap->keys())
|
||||
{
|
||||
ClientHandler *handler = clientsMap->value(idSocket);
|
||||
|
||||
if (!handler->getClient()->getIsLoggedIn()) continue;
|
||||
handler->sendVersion();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CommonClientHandler::slot_ListsInstructorsTraineesChanged()
|
||||
{
|
||||
//Проходим все открытые сокеты
|
||||
foreach(int idSocket, clientsMap->keys())
|
||||
{
|
||||
ClientHandler *handler = clientsMap->value(idSocket);
|
||||
//Проверяем, есть ли клиенты TYPE_GUI
|
||||
if(handler->getClient()->getTypeClient() == TypeClientAutorization::TYPE_GUI)
|
||||
{//Отправляем этому клиенту обновление списков
|
||||
ClientQueryToDB queryToDB;
|
||||
queryToDB.typeQuery = TypeQueryToDB::TYPE_QUERY_GET_ALL_LISTS;
|
||||
processingSystem->processingClientQueryToDB(handler, queryToDB);
|
||||
}
|
||||
|
||||
if(handler->getClient()->getClientType() == TypeClientAutorization::TYPE_UNITY_CLIENT)
|
||||
{
|
||||
ClientQueryToDB queryToDB;
|
||||
queryToDB.typeQuery = TypeQueryToDB::TYPE_QUERY_GET_CONTACT_LIST;
|
||||
processingSystem->processingClientQueryToDB(handler, queryToDB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommonClientHandler::slot_StatusTasksAMMofTraineeChanged(int trainee_id)
|
||||
{
|
||||
//Проходим все открытые сокеты
|
||||
foreach(int idSocket, clientsMap->keys())
|
||||
{
|
||||
ClientHandler *handler = clientsMap->value(idSocket);
|
||||
//Проверяем, есть ли клиенты TYPE_GUI
|
||||
if(handler->getClient()->getTypeClient() == TypeClientAutorization::TYPE_GUI)
|
||||
{//Отправляем этому клиенту задачи AMM для Обучаемого (с измененным статусом)
|
||||
ClientQueryToDB queryToDB;
|
||||
queryToDB.typeQuery = TypeQueryToDB::TYPE_QUERY_GET_TASKS_AMM_FOR_TRAINEE;
|
||||
processingSystem->processingClientQueryToDB(handler, queryToDB, trainee_id);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//Отправка списка задач AMM клиенту Юнити
|
||||
if(ClientHandler* clientUnity = processingSystem->getUnityClientById(trainee_id))
|
||||
{//Есть такой
|
||||
//processingSystem->sendListTasksAMMofTraineetoClient(clientUnity, trainee_id);
|
||||
}*/
|
||||
}
|
||||
|
||||
void CommonClientHandler::slot_StatusTasksFIMofTraineeChanged(int trainee_id)
|
||||
{
|
||||
//Проходим все открытые сокеты
|
||||
foreach(int idSocket, clientsMap->keys())
|
||||
{
|
||||
ClientHandler *handler = clientsMap->value(idSocket);
|
||||
//Проверяем, есть ли клиенты TYPE_GUI
|
||||
if(handler->getClient()->getTypeClient() == TypeClientAutorization::TYPE_GUI)
|
||||
{//Отправляем этому клиенту задачи FIM для Обучаемого (с измененным статусом)
|
||||
ClientQueryToDB queryToDB;
|
||||
queryToDB.typeQuery = TypeQueryToDB::TYPE_QUERY_GET_TASKS_FIM_FOR_TRAINEE;
|
||||
processingSystem->processingClientQueryToDB(handler, queryToDB, trainee_id);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//Отправка списка задач FIM клиенту Юнити
|
||||
if(ClientHandler* clientUnity = processingSystem->getUnityClientById(trainee_id))
|
||||
{//Есть такой
|
||||
//processingSystem->sendListTasksFIMofTraineetoClient(clientUnity, trainee_id);
|
||||
}*/
|
||||
}
|
||||
|
||||
void CommonClientHandler::slot_sendPacketToAllClients(PacketType packetType)
|
||||
{
|
||||
foreach(int idSocket, clientsMap->keys())
|
||||
{
|
||||
ClientHandler *handler = clientsMap->value(idSocket);
|
||||
|
||||
if (!handler->getClient()->getIsLoggedIn()) continue;
|
||||
|
||||
handler->sendPacketType(packetType);
|
||||
Logger::instance().log("AllSending " + handler->getClient()->getLogin() + " " + enumToString(packetType));
|
||||
}
|
||||
|
||||
emit sigSetServerState(packetType);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CommonClientHandler::slot_sendTaskToClient(QString fullNameClient,QString textTask)
|
||||
{
|
||||
QByteArray byteArrayTask = dataParser->ClientAnswer()->task(textTask);
|
||||
|
||||
//Проходим все открытые сокеты
|
||||
foreach(int idSocket, clientsMap->keys())
|
||||
{
|
||||
ClientHandler *handler = clientsMap->value(idSocket);
|
||||
|
||||
if(handler->getClient()->getFullName() == fullNameClient)
|
||||
{//Отправляем ему
|
||||
handler->getSocket()->write(byteArrayTask);
|
||||
|
||||
QString peerAddress = handler->getSocket()->peerAddress().toString();
|
||||
QString peerPort = QString::number(handler->getSocket()->peerPort());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommonClientHandler::slot_DocsChanged()
|
||||
{
|
||||
//Проходим все открытые сокеты
|
||||
foreach(int idSocket, clientsMap->keys())
|
||||
{
|
||||
ClientHandler *handler = clientsMap->value(idSocket);
|
||||
|
||||
TypeClientAutorization type = handler->getClient()->getTypeClient();
|
||||
|
||||
//Отправляем всем заинтересованным клиентам оповещение об изменении docs.xml
|
||||
if(type == TypeClientAutorization::TYPE_GUI)
|
||||
{
|
||||
handler->sendPacketType(PacketType::TYPE_XMLANSWER_DOCS_CHANGED);
|
||||
}
|
||||
else if(type == TypeClientAutorization::TYPE_QT_CLIENT)
|
||||
{
|
||||
handler->sendPacketType(PacketType::TYPE_XMLANSWER_DOCS_CHANGED);
|
||||
}
|
||||
else if(type == TypeClientAutorization::TYPE_UNITY_CLIENT)
|
||||
{
|
||||
//handler->sendPacketType(PacketType::TYPE_XMLANSWER_DOCS_CHANGED); //Unity не обязательно!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user