From 03d0ea9df2abe164ab8575d1add29f3d51711f67 Mon Sep 17 00:00:00 2001
From: tianduanrui <2407223896@qq.com>
Date: Mon, 23 Apr 2018 14:44:46 +0800
Subject: [PATCH 1/2] fix qqt client error
---
examples/qqtnetworkexample/mainwindow.cpp | 2 +-
examples/qqtnetworkexample/mainwindow.ui | 20 +++++++++----------
.../qqtnetworkexample/qqtclientprotocol.h | 5 +++--
3 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/examples/qqtnetworkexample/mainwindow.cpp b/examples/qqtnetworkexample/mainwindow.cpp
index f348e720..a5c4a7d3 100644
--- a/examples/qqtnetworkexample/mainwindow.cpp
+++ b/examples/qqtnetworkexample/mainwindow.cpp
@@ -30,5 +30,5 @@ void MainWindow::on_pushButton_clicked()
void MainWindow::on_recv_say_hello ( QString a )
{
pline() << a;
- //ui->plainTextEdit->appendPlainText ( a );
+ ui->textBrowser->append(a + "\r\n");
}
diff --git a/examples/qqtnetworkexample/mainwindow.ui b/examples/qqtnetworkexample/mainwindow.ui
index 99b21a43..ddd648f6 100644
--- a/examples/qqtnetworkexample/mainwindow.ui
+++ b/examples/qqtnetworkexample/mainwindow.ui
@@ -14,16 +14,6 @@
MainWindow
-
-
-
- 40
- 30
- 251
- 141
-
-
-
@@ -47,6 +37,16 @@
+
+
+
+ 30
+ 10
+ 256
+ 192
+
+
+
diff --git a/examples/qqtnetworkexample/qqtclientprotocol.h b/examples/qqtnetworkexample/qqtclientprotocol.h
index 409aa506..7e9c33cd 100644
--- a/examples/qqtnetworkexample/qqtclientprotocol.h
+++ b/examples/qqtnetworkexample/qqtclientprotocol.h
@@ -141,7 +141,7 @@ public slots:
protected:
//报文的最小长度
virtual quint16 minlength() override {
- return 0x00;
+ return 0x03;
}
//报文的最大长度
virtual quint16 maxlength() override {
@@ -159,6 +159,7 @@ protected:
//报文现在被切开,发了进来,第二个字节是cmd,解析出来,在函数里处理处理数据,告诉业务层,拿到数据了干点什么。
virtual bool dispatcher ( const QByteArray& m ) override { //message
+
bool ret = true;
QQtClientMessage qMsg;
@@ -170,7 +171,7 @@ protected:
recvCommand1 ( qMsg );
break;
- case 0x0100://protocol command 2
+ case 0x0A://protocol command 2
recvCommand2 ( qMsg );
break;
From dcfc204c5f5e7051201a9f388315766ca6740116 Mon Sep 17 00:00:00 2001
From: AbelTian <2407223896@qq.com>
Date: Mon, 23 Apr 2018 15:47:37 +0800
Subject: [PATCH 2/2] fix qqt client
---
examples/qqtnetworkexample/qqtclientprotocol.h | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/examples/qqtnetworkexample/qqtclientprotocol.h b/examples/qqtnetworkexample/qqtclientprotocol.h
index 7e9c33cd..710d91a5 100644
--- a/examples/qqtnetworkexample/qqtclientprotocol.h
+++ b/examples/qqtnetworkexample/qqtclientprotocol.h
@@ -1,4 +1,4 @@
-#ifndef QQTCLIENTPROTOCOL_H
+#ifndef QQTCLIENTPROTOCOL_H
#define QQTCLIENTPROTOCOL_H
#include
@@ -149,11 +149,19 @@ protected:
}
virtual quint16 splitter ( const QByteArray& l ) override { //stream
+ pline() << l[0] << l[1] << l[2] << l[3] << l[4] << l[5] << l[6] << l[7];
+ for ( int i = 0; i < l.size(); i++ ) {
+ pline() << l[i];
+ }
+
QByteArray s0 = l.left ( 3 );
quint8 start = 0;
quint16 size = 0;
- s0 << start;
- s0 << size;
+ pline() << s0[0] << s0[1] << s0[2];
+
+ s0 >> start;
+ s0 >> size;
+ pline() << start << size;
return size;
}