diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index ff3eb71..93fc9c4 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -9,6 +9,7 @@ kanban-plugin: board - [ ] увеличить размер текста в окне обновлений - [ ] Нужен ли дополнительный выбор для загрузки с мат моделью или нет? - [ ] Делить по группам траэйнисы и инструкторы +- [ ] Проверить Максимальный объем пересылаемых позже сообщений ## bugs @@ -32,18 +33,17 @@ kanban-plugin: board ## feature server - [ ] убрать clientMap из serverLMS Widget в мультитред сервер -- [ ] Различать, загружен клиент из Unity или нет, для возможности отправлять сообщения только Unity -- [ ] в ГУИ научится определять тип клиента при приеме сообщения -- [ ] Проверить Максимальный объем пересылаемых позже сообщений ## NOW -- [ ] Если клиент не isUnity отправлять сообщение на позднюю отправку ## Complete +- [ ] Различать, загружен клиент из Unity или нет, для возможности отправлять сообщения только Unity +- [ ] в ГУИ научится определять тип клиента при приеме сообщения +- [ ] Если клиент не isUnity отправлять сообщение на позднюю отправку - [ ] свести позицию виджетов (что то не по центру) notify в оффлайн режиме смещен - [ ] ПЕРЕВЕСТИ все действия под операции и формировать процент ПРИ загрузке из них - [ ] При нажатии на кнопку обновить, менять надпись на Загрузка diff --git a/ServerLMS/Data/Client.h b/ServerLMS/Data/Client.h index 33c55f4..3de49f7 100644 --- a/ServerLMS/Data/Client.h +++ b/ServerLMS/Data/Client.h @@ -12,7 +12,7 @@ public: Client(QString name, QString address, QString port,QObject *parent = nullptr): login(""), ready(false), - TypeClient(TypeClientAutorization::TYPE_SIMPLE) + typeClient(TypeClientAutorization::TYPE_QT_CLIENT) { this->name = name; this->address = address; @@ -57,28 +57,31 @@ public: this->ready = ready; } - void setUnity(bool flag) + void setUnity(TypeClientAutorization type) { - isUnity = flag; + typeClient = type; } - bool getIsUnity() + TypeClientAutorization GETTYPE() { - return isUnity; + return typeClient; } void setTypeClient(TypeClientAutorization TypeClient) { - this->TypeClient = TypeClient; + this->typeClient = TypeClient; } TypeClientAutorization getTypeClient() { - return TypeClient; + return typeClient; } void changePackageResponse() { - isUnity = !isUnity; + if (typeClient == TypeClientAutorization::TYPE_QT_CLIENT) + typeClient = TypeClientAutorization::TYPE_UNITY_CLIENT; + else if (typeClient == TypeClientAutorization::TYPE_UNITY_CLIENT) + typeClient = TypeClientAutorization::TYPE_QT_CLIENT; } bool operator == (Client* right) @@ -105,8 +108,6 @@ public: return userType; } - - QString getId() { return id; @@ -127,9 +128,8 @@ private: QString login; bool ready; bool isLoggedIn; - bool isUnity = false; - TypeClientAutorization TypeClient; + TypeClientAutorization typeClient; UserType userType; }; diff --git a/ServerLMS/Data/typesDataServerClient.h b/ServerLMS/Data/typesDataServerClient.h index e2fcbe6..7135dff 100644 --- a/ServerLMS/Data/typesDataServerClient.h +++ b/ServerLMS/Data/typesDataServerClient.h @@ -44,7 +44,8 @@ struct SXmlAnswerTag }; enum TypeClientAutorization{ - TYPE_SIMPLE = 0, + TYPE_QT_CLIENT = 0, + TYPE_UNITY_CLIENT = 1, TYPE_GUI = 10 }; diff --git a/ServerLMS/Systems/Parsers/processparser.cpp b/ServerLMS/Systems/Parsers/processparser.cpp index 42cf7b7..45ffbe1 100644 --- a/ServerLMS/Systems/Parsers/processparser.cpp +++ b/ServerLMS/Systems/Parsers/processparser.cpp @@ -60,14 +60,14 @@ void ProcessParser::slot_read(ClientHandler *client, QByteArray array) } else if(xmlReader.name() == "ListTasksAMM") { - if(client->getClient()->getIsUnity()) + if(client->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) {//Отчет по задаче АММ от Юнити-клиента clientUnityTaskAMMreport(xmlReader,client, array); } } else if(xmlReader.name() == "ListTasksFIM") { - if(client->getClient()->getIsUnity()) + if(client->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) {//Отчет по задаче FIM от Юнити-клиента clientUnityTaskFIMreport(xmlReader,client, array); } @@ -518,8 +518,6 @@ void ProcessParser::clientNotify(QXmlStreamReader &xmlReader,ClientHandler *clie clientNotify.Code = value; } - - processingSystem->processingClientNotify(client, clientNotify); } diff --git a/ServerLMS/Systems/chatsystem.cpp b/ServerLMS/Systems/chatsystem.cpp index a5f3fbf..105c2ff 100644 --- a/ServerLMS/Systems/chatsystem.cpp +++ b/ServerLMS/Systems/chatsystem.cpp @@ -10,15 +10,7 @@ void ChatSystem::initialize(CommonClientHandler *commonClientHandler, DataParser this->commonClientHandler = commonClientHandler; this->dataParser = dataParser; this->clientsMap = clientsMap; - clientNotSendedMessage = new QMap*>; - - auto stack = new QStack; - auto clientMessage1 = ClientMessage("1-0","102-0","Сообщение 1"); - stack->append(clientMessage1); - auto clientMessage2 = ClientMessage("1-0","102-0","Сообщение 2"); - stack->append(clientMessage2); - - clientNotSendedMessage->insert("102", stack); + clientNotSendedMessage = new QMap*>; } bool ChatSystem::sendTo(ClientMessage message) @@ -26,16 +18,14 @@ bool ChatSystem::sendTo(ClientMessage message) QByteArray byteArrayMsg = dataParser->ClientAnswer()->message(message.From,message.To,message.Text); auto result = message.To.split("-"); - //qt - инструктор - //qt - клиент нельзя - //unity - можно foreach(int idSocket, clientsMap->keys()) { ClientHandler *handler = clientsMap->value(idSocket); QString userType = QString::number(static_cast(handler->getClient()->getAccessType())); if(handler->getClient()->getId() == result[0] && - userType == result[1]) + userType == result[1] && + handler->getClient()->getTypeClient() != TypeClientAutorization::TYPE_QT_CLIENT) { handler->sendXmlAnswer(byteArrayMsg, PacketType::TYPE_XMLANSWER); QString str = "Msg From Client [" + message.From + " to " + message.To + "] : " + message.Text; @@ -60,8 +50,8 @@ bool ChatSystem::sendMessage(ClientMessage message) } else { - auto stack = new QStack; - stack->append(message); + auto stack = new QQueue; + stack->enqueue(message); clientNotSendedMessage->insert(message.To, stack); } @@ -76,11 +66,11 @@ void ChatSystem::sendOldMessages(QString id) qDebug() << id; if (clientNotSendedMessage->contains(id)) { - auto stack = clientNotSendedMessage->find(id).value(); + auto queue = clientNotSendedMessage->find(id).value(); - while (!stack->isEmpty()) + while (!queue->isEmpty()) { - auto message = stack->pop(); + auto message = queue->dequeue(); sendTo(message); } } diff --git a/ServerLMS/Systems/chatsystem.h b/ServerLMS/Systems/chatsystem.h index 369cb17..07b3074 100644 --- a/ServerLMS/Systems/chatsystem.h +++ b/ServerLMS/Systems/chatsystem.h @@ -20,7 +20,7 @@ private: CommonClientHandler *commonClientHandler; DataParser *dataParser; QMap *clientsMap; - QMap*> *clientNotSendedMessage; + QMap*> *clientNotSendedMessage; bool sendTo(ClientMessage message); }; diff --git a/ServerLMS/Systems/commonclienthandler.cpp b/ServerLMS/Systems/commonclienthandler.cpp index 34cc28a..7822b9a 100644 --- a/ServerLMS/Systems/commonclienthandler.cpp +++ b/ServerLMS/Systems/commonclienthandler.cpp @@ -53,7 +53,7 @@ void CommonClientHandler::slot_ListsInstructorsTraineesChanged() processingSystem->processingClientQueryToDB(handler, queryToDB); } - if(handler->getClient()->getIsUnity()) + if(handler->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { ClientQueryToDB queryToDB; queryToDB.typeQuery = TypeQueryToDB::TYPE_QUERY_GET_CONTACT_LIST; diff --git a/ServerLMS/Systems/processingsystem.cpp b/ServerLMS/Systems/processingsystem.cpp index 559229e..cc674c0 100644 --- a/ServerLMS/Systems/processingsystem.cpp +++ b/ServerLMS/Systems/processingsystem.cpp @@ -528,7 +528,7 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif else if(clientNotify.Code == commandStartTimerClient) { //Фиксируем время входа Юнити-клиента - if (client->getClient()->getIsUnity()) + if (client->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { processingEntryUnityClient(client); } @@ -538,7 +538,7 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif qDebug() << "processing thread: " << QThread::currentThreadId(); //Фиксируем время выхода Юнити-клиента - if (client->getClient()->getIsUnity()) + if (client->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { processingExitUnityClient(client); } @@ -670,7 +670,7 @@ void ProcessingSystem::sendTaskFIMToClient(ClientHandler *client, int id_trainee void ProcessingSystem::sendTaskListToUnity(ClientHandler *client) { //Отправка списков задач клиенту Юнити - if(client->getClient()->getIsUnity()) + if(client->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { QString login = client->getClient()->getLogin(); int id_trainee = providerDBLMS->getIdTraineeByLogin(login); @@ -697,7 +697,7 @@ ClientHandler *ProcessingSystem::getUnityClientById(int id) ClientHandler *handler = server->getClientsMap().value(idSocket); if(handler->getClient()->getLogin() == login) { - if(handler->getClient()->getIsUnity()) + if(handler->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { return handler; } diff --git a/ServerLMS/Systems/recognizesystem.cpp b/ServerLMS/Systems/recognizesystem.cpp index e2d2b9c..71bbc00 100644 --- a/ServerLMS/Systems/recognizesystem.cpp +++ b/ServerLMS/Systems/recognizesystem.cpp @@ -61,7 +61,7 @@ void RecognizeSystem::recognize() continue; } - if(client->getIsUnity()) + if(client->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { char *read = new char[4]; stream.readRawData(read,4); @@ -110,7 +110,7 @@ void RecognizeSystem::recognize() if (packetType == PacketType::TYPE_XMLANSWER) { - if(clientHandler->getClient()->getIsUnity()) + if(clientHandler->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { data = socket->readAll(); } @@ -130,7 +130,7 @@ void RecognizeSystem::recognize() if(packetType == PacketType::TYPE_BIGXML) { - if (clientHandler->getClient()->getIsUnity()) + if (clientHandler->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { char *readBuffer = new char[4]; socket->read(readBuffer,4); @@ -183,7 +183,7 @@ void RecognizeSystem::recognize() if(packetType == PacketType::TYPE_FOLDER) //создание папок { - if(client->getIsUnity()) + if(client->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { filePath = socket->readAll(); filePath = Tools::createSharedPath(filePath); @@ -215,7 +215,7 @@ void RecognizeSystem::recognize() if (packetType == PacketType::TYPE_FILE) //выгрузка одного файла { - if(client->getIsUnity()) + if(client->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { DataInfo *currentFileData = updateController->getCurrentDataInfo(); filePath = currentFileData->path; @@ -443,13 +443,13 @@ void RecognizeSystem::packetTypeInit(PacketType packet,Client *client) { if(packet == PacketType::TYPE_QT) { - client->setUnity(false); + client->setUnity(TypeClientAutorization::TYPE_QT_CLIENT); - qDebug() << "ConnectionType isUnity: " << client->getIsUnity(); + qDebug() << "ConnectionType isUnity: " << client->GETTYPE(); } else if (packet == PacketType::TYPE_UNITY) { - client->setUnity(true); + client->setUnity(TypeClientAutorization::TYPE_UNITY_CLIENT); //Фиксируем время входа Юнити-клиента } diff --git a/ServerLMS/Systems/sendsystem.cpp b/ServerLMS/Systems/sendsystem.cpp index 303255d..3515894 100644 --- a/ServerLMS/Systems/sendsystem.cpp +++ b/ServerLMS/Systems/sendsystem.cpp @@ -22,7 +22,7 @@ void SendSystem::initialize(DataParser *dataParser,Logger *logger) void SendSystem::setClient(Client *client,QTcpSocket *socket) { this->socket = socket; - this->isUnity = client->getIsUnity(); + this->type = client->GETTYPE(); this->client = client; isSendStopped = false; } @@ -85,7 +85,8 @@ void SendSystem::sendFileBlockByteArray(QByteArray array, PacketType packetType) { qDebug() << "sendFileBlockByteArray thread: " << QThread::currentThreadId(); - if(!client->getIsUnity()) + if(client->GETTYPE() == TypeClientAutorization::TYPE_QT_CLIENT || + client->GETTYPE() == TypeClientAutorization::TYPE_GUI) { QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); @@ -193,7 +194,8 @@ void SendSystem::sendDeleteBlock(QString path) void SendSystem::sendPacketType(PacketType packetType) { - if(!client->getIsUnity()) + if (client->GETTYPE() == TypeClientAutorization::TYPE_QT_CLIENT || + client->GETTYPE() == TypeClientAutorization::TYPE_GUI) { QDataStream stream(socket); @@ -225,7 +227,8 @@ void SendSystem::sendNotify(QString notify) void SendSystem::sendXmlAnswer(QByteArray array, PacketType packetType) { qDebug() << "SendSystemThread: " << QThread::currentThreadId(); - if(!client->getIsUnity()) + if (client->GETTYPE() == TypeClientAutorization::TYPE_QT_CLIENT || + client->GETTYPE() == TypeClientAutorization::TYPE_GUI) { QDataStream stream(socket); stream.setVersion(QDataStream::Qt_DefaultCompiledVersion); diff --git a/ServerLMS/Systems/sendsystem.h b/ServerLMS/Systems/sendsystem.h index cd5474a..4e2146f 100644 --- a/ServerLMS/Systems/sendsystem.h +++ b/ServerLMS/Systems/sendsystem.h @@ -63,9 +63,7 @@ private: quint64 fileSize; int countSend; bool isSendStopped; - bool isUnity; - - + TypeClientAutorization type; }; #endif // SENDSYSTEM_H diff --git a/ServerLMS/serverlmswidget.cpp b/ServerLMS/serverlmswidget.cpp index 4ff227f..c636804 100644 --- a/ServerLMS/serverlmswidget.cpp +++ b/ServerLMS/serverlmswidget.cpp @@ -136,7 +136,7 @@ bool ServerLMSWidget::stopServer() ClientHandler* clientHandlerOpen = clientsMap[idSocket]; //Фиксируем время выхода Юнити-клиента - if(clientHandlerOpen->getClient()->getIsUnity()) + if(clientHandlerOpen->getClient()->GETTYPE() == TypeClientAutorization::TYPE_UNITY_CLIENT) { processingSystem->processingExitUnityClient(clientHandlerOpen); }