From 33c7a31143b699f67fcabad2f7b391e5b0506dd8 Mon Sep 17 00:00:00 2001 From: semenov Date: Mon, 4 Aug 2025 16:37:54 +0300 Subject: [PATCH] ref: change message attributes --- DOCS/Алексей/Board.md | 24 ++++++++++++------- .../connectorToServer/Core/dataparser.cpp | 1 - .../Core/recognizesystem.cpp | 5 ---- .../connectorToServer/Datas.h | 11 +++++---- .../messanger/messangerwidget.cpp | 7 ++++-- ServerLMS/Data/Client.h | 10 ++++---- ServerLMS/Data/typesDataServerClient.h | 16 ++++++++----- .../Systems/Parsers/clientanswerparser.cpp | 4 +--- .../Systems/Parsers/clientanswerparser.h | 2 +- ServerLMS/Systems/Parsers/processparser.cpp | 2 -- ServerLMS/Systems/chatsystem.cpp | 13 ++++++---- ServerLMS/Systems/processingsystem.cpp | 20 ++++++++-------- 12 files changed, 62 insertions(+), 53 deletions(-) diff --git a/DOCS/Алексей/Board.md b/DOCS/Алексей/Board.md index cdee597..3864b25 100644 --- a/DOCS/Алексей/Board.md +++ b/DOCS/Алексей/Board.md @@ -14,39 +14,42 @@ kanban-plugin: board - [ ] QT client: sig fault если не выбрана версия - [ ] после удаления версии сбрасывать текст в описании -- [ ] сбрасывается выделение кнопки текущего клиента в мессенджере -- [ ] notification message скидывается у всех при проверке ## feature client Unity - [ ] Если staticData не найдена, грузится как оффлайн, проверять просто иконки билда -- [ ] Делить по группам номер группы -- [ ] добавить тестово логины в строку контактов -- [ ] сортировать по онлайну -- [ ] Делить по группам Администрация -- [ ] верстка окна +- [ ] Делить по группам траэйнисы и инструкторы ## feature client QT +- [ ] ПЕРЕВЕСТИ все действия под операции и формировать процент ПРИ загрузке из них - [ ] При нажатии на кнопку обновить, менять надпись на Загрузка -- [ ] Написать Аркадию ТЗ для разработки иконки клиента +- [ ] свести позицию виджетов (что то не по центру) notify в оффлайн режиме смещен ## feature server - [ ] добавить генерацию пустых файлов, если shared не найден -- [ ] ПЕРЕВЕСТИ все действия под операции и формировать процент ПРИ загрузке из них - [ ] убрать clientMap из serverLMS Widget в мультитред сервер +- [ ] Различать, загружен клиент из Unity или нет, для возможности отправлять сообщения только Unity +- [ ] в ГУИ научится определять тип клиента при приеме сообщения ## NOW +- [ ] Переверстать верхушку Messenger +- [ ] Unity Layout в мессенджере пересчитывать ## Complete +- [ ] Идентификация имени внизу для отладки +- [ ] добавить тестово логины в строку контактов +- [ ] верстка окна +- [ ] сортировать по онлайну +- [ ] Написать Аркадию для подготовки иконки - [ ] FIM проверять на null задачу - [ ] Добавить - фильтрацию trainees или instructor - [ ] выбор версии на один клик @@ -304,6 +307,8 @@ kanban-plugin: board ## BUGFIX Complete +- [ ] notification message скидывается у всех при проверке +- [ ] сбрасывается выделение кнопки текущего клиента в мессенджере - [ ] при создании копии переключение сервера и переключения клиента - [ ] QT сервер Найти причину двойного вызова проверки при логине инструктором - [ ] QT клиент: device not open после прерывания загрузки @@ -333,6 +338,7 @@ kanban-plugin: board ## Cancel +- [ ] Делить по группам номер группы - [ ] Добавить обновление инструктора, если он перелогинился - [ ] добавить в settings адрес и булку мат модели - [ ] Иерархия проекта - папка application, папка updater и линк на основной экзешник diff --git a/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp b/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp index f1f35de..d3b1319 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp +++ b/InstructorsAndTrainees/connectorToServer/Core/dataparser.cpp @@ -88,7 +88,6 @@ QByteArray DataParser::createMessage(ClientMessage clientMessage) xmlWriter.writeAttribute("From",clientMessage.fromId); xmlWriter.writeAttribute("To", clientMessage.toId); xmlWriter.writeAttribute("Text", clientMessage.Text); - xmlWriter.writeAttribute("UserType",clientMessage.UserType); xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); diff --git a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp index 93e12d0..933bb2a 100644 --- a/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp +++ b/InstructorsAndTrainees/connectorToServer/Core/recognizesystem.cpp @@ -526,11 +526,6 @@ void RecognizeSystem::xmlParser(QByteArray array) if (name == "Text"){ clientMessage->Text = value; } - - if (name == "UserType") - { - clientMessage->UserType = value; - } } emit signal_ReceiveMessage(*clientMessage); diff --git a/InstructorsAndTrainees/connectorToServer/Datas.h b/InstructorsAndTrainees/connectorToServer/Datas.h index 0312211..ffcf510 100644 --- a/InstructorsAndTrainees/connectorToServer/Datas.h +++ b/InstructorsAndTrainees/connectorToServer/Datas.h @@ -74,17 +74,18 @@ public: class ClientMessage { public: - QString fromId; - QString toId; + QString fromId;//формат id-typeId + QString toId;//формат id-typeId QString Text; - QString UserType; + + //TypeId + //0 - инструктор, 1 - обучаемый ClientMessage(){} - ClientMessage(QString fromId, QString toId, QString text, QString UserType) + ClientMessage(QString fromId, QString toId, QString text) { this->fromId = fromId; this->toId = toId; this->Text = text; - this->UserType = UserType; } }; diff --git a/InstructorsAndTrainees/messanger/messangerwidget.cpp b/InstructorsAndTrainees/messanger/messangerwidget.cpp index a63abc3..1e6875a 100644 --- a/InstructorsAndTrainees/messanger/messangerwidget.cpp +++ b/InstructorsAndTrainees/messanger/messangerwidget.cpp @@ -153,8 +153,10 @@ void MessangerWidget::clear() void MessangerWidget::on_btnSend_clicked() { QString text = ui->editMsg->toPlainText(); - ClientMessage message = ClientMessage(currClientId,selectedUserId,text,"0"); + QString from = currClientId + "-" + QString::number(0);// временный костыль, так как чаты только с обучаемыми + QString to = selectedUserId + "-" + QString::number(1);// временный костыль, так как чаты только с обучаемыми + ClientMessage message = ClientMessage(from,to,text); emit signal_sendMessage(message); ui->editMsg->clear(); @@ -229,9 +231,10 @@ void MessangerWidget::slot_InitMessanger(QList listTrainees) void MessangerWidget::slot_showMessage(ClientMessage clientMessage) { + auto result = clientMessage.fromId.split("-"); for(Trainee trainee: listTrainees) { - if(QString::number(trainee.getID()) == clientMessage.fromId) + if(QString::number(trainee.getID()) == result[0]) { addMsgFromClient(trainee, clientMessage.Text); break; diff --git a/ServerLMS/Data/Client.h b/ServerLMS/Data/Client.h index 9b01df0..33c55f4 100644 --- a/ServerLMS/Data/Client.h +++ b/ServerLMS/Data/Client.h @@ -96,13 +96,13 @@ public: isLoggedIn = value; } - void setAccessType(QString type) + void setAccessType(UserType type) { - accessType = type; + userType = type; } - QString getAccessType() + UserType getAccessType() { - return accessType; + return userType; } @@ -130,7 +130,7 @@ private: bool isUnity = false; TypeClientAutorization TypeClient; - QString accessType = ""; + UserType userType; }; #endif // CLIENT_H diff --git a/ServerLMS/Data/typesDataServerClient.h b/ServerLMS/Data/typesDataServerClient.h index f2bda0f..e2fcbe6 100644 --- a/ServerLMS/Data/typesDataServerClient.h +++ b/ServerLMS/Data/typesDataServerClient.h @@ -51,7 +51,9 @@ enum TypeClientAutorization{ enum UserType { INSTRUCTOR, - TRAINEE + TRAINEE, + + NONE = 100 }; class ClientAutorization @@ -104,18 +106,20 @@ public: class ClientMessage { public: - QString From; - QString To; + QString From;//формат"id-type" + QString To;//формат"id-type" QString Text; - QString Type; //ТИП ЮЗЕРА К КОТОРОМУ ПРИХОДИТ СООБЩЕНИЕ + + //id-0 инструктор + //id-1 обучаемый ClientMessage(){} - ClientMessage(QString from,QString to,QString text,QString userType) + ClientMessage(QString from,QString to,QString text) { From = from; To = to; Text = text; - Type = userType; + } }; diff --git a/ServerLMS/Systems/Parsers/clientanswerparser.cpp b/ServerLMS/Systems/Parsers/clientanswerparser.cpp index c3ad24c..e1ce8b3 100644 --- a/ServerLMS/Systems/Parsers/clientanswerparser.cpp +++ b/ServerLMS/Systems/Parsers/clientanswerparser.cpp @@ -43,7 +43,7 @@ QByteArray ClientAnswerParser::deAuthorization(bool result, QString login) return dataParser->xmlAnswer(listTag); } -QByteArray ClientAnswerParser::message(QString loginFrom,QString loginTo,QString text,QString type) +QByteArray ClientAnswerParser::message(QString loginFrom,QString loginTo,QString text) { QList listTag; QList listAttr; @@ -54,8 +54,6 @@ QByteArray ClientAnswerParser::message(QString loginFrom,QString loginTo,QString listAttr.append(attribute1); attribute1 = {"Text",text}; listAttr.append(attribute1); - attribute1 = {"UserType",type}; - listAttr.append(attribute1); SXmlAnswerTag tag = {"ClientMessage", listAttr}; diff --git a/ServerLMS/Systems/Parsers/clientanswerparser.h b/ServerLMS/Systems/Parsers/clientanswerparser.h index 80cfc77..423b4e5 100644 --- a/ServerLMS/Systems/Parsers/clientanswerparser.h +++ b/ServerLMS/Systems/Parsers/clientanswerparser.h @@ -16,7 +16,7 @@ public: QByteArray authorization(bool result, QString instructorName, QString clientName, QString accessType, QString login, int id); QByteArray deAuthorization(bool result, QString login); - QByteArray message(QString loginFrom,QString loginTo,QString text, QString userType); + QByteArray message(QString loginFrom,QString loginTo,QString text); QByteArray task(QString text); QByteArray notify(QString code); QByteArray tasks(QStringList listTasks); diff --git a/ServerLMS/Systems/Parsers/processparser.cpp b/ServerLMS/Systems/Parsers/processparser.cpp index b1bade8..42cf7b7 100644 --- a/ServerLMS/Systems/Parsers/processparser.cpp +++ b/ServerLMS/Systems/Parsers/processparser.cpp @@ -498,8 +498,6 @@ void ProcessParser::clientMessage(QXmlStreamReader &xmlReader,ClientHandler *cli clientMessage.From = value; if (name == "To") clientMessage.To = value; - if (name == "UserType") - clientMessage.Type = value; } processingSystem->processingSendMessage(clientMessage); diff --git a/ServerLMS/Systems/chatsystem.cpp b/ServerLMS/Systems/chatsystem.cpp index 962e491..0c481cf 100644 --- a/ServerLMS/Systems/chatsystem.cpp +++ b/ServerLMS/Systems/chatsystem.cpp @@ -13,9 +13,9 @@ void ChatSystem::initialize(CommonClientHandler *commonClientHandler, DataParser clientNotSendedMessage = new QMap*>; auto stack = new QStack; - auto clientMessage1 = ClientMessage("1","102","Сообщение 1","1"); + auto clientMessage1 = ClientMessage("1-0","102-0","Сообщение 1"); stack->append(clientMessage1); - auto clientMessage2 = ClientMessage("1","102","Сообщение 2","1"); + auto clientMessage2 = ClientMessage("1-0","102-0","Сообщение 2"); stack->append(clientMessage2); clientNotSendedMessage->insert("102", stack); @@ -23,12 +23,17 @@ void ChatSystem::initialize(CommonClientHandler *commonClientHandler, DataParser bool ChatSystem::sendTo(ClientMessage message) { - QByteArray byteArrayMsg = dataParser->ClientAnswer()->message(message.From,message.To,message.Text,message.Type); + QByteArray byteArrayMsg = dataParser->ClientAnswer()->message(message.From,message.To,message.Text); + + auto result = message.To.split("-"); foreach(int idSocket, clientsMap->keys()) { ClientHandler *handler = clientsMap->value(idSocket); - if(handler->getClient()->getId() == message.To) + QString userType = QString::number(static_cast(handler->getClient()->getAccessType())); + + if(handler->getClient()->getId() == result[0] && + userType == result[1]) { handler->sendXmlAnswer(byteArrayMsg, PacketType::TYPE_XMLANSWER); QString str = "Msg From Client [" + message.From + " to " + message.To + "] : " + message.Text; diff --git a/ServerLMS/Systems/processingsystem.cpp b/ServerLMS/Systems/processingsystem.cpp index 5f9c54a..4ba8f7b 100644 --- a/ServerLMS/Systems/processingsystem.cpp +++ b/ServerLMS/Systems/processingsystem.cpp @@ -58,7 +58,7 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien {//Авторизуется инструктор client->getClient()->setLogin(clientAutorization.Login); - client->getClient()->setAccessType("instructor"); + client->getClient()->setAccessType(UserType::INSTRUCTOR); client->getClient()->setTypeClient(clientAutorization.TypeClient); emit sigUpdateListClients(); @@ -74,7 +74,7 @@ void ProcessingSystem::processingClientAutorization(ClientHandler *client, Clien {//Авторизуется обучаемый client->getClient()->setLogin(clientAutorization.Login); - client->getClient()->setAccessType("trainee"); + client->getClient()->setAccessType(UserType::TRAINEE); emit sigUpdateListClients(); //KAV redact @@ -122,7 +122,7 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli {//ДеАвторизуется обучаемый client->getClient()->setLogin(""); - client->getClient()->setAccessType(""); + client->getClient()->setAccessType(UserType::NONE); emit sigUpdateListClients(); arrayAnswer = dataParser->ClientAnswer()->deAuthorization(true, clientDeAutorization.Login); @@ -131,7 +131,7 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli {//ДеАвторизуется инструктор client->getClient()->setLogin(""); - client->getClient()->setAccessType(""); + client->getClient()->setAccessType(UserType::NONE); emit sigUpdateListClients(); arrayAnswer = dataParser->ClientAnswer()->deAuthorization(true, clientDeAutorization.Login); @@ -167,14 +167,14 @@ void ProcessingSystem::processingClientDeAutorization(QString login) void ProcessingSystem::processingEntryUnityClient(ClientHandler *client) { QString login = client->getClient()->getLogin(); - QString accessType = client->getClient()->getAccessType(); + UserType userType = client->getClient()->getAccessType(); - if(accessType == "trainee") + if(userType == UserType::TRAINEE) { int id_trainee = providerDBLMS->getIdTraineeByLogin(login); providerDBLMS->entryTraineeOnSimulator(id_trainee); } - else if(accessType == "instructor") + else if(userType == UserType::INSTRUCTOR) { //Здесь пока ничего не происходит } @@ -183,14 +183,14 @@ void ProcessingSystem::processingEntryUnityClient(ClientHandler *client) void ProcessingSystem::processingExitUnityClient(ClientHandler *client) { QString login = client->getClient()->getLogin(); - QString accessType = client->getClient()->getAccessType(); + UserType userType = client->getClient()->getAccessType(); - if(accessType == "trainee") + if(userType == UserType::TRAINEE) { int id_trainee = providerDBLMS->getIdTraineeByLogin(login); providerDBLMS->exitTraineeFromSimulator(id_trainee); } - else if(accessType == "instructor") + else if(userType == UserType::INSTRUCTOR) { //Здесь пока ничего не происходит }