mirror of
https://gitea.msk.dinamika-avia.ru/Constanta-Design/RRJServer.git
synced 2026-03-27 19:45:43 +03:00
bugfix: send old messages to QTGUI
This commit is contained in:
@@ -10,11 +10,12 @@ kanban-plugin: board
|
||||
|
||||
## bugs
|
||||
|
||||
- [ ] Перезаполнять имя на offline, если клиент отключился
|
||||
|
||||
|
||||
## feature client Unity
|
||||
|
||||
- [ ] Протестировать и обновить версию на testPC СХЕМЫ
|
||||
- [ ] перетащить наименования хинтов в XML и забирать из оттуда при старте
|
||||
|
||||
|
||||
## feature client QT
|
||||
@@ -349,6 +350,7 @@ kanban-plugin: board
|
||||
|
||||
## Cancel
|
||||
|
||||
- [ ] Протестировать и обновить версию на testPC СХЕМЫ
|
||||
- [ ] Делить по группам номер группы
|
||||
- [ ] Добавить обновление инструктора, если он перелогинился
|
||||
- [ ] добавить в settings адрес и булку мат модели
|
||||
|
||||
@@ -139,14 +139,6 @@ void SendSystem::sendChangeVersion(StreamingVersionData *streamingVersion)
|
||||
socket->waitForReadyRead(100);
|
||||
}
|
||||
|
||||
void SendSystem::sendOldMessages()
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
stream.setVersion(QDataStream::Qt_DefaultCompiledVersion);
|
||||
stream << PacketType::TYPE_GET_OLD_MESSAGES;
|
||||
socket->waitForReadyRead(100);
|
||||
}
|
||||
|
||||
void SendSystem::sendDeleteVersion(StreamingVersionData *streamingVersion)
|
||||
{
|
||||
QDataStream stream(socket);
|
||||
|
||||
@@ -26,8 +26,6 @@ public:
|
||||
void sendDeleteVersion(StreamingVersionData *streamingVersion);
|
||||
void sendCopyVersion(QString versionName);
|
||||
void sendPacketType(PacketType packetType);
|
||||
|
||||
void sendOldMessages();
|
||||
signals:
|
||||
void sigSend();
|
||||
QByteArray sigGetXmlAnswer(QString);
|
||||
|
||||
@@ -21,6 +21,7 @@ static QString streamingHashFilename = staticDataFolderName + "/streamingHash.xm
|
||||
static QString serverHash = staticDataFolderName + "/serverHash.xml";
|
||||
|
||||
static QString cmd_CheckVersionList = "CHECKVERSIONLIST";
|
||||
static QString cmd_GetOfflineMessages = "GETOFFLINEMESSAGE";
|
||||
|
||||
enum PacketType{
|
||||
TYPE_NONE = 0,
|
||||
|
||||
@@ -11,7 +11,8 @@ ConnectorToServer::ConnectorToServer(QWidget* parentWidget, QObject *parent) :
|
||||
recognizeSystem(nullptr),
|
||||
versionSelectWidget(nullptr),
|
||||
versionContainer(nullptr),
|
||||
notifyController(nullptr)
|
||||
notifyController(nullptr),
|
||||
isLoggedIn(false)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
@@ -42,6 +43,7 @@ bool ConnectorToServer::authorizationInstructorLocal(QString login, QString pass
|
||||
autorization->Login = login;
|
||||
autorization->Password = password;
|
||||
autorization->TypeClient = TypeClientAutorization::TYPE_GUI;
|
||||
isLoggedIn = true;
|
||||
|
||||
QByteArray array = dataParser->createAuthMessage(autorization);
|
||||
emit signal_sendXMLmsgGUItoServer(array);
|
||||
@@ -58,6 +60,7 @@ bool ConnectorToServer::deAuthorizationInstructorLocal(QString login)
|
||||
|
||||
ClientDeAutorization *deAutorization = new ClientDeAutorization;
|
||||
deAutorization->Login = login;
|
||||
isLoggedIn = false;
|
||||
|
||||
QByteArray array = dataParser->createDeAuthMessage(deAutorization);
|
||||
emit signal_sendXMLmsgGUItoServer(array);
|
||||
@@ -93,6 +96,12 @@ bool ConnectorToServer::sendMessage(ClientMessage clientMessage)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConnectorToServer::sendClientNotify(QString command)
|
||||
{
|
||||
QByteArray answer = dataParser->xmlAnswer_notify(command);
|
||||
emit sigSendAnswerToServer(answer);
|
||||
return true;
|
||||
}
|
||||
bool ConnectorToServer::sendQueryTasksXML(QString type)
|
||||
{
|
||||
if (!client->getIsConnected())
|
||||
@@ -328,6 +337,11 @@ void ConnectorToServer::slot_AnswerQueryToDB_ListTrainees(QList<Trainee> listTra
|
||||
this->listTrainees = listTrainees;
|
||||
emit signal_UpdateDB(false, true);
|
||||
emit signal_InitMessanger(listTrainees);
|
||||
|
||||
if (isLoggedIn)
|
||||
{
|
||||
sendClientNotify(cmd_GetOfflineMessages);
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectorToServer::slot_AnswerQueryToDB_ListComputers(QList<Computer> listComputers)
|
||||
@@ -414,7 +428,7 @@ void ConnectorToServer::bindConnection()
|
||||
|
||||
connect(recognizeSystem,&RecognizeSystem::sigAuth,this,&ConnectorToServer::sigLoginResult);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigDeAuth,this,&ConnectorToServer::sigDeLoginResult);
|
||||
connect(recognizeSystem,&RecognizeSystem::signal_ReceiveMessage,this,&ConnectorToServer::signal_receiveMessage);
|
||||
connect(recognizeSystem,&RecognizeSystem::signal_ReceiveMessage,this,&ConnectorToServer::signal_receiveMessage,Qt::AutoConnection);
|
||||
connect(recognizeSystem,&RecognizeSystem::sigShowServerDataList,this,&ConnectorToServer::showServerList);
|
||||
connect (recognizeSystem,&RecognizeSystem::sigSetVersion,versionContainer,&VersionContainer::setServerVersionData);
|
||||
//connect(recognizeSystem,&RecognizeSystem::sigAnswerQueryToDB,this,&ConnectorToServer::slot_AnswerQueryToDB);
|
||||
|
||||
@@ -70,6 +70,7 @@ public:
|
||||
|
||||
SendSystem *getSendSystem() const;
|
||||
|
||||
bool sendClientNotify(QString command);
|
||||
public slots:
|
||||
void slot_AnswerQueryToDB_ListInstructors(QList<Instructor> listInstructors);
|
||||
void slot_AnswerQueryToDB_ListGroups(QList<Group> listGroups);
|
||||
@@ -146,6 +147,7 @@ private:
|
||||
QByteArray listTaskAmmArray;
|
||||
|
||||
ServerSettings serverSettings;
|
||||
bool isLoggedIn;
|
||||
};
|
||||
|
||||
#endif // CONNECTORTOSERVER_H
|
||||
|
||||
@@ -216,10 +216,10 @@ void InstructorsAndTraineesWidget::checkLoginResult(ServerAuthorization *serverA
|
||||
|
||||
updateLabelLoggedInInstructor(serverAuth->Login, serverAuth->ClientName);
|
||||
connectorToServer->setLoginName(nameInstructorLoggedInLocal);
|
||||
messangerWidget->initialize(serverAuth->Id);
|
||||
|
||||
connectorToServer->sendQueryTasksXML("fim");
|
||||
connectorToServer->sendQueryTasksXML("amm");
|
||||
messangerWidget->initialize(serverAuth->Id);
|
||||
//QMessageBox::information(this, tr("Instructor authorization"), tr("Successfully!"));
|
||||
}
|
||||
else
|
||||
|
||||
@@ -153,8 +153,8 @@ void MessangerWidget::clear()
|
||||
void MessangerWidget::on_btnSend_clicked()
|
||||
{
|
||||
QString text = ui->editMsg->toPlainText();
|
||||
QString from = currClientId + "-" + QString::number(0);// временный костыль, так как чаты только с обучаемыми
|
||||
QString to = selectedUserId + "-" + QString::number(1);// временный костыль, так как чаты только с обучаемыми
|
||||
QString from = currClientId;
|
||||
QString to = selectedUserId;
|
||||
|
||||
ClientMessage message = ClientMessage(from,to,text);
|
||||
emit signal_sendMessage(message);
|
||||
@@ -231,10 +231,9 @@ void MessangerWidget::slot_InitMessanger(QList<Trainee> listTrainees)
|
||||
|
||||
void MessangerWidget::slot_showMessage(ClientMessage clientMessage)
|
||||
{
|
||||
auto result = clientMessage.fromId.split("-");
|
||||
for(Trainee trainee: listTrainees)
|
||||
{
|
||||
if(QString::number(trainee.getID()) == result[0])
|
||||
if(QString::number(trainee.getID()) == clientMessage.fromId)
|
||||
{
|
||||
addMsgFromClient(trainee, clientMessage.Text);
|
||||
break;
|
||||
|
||||
@@ -10,6 +10,7 @@ void ChatSystem::initialize(CommonClientHandler *commonClientHandler, DataParser
|
||||
this->commonClientHandler = commonClientHandler;
|
||||
this->dataParser = dataParser;
|
||||
this->clientsMap = clientsMap;
|
||||
|
||||
clientNotSendedMessage = new QMap<QString,QQueue<ClientMessage>*>;
|
||||
}
|
||||
|
||||
@@ -17,15 +18,13 @@ bool ChatSystem::sendTo(ClientMessage message)
|
||||
{
|
||||
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);
|
||||
QString userType = QString::number(static_cast<int>(handler->getClient()->getAccessType()));
|
||||
|
||||
if(handler->getClient()->getId() == result[0] &&
|
||||
userType == result[1] &&
|
||||
handler->getClient()->getTypeClient() != TypeClientAutorization::TYPE_QT_CLIENT)
|
||||
if(handler->getClient()->getId() == message.To &&
|
||||
handler->getClient()->getTypeClient() != TypeClientAutorization::TYPE_QT_CLIENT &&
|
||||
handler->getClient()->getIsLoggedIn())
|
||||
{
|
||||
handler->sendXmlAnswer(byteArrayMsg, PacketType::TYPE_XMLANSWER);
|
||||
QString str = "Msg From Client [" + message.From + " to " + message.To + "] : " + message.Text;
|
||||
@@ -67,6 +66,7 @@ void ChatSystem::sendOldMessages(QString id)
|
||||
if (clientNotSendedMessage->contains(id))
|
||||
{
|
||||
auto queue = clientNotSendedMessage->find(id).value();
|
||||
Logger::instance().log("Send old Messages " + QString::number(queue->length()));
|
||||
|
||||
while (!queue->isEmpty())
|
||||
{
|
||||
|
||||
@@ -120,6 +120,7 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
|
||||
|
||||
client->getClient()->setLogin("");
|
||||
client->getClient()->setAccessType(UserType::NONE);
|
||||
client->getClient()->setIsLoggedIn(false);
|
||||
emit sigUpdateListClients();
|
||||
|
||||
arrayAnswer = dataParser->ClientAnswer()->deAuthorization(true, clientDeAutorization.Login);
|
||||
@@ -129,6 +130,7 @@ void ProcessingSystem::processingClientDeAutorization(ClientHandler *client, Cli
|
||||
|
||||
client->getClient()->setLogin("");
|
||||
client->getClient()->setAccessType(UserType::NONE);
|
||||
client->getClient()->setIsLoggedIn(false);
|
||||
emit sigUpdateListClients();
|
||||
|
||||
arrayAnswer = dataParser->ClientAnswer()->deAuthorization(true, clientDeAutorization.Login);
|
||||
@@ -568,7 +570,7 @@ void ProcessingSystem::processingClientNotify(ClientHandler *client, ClientNotif
|
||||
}
|
||||
else if (clientNotify.Code == commandeGetOfflineMessages)
|
||||
{
|
||||
chatSystem->sendOldMessages(client->getClient()->getId() + "-" + QString::number(1));
|
||||
chatSystem->sendOldMessages(client->getClient()->getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user