改进部分代码

This commit is contained in:
feiyangqingyun
2021-04-13 09:36:48 +08:00
parent bc5acc612e
commit 788da958fb
40 changed files with 1181 additions and 289 deletions

View File

@@ -42,11 +42,11 @@ void WebClient::textFrameReceived(const QString &data, bool isLastFrame)
emit receiveData(ip, port, buffer);
//自动回复数据,可以回复的数据是以;隔开,每行可以带多个;所以这里不需要继续判断
if (App::DebugWebServer) {
int count = App::Keys.count();
if (AppConfig::DebugWebServer) {
int count = AppConfig::Keys.count();
for (int i = 0; i < count; i++) {
if (App::Keys.at(i) == buffer) {
sendData(App::Values.at(i));
if (AppConfig::Keys.at(i) == buffer) {
sendData(AppConfig::Values.at(i));
break;
}
}
@@ -56,7 +56,7 @@ void WebClient::textFrameReceived(const QString &data, bool isLastFrame)
void WebClient::binaryFrameReceived(const QByteArray &data, bool isLastFrame)
{
QString buffer;
if (App::HexReceiveWebClient) {
if (AppConfig::HexReceiveWebClient) {
buffer = QUIHelper::byteArrayToHexStr(data);
} else {
buffer = QString(data);
@@ -78,13 +78,13 @@ void WebClient::binaryMessageReceived(const QByteArray &data)
void WebClient::sendData(const QString &data)
{
QByteArray buffer;
if (App::HexSendWebServer) {
if (AppConfig::HexSendWebServer) {
buffer = QUIHelper::hexStrToByteArray(data);
} else {
buffer = data.toUtf8();
}
if (App::AsciiWebServer) {
if (AppConfig::AsciiWebServer) {
socket->sendTextMessage(data);
} else {
socket->sendBinaryMessage(buffer);