До трансляции message на ГУИ от Клиента

This commit is contained in:
krivoshein
2024-12-16 17:47:33 +03:00
parent b4e30429f7
commit e393244bf7
60 changed files with 877 additions and 551 deletions

View File

@@ -72,6 +72,7 @@ ServerLMSWidget::ServerLMSWidget(QWidget *parent) :
connect(this,&ServerLMSWidget::sigLog,logger,&Logger::addTextToLogger);
connect(processingSystem,&ProcessingSystem::sigAuthChanged,this, &ServerLMSWidget::slot_AuthChanged);
connect(processingSystem,&ProcessingSystem::signal_msgToClientReady,this, &ServerLMSWidget::slot_msgToClientFromGUI);
on_btnStartServer_clicked();
@@ -227,7 +228,7 @@ void ServerLMSWidget::slot_LanguageChanged(QString language)
}
void ServerLMSWidget::slot_msgToClientReady(QString login, QString text)
void ServerLMSWidget::slot_msgToClientFromGUI(QString login, QString text)
{
QString textMsg = text;
@@ -253,6 +254,32 @@ void ServerLMSWidget::slot_msgToClientReady(QString login, QString text)
}
}
void ServerLMSWidget::slot_msgToGUIfromClient(QString login, QString text)
{
QString textMsg = text;
QByteArray byteArrayMsg = dataParser->xmlAnswer_message(textMsg);
//Проходим все открытые сокеты, ищем нужный
foreach(int idSocket, clientsMap.keys())
{
ClientHandler *handler = clientsMap[idSocket];
if(handler->getClient()->getTypeClient() == TypeClientAutorization::TYPE_GUI)
{//Отправляем GUI-клиенту для отображения в Мессенджере
handler->sendXmlAnswer(byteArrayMsg);
QString peerAddress = clientsMap[idSocket]->getSocket()->peerAddress().toString();
QString peerPort = QString::number(clientsMap[idSocket]->getSocket()->peerPort());
QString str = "Msg From Client [" + peerAddress + ":" + peerPort + "] : " + textMsg;
logger->addTextToLogger(str);
break;
}
}
}
void ServerLMSWidget::slotAddToLog(QString msg)
{
ui->listWidgetLogger->addItem(msg);