提交 20752510 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Add testing code, need debug

上级 19727fab
......@@ -645,7 +645,9 @@ int MainDialog::deal_current_message_block()
if (bytesLeft)
return 0;
char * ptr = m_currentBlock.data();
const char * ptr = m_currentBlock.constData();
SMARTLINK_MSG_APP * pApp = (SMARTLINK_MSG_APP *)(((unsigned char *)
(ptr))+sizeof(SMARTLINK_MSG)-1
);
......@@ -763,8 +765,57 @@ int MainDialog::deal_current_message_block()
else
QMessageBox::information(this,tr("Failed!"),tr("download in Failed!"));
}
else
{
QString str;
int nLen = m_currentHeader.data_length;
for (int i=0;i<nLen;i++)
{
str += ptr[i+ sizeof(SMARTLINK_MSG) - 1];
}
ui->plainTextEdit_msg_recieved->setPlainText(str);
}
m_currentBlock = QByteArray();
return 0;
}
void MainDialog::on_pushButton_sendToClient_clicked()
{
if (client->isOpen()==false)
{
QMessageBox::warning(this,"Please connect first!","Connect to server and test funcs");
return;
}
if (m_bLogedIn==false)
{
QMessageBox::warning(this,"Please log in the host first!","get uuid and login");
return;
}
saveIni();
QString strMsg = ui->plainTextEdit_msg_to_client->toPlainText();
QByteArray arrMsg(strMsg.toStdString().c_str());
QByteArray array(sizeof(SMARTLINK_MSG) - 1,0);
char * ptr = array.data();
SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr;
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(ui->lineEdit_boxid->text().toUInt()) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(ui->lineEdit_client_uuid->text().toUInt()) & 0xffffffff );;
pMsg->data_length = arrMsg.size();
pMsg->Reserved2 = 0;
array.append(arrMsg);
//3/10 possibility to send a data block to server
client->SendData(array);
}
......@@ -71,6 +71,7 @@ public slots:
void on_pushButton_box_download_uid_clicked();
void on_pushButton_client_downHost_clicked();
void on_pushButton_clientLogout_clicked();
void on_pushButton_sendToClient_clicked();
};
......
......@@ -101,7 +101,7 @@
<enum>QTabWidget::Triangular</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab">
<attribute name="title">
......@@ -377,6 +377,67 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>Send Msg</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QLabel" name="label_11">
<property name="text">
<string>Msg</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit_msg_to_client"/>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Send To UUID:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_client_uuid"/>
</item>
<item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_sendToClient">
<property name="text">
<string>Send</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Recieved:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit_msg_recieved"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_Message">
<attribute name="title">
<string>Logs</string>
......
......@@ -30,7 +30,6 @@ namespace SmartLink{
bool regisitClientUUID(st_clientNode_baseTrans *);
st_clientNode_baseTrans * clientNodeFromUUID(quint32);
st_clientNode_baseTrans * clientNodeFromSocket(QObject *);
bool SendToNode(quint32 uuid, const QByteArray & msg);
//Heart beating and healthy
void KickDeadClients();
int heartBeatingThrd();
......@@ -116,6 +115,9 @@ namespace SmartLink{
//a block of data has been successfuly sent
void on_evt_RemoteData_transferred(QObject * /*svrHandle*/,qint64 /*bytes sent*/);
//send msg to uuid
bool SendToNode(quint32 uuid, const QByteArray & msg);
};
}
#endif // ST_CLIENT_TABLE_H
......@@ -90,11 +90,12 @@ namespace SmartLink{
}
if (m_destin_uuid == 0xffffffff)
return false;
//Transfer
if (false==m_pClientTable->SendToNode(this->m_destin_uuid , m_currStBlock))
{
//Send to Client
// //Transfer
// if (false==m_pClientTable->SendToNode(this->m_destin_uuid , m_currStBlock))
// {
}
// }
}
delCurrBlock = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册