1
0
mirror of https://gitee.com/drabel/LibQQt.git synced 2025-01-04 10:18:44 +08:00

add highgrade level code

This commit is contained in:
tianduanrui 2018-04-22 13:03:28 +08:00
parent ce03ba2365
commit f3243f204d
104 changed files with 1144 additions and 281 deletions

View File

@ -43,9 +43,12 @@ SUBDIRS += examples/qqtaudioexample
#SUBDIRS += examples/tabwidgetexamples #SUBDIRS += examples/tabwidgetexamples
#need QZXing, default closed. #need QZXing, default closed.
#SUBDIRS += examples/qrcodeexample #SUBDIRS += examples/qrcodeexample
#必开 #必开 客户端的 basic
SUBDIRS += examples/qqtnetworkexample SUBDIRS += examples/qqtnetworkexample
SUBDIRS += demo/QQtNetworkCreator SUBDIRS += demo/QQtNetworkCreator
#服务器的 highgrade
SUBDIRS += examples/qqtserverexample
SUBDIRS += demo/QQtServerCreator
#greaterThan(QT_VERSION, 4.6.0):SUBDIRS += test/voicetest #greaterThan(QT_VERSION, 4.6.0):SUBDIRS += test/voicetest
#mac:lessThan(QT_MAJOR_VERSION , 5):SUBDIRS -= test/voicetest #mac:lessThan(QT_MAJOR_VERSION , 5):SUBDIRS -= test/voicetest

View File

@ -23,12 +23,12 @@ LibQQt现进行正式发布版本v2.1.6.0,欢迎工程师们使用。
# 详细介绍 # 详细介绍
1. 支持绘制图表 1. 支持绘制图表
- QQtChart (compatiable with QChart and QCustomPlot) - [QQtChart](src/charts/qqtchartview.h) (compatiable with QChart and QCustomPlot)
2. 支持检测USB设备热插拔 2. 支持检测USB设备热插拔
3. 自定义了一部分特殊需要的控件用来解决Qt的嵌入式bug。 3. 自定义了一部分特殊需要的控件用来解决Qt的嵌入式bug。
- 包括完全使用图片的checkboxswitchbutton - 包括完全使用图片的checkboxswitchbutton
- QQtTabWidget解决QtTab不能竖排横显文字的问题 - QQtTabWidget解决QtTab不能竖排横显文字的问题
- QQt进度条解决Qt进度条在Dialog中导致系统死机的问题 - QQt进度条解决Qt进度条在Dialog中导致系统死机的问题(e-linux)
1. 添加精美控件 1. 添加精美控件
- 包括复杂的圆盘进度条, SpeedMeter - 包括复杂的圆盘进度条, SpeedMeter
- 包括有多种效果的Widget、Dialog - 包括有多种效果的Widget、Dialog
@ -36,7 +36,7 @@ LibQQt现进行正式发布版本v2.1.6.0,欢迎工程师们使用。
- 九宫格技术展示图片 - 九宫格技术展示图片
- Html解析器 - Html解析器
- 以及未列出的等20余种自定义widget。 - 以及未列出的等20余种自定义widget。
4. 有线和无线网络自动连接管理 4. 有线和无线网络自动连接管理
6. 解决Qt4.8.7在嵌入式屏幕上QGraphics系统不正常绘画的问题 6. 解决Qt4.8.7在嵌入式屏幕上QGraphics系统不正常绘画的问题
7. QQt输入法 7. QQt输入法
- 重写了UI适配多种屏幕 - 重写了UI适配多种屏幕
@ -47,36 +47,37 @@ LibQQt现进行正式发布版本v2.1.6.0,欢迎工程师们使用。
4. QQtTreeView添加Qt4内部没有TreeView 4. QQtTreeView添加Qt4内部没有TreeView
- 包括QQtXmlTreeModel、QQtJsonTreeModel、QQtFileSystemTreeModel、QQtSqlTreeModel - 包括QQtXmlTreeModel、QQtJsonTreeModel、QQtFileSystemTreeModel、QQtSqlTreeModel
5. 支持工程的版本变更 5. 支持工程的版本变更
- 在qqt_version.pri里面是QQt的版本和源文件内版本宏定义 - 在[qqt_version.pri](src/qqt_version.pri)里面是QQt的版本和源文件内版本宏定义
- 在app_version.pri里面是App的版本和源文件内版本宏定义 - 在[app_version.pri](app/app_version.pri)里面是App的版本和源文件内版本宏定义
6. QQt通讯套件。 6. QQt通讯套件。
- 通讯口类 - 通讯口类
- QQtSerialPort 兼容QSerialPort and QextSerialPort - QQtSerialPort 兼容QSerialPort and QextSerialPort
- [QQtSocketTcpClient](src/network/qqtsockettcpclient.h)、QQtSocketTcpServer、QQtSocketUdpClient - [QQtTcpClient](src/network/qqttcpclient.h)、QQtTcpServer、QQtUdpClient
- QQtBluetoothSocket +QQtBluetoothManager - QQtBluetoothSocket +QQtBluetoothManager
- QQtWebAccessManager支持http、ftp等主流协议高并发传输。 - QQtWebAccessManager支持http、ftp等主流协议高并发传输。
- QQtWebSocket接口 - [QQtWebSocket](src/network/qqtwebsocketclient.h) 接口
- 协议虚类(接口类) [QQtProtocol](src/network/qqtprotocol.h) QQtWebSocketProtocol - 协议虚类(接口类) [QQtProtocol](src/network/qqtprotocol.h) QQtWebSocketProtocol
- 报文虚类(接口类) [QQtMessage](src/network/qqtmessage.h) - 报文虚类(接口类) [QQtMessage](src/network/qqtmessage.h)
7. 添加应用中常用的form 7. 添加应用中常用的form
8. 支持多页TableWidget 8. 支持多页表格 [QQtMPTableWidget](src/widgets/qqtmptablewidget.h)
9. 添加 [QQtApplication](src/frame/qqtapplication.h)支持入门级、通用级、专用级嵌入式App所必须的初始化内容 9. 添加 [QQtApplication](src/frame/qqtapplication.h)支持入门级、通用级、专用级嵌入式App所必须的初始化内容
5. 支持Qt5.9.2 5. 支持Qt5.9.2
0. 跨平台支持macOS、iOS、Android、Windows、Linux、MIPS、ARM等。 0. 跨平台支持macOS、iOS、Android、Windows、Linux、MIPS、ARM等。
1. 添加矢量图形widgets 1. 添加矢量图形widgets
- 比如 QQtSvgProgressbar - 比如 QQtSvgProgressbar
- QQtSvgCheckBox - QQtSvgCheckBox
- [QQtSvgPushButton](src/exquisite/svgwidgets/qqtsvgpushbutton.h)
2. 添加核心类之[QQtDictionary](src/core/qqtdictionary.h) 2. 添加核心类之[QQtDictionary](src/core/qqtdictionary.h)
- 化解C Plus Plus中没有字典类别的尴尬。 - 化解C Plus Plus中没有字典类别的尴尬。
3. 添加Multi Link工程管理pri组 3. 添加Multi Link工程管理pri组
- Multi Link technology既多链接工程管理技术。 - [Multi Link technology](src/app_multi_link_technology.pri),既多链接工程管理技术。
- 基于qmake用户可以轻易的链接LibQQt和添加自定义library。 - 基于qmake用户可以轻易的链接LibQQt和添加自定义library。
4. 添加gif support Widgets 4. 添加gif support Widgets
- 可以方便的设置动态按钮等。 - 可以方便的设置动态按钮等。
- 有QQtGifWidget、QQtGifButton等。 - 有[QQtGifWidget](src/exquisite/gifwidgets/qqtgifwidget.h)、QQtGifButton等。
5. 升级多媒体音频 5. 升级多媒体音频
- 添加内存服务器,处理内存和设备之间的数据交互。 - 添加内存服务器,处理内存和设备之间的数据交互。
- QQtAudioManager、 - [QQtAudioManager](src/multimedia/qqtaudiomanager.h)
- QQtWavAudioInput、QQtWavAudioOutput、QQtWavAudioManager、 - QQtWavAudioInput、QQtWavAudioOutput、QQtWavAudioManager、
- QQtWavSoundEffect - QQtWavSoundEffect
- 将AudioDevice、wav输入输出文件当做一个设备进行读写App处理获取到的声音。 - 将AudioDevice、wav输入输出文件当做一个设备进行读写App处理获取到的声音。

View File

@ -9,5 +9,6 @@ APP_BUILD_VERSION = 0
APP_VERSION = $${APP_MAJOR_VERSION}.$${APP_MINOR_VERSION}.$${APP_PATCH_VERSION} APP_VERSION = $${APP_MAJOR_VERSION}.$${APP_MINOR_VERSION}.$${APP_PATCH_VERSION}
APP_VERSION4 = $${APP_MAJOR_VERSION}.$${APP_MINOR_VERSION}.$${APP_PATCH_VERSION}.$${APP_BUILD_VERSION} APP_VERSION4 = $${APP_MAJOR_VERSION}.$${APP_MINOR_VERSION}.$${APP_PATCH_VERSION}.$${APP_BUILD_VERSION}
DEFINES += APP_VERSION=$${APP_VERSION}
message (Build $${TARGET} version: $$APP_VERSION4) message (Build $${TARGET} version: $$APP_VERSION4)
unix:VERSION = $${APP_VERSION} unix:VERSION = $${APP_VERSION}

View File

@ -30,7 +30,7 @@
6. QQt通讯套件。 6. QQt通讯套件。
- 通讯口类 - 通讯口类
- QQtSerialPort 兼容QSerialPort and QextSerialPort - QQtSerialPort 兼容QSerialPort and QextSerialPort
- [QQtSocketTcpClient](src/network/qqtsockettcpclient.h)、QQtSocketTcpServer、QQtSocketUdpClient - [QQtTcpClient](src/network/qqttcpclient.h)、QQtTcpServer、QQtUdpClient
- QQtBluetoothSocket +QQtBluetoothManager - QQtBluetoothSocket +QQtBluetoothManager
- QQtWebAccessManager支持http、ftp等主流协议高并发传输。 - QQtWebAccessManager支持http、ftp等主流协议高并发传输。
- QQtWebSocket接口 - QQtWebSocket接口

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const QQtUserMessage& msg )
QQtUserProtocol* QQtUserConnectionInstance ( QObject* parent ) QQtUserProtocol* QQtUserConnectionInstance ( QObject* parent )
{ {
static QQtUserProtocol* p0 = NULL; static QQtUserProtocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new QQtUserProtocol ( parent ); p0 = new QQtUserProtocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class QQtUserMessage : public QQtMessage class QQtUserMessage : public QQtMessage
{ {

View File

@ -1,9 +1,9 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <QApplication> #include <QQtApplication>
int main(int argc, char *argv[]) int main ( int argc, char* argv[] )
{ {
QApplication a(argc, argv); QQtApplication a ( argc, argv );
MainWindow w; MainWindow w;
w.show(); w.show();

View File

@ -0,0 +1,34 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-04-22T12:55:57
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = QQtServerCreator
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui

View File

@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@ -0,0 +1,14 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}

View File

@ -0,0 +1,22 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,24 @@
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

View File

@ -5,8 +5,8 @@
#include "qqtinput.h" #include "qqtinput.h"
#include "qqtmsgbox.h" #include "qqtmsgbox.h"
#include "qqtframe.h" #include "qqtframe.h"
#include "qqtsockettcpclient.h" #include "qqttcpclient.h"
#include "qqtsockettcpserver.h" #include "qqttcpserver.h"
#include "qqtserialport.h" #include "qqtserialport.h"
#include "qqtpluginwatcher.h" #include "qqtpluginwatcher.h"
#include "qqtversion.h" #include "qqtversion.h"
@ -16,7 +16,7 @@
*/ */
void QQTLanServer ( QObject* parent = 0 ) void QQTLanServer ( QObject* parent = 0 )
{ {
static QQtSocketTcpServer* s = new QQtSocketTcpServer ( parent ); static QQtTcpServer* s = new QQtTcpServer ( parent );
s->listen ( QHostAddress::Any, 8000 ); s->listen ( QHostAddress::Any, 8000 );
s->installedProtocol(); s->installedProtocol();
@ -108,13 +108,13 @@ QQTApp::QQTApp ( int& argc, char** argv ) : QApplication ( argc, argv )
QObject::connect ( QQtPluginWatcher::Instance(), SIGNAL ( storageChanged ( int ) ), QObject::connect ( QQtPluginWatcher::Instance(), SIGNAL ( storageChanged ( int ) ),
this, SLOT ( slotUPanAutoRun ( int ) ) ); this, SLOT ( slotUPanAutoRun ( int ) ) );
#endif #endif
//QQtSocketTcpClient //QQtTcpClient
//QQTCloudClientInstance(this); //QQTCloudClientInstance(this);
#ifdef __EMBEDDED_LINUX__ #ifdef __EMBEDDED_LINUX__
//QQTEthManager //QQTEthManager
QQtEthenetManager::Instance ( this ); QQtEthenetManager::Instance ( this );
#endif #endif
//QQtSocketTcpServer //QQtTcpServer
//QQTPeerPort //QQTPeerPort
//QQTPeerPortInstance(this); //QQTPeerPortInstance(this);

View File

@ -6,8 +6,8 @@
#include "qqtinput.h" #include "qqtinput.h"
#include "qqtmsgbox.h" #include "qqtmsgbox.h"
#include "qqtframe.h" #include "qqtframe.h"
#include "qqtsockettcpclient.h" #include "qqttcpclient.h"
#include "qqtsockettcpserver.h" #include "qqttcpserver.h"
#include "qqtserialport.h" #include "qqtserialport.h"
#include "qqtpluginwatcher.h" #include "qqtpluginwatcher.h"
@ -16,7 +16,7 @@
*/ */
void QQTLanServer ( QObject* parent = 0 ) void QQTLanServer ( QObject* parent = 0 )
{ {
static QQtSocketTcpServer* s = new QQtSocketTcpServer ( parent ); static QQtTcpServer* s = new QQtTcpServer ( parent );
s->listen ( QHostAddress::Any, 8000 ); s->listen ( QHostAddress::Any, 8000 );
s->installedProtocol(); s->installedProtocol();
@ -108,13 +108,13 @@ QQTApp::QQTApp ( int& argc, char** argv ) : QApplication ( argc, argv )
QObject::connect ( QQtPluginWatcher::Instance(), SIGNAL ( storageChanged ( int ) ), QObject::connect ( QQtPluginWatcher::Instance(), SIGNAL ( storageChanged ( int ) ),
this, SLOT ( slotUPanAutoRun ( int ) ) ); this, SLOT ( slotUPanAutoRun ( int ) ) );
#endif #endif
//QQtSocketTcpClient //QQtTcpClient
//QQTCloudClientInstance(this); //QQTCloudClientInstance(this);
#ifdef __EMBEDDED_LINUX__ #ifdef __EMBEDDED_LINUX__
//QQTEthManager //QQTEthManager
QQtEthenetManager::Instance ( this ); QQtEthenetManager::Instance ( this );
#endif #endif
//QQtSocketTcpServer //QQtTcpServer
//QQTPeerPort //QQTPeerPort
//QQTPeerPortInstance(this); //QQTPeerPortInstance(this);

View File

@ -3,16 +3,16 @@
#include "qqtcore.h" #include "qqtcore.h"
#include "qqt-qt.h" #include "qqt-qt.h"
QQtSocketTcpClient* QQTUpgradeClientInstance ( QObject* parent ) QQtTcpClient* QQTUpgradeClientInstance ( QObject* parent )
{ {
static QQtSocketTcpClient* cli = NULL; static QQtTcpClient* cli = NULL;
if ( !cli ) if ( !cli )
{ {
QStringList ip; QStringList ip;
ip << "222.175.114.244" << "124.133.1.54"; ip << "222.175.114.244" << "124.133.1.54";
//"www.QQToo.com" //"www.QQToo.com"
cli = new QQtSocketTcpClient ( parent ); cli = new QQtTcpClient ( parent );
cli->SetServerIPAddress ( ip ); cli->SetServerIPAddress ( ip );
cli->SetServerPort ( 8089 ); cli->SetServerPort ( 8089 );
} }
@ -20,15 +20,15 @@ QQtSocketTcpClient* QQTUpgradeClientInstance ( QObject* parent )
return cli; return cli;
} }
QQtSocketTcpClient* QQTCloudClientInstance ( QObject* parent ) QQtTcpClient* QQTCloudClientInstance ( QObject* parent )
{ {
static QQtSocketTcpClient* cli = NULL; static QQtTcpClient* cli = NULL;
if ( !cli ) if ( !cli )
{ {
QStringList ip; QStringList ip;
ip << "222.175.114.244" << "124.133.1.54"; ip << "222.175.114.244" << "124.133.1.54";
cli = new QQtSocketTcpClient ( parent ); cli = new QQtTcpClient ( parent );
cli->SetServerIPAddress ( ip ); cli->SetServerIPAddress ( ip );
cli->SetServerPort ( 7079 ); cli->SetServerPort ( 7079 );
} }

View File

@ -4,7 +4,7 @@
#include <QTimer> #include <QTimer>
#include "qqtprotocol.h" #include "qqtprotocol.h"
#include "qqtnetworkmessage.h" #include "qqtnetworkmessage.h"
#include "qqtsockettcpclient.h" #include "qqttcpclient.h"
#define _TCPCMD_HEART 0x0010 #define _TCPCMD_HEART 0x0010
#define _TCPCMD_HEARTBEATRESP 0x8010 #define _TCPCMD_HEARTBEATRESP 0x8010
@ -424,10 +424,10 @@ public:
}; };
QQtSocketTcpClient *QQTUpgradeClientInstance(QObject *parent); QQtTcpClient *QQTUpgradeClientInstance(QObject *parent);
QQtSocketTcpClient *QQTCloudClientInstance(QObject *parent); QQtTcpClient *QQTCloudClientInstance(QObject *parent);
#endif // QQTCLOUDPROTOCOL_H #endif // QQTCLOUDPROTOCOL_H

View File

@ -28,9 +28,9 @@ bool QQTLanProtocol::dispatcher ( const QByteArray& m )
} }
QQtSocketTcpServer* QQTSingleServer ( QObject* parent ) QQtTcpServer* QQTSingleServer ( QObject* parent )
{ {
static QQtSocketTcpServer* s = new QQtSocketTcpServer ( parent ); static QQtTcpServer* s = new QQtTcpServer ( parent );
s->listen ( QHostAddress::Any, 8000 ); s->listen ( QHostAddress::Any, 8000 );
return s; return s;
} }
@ -38,12 +38,12 @@ QQtSocketTcpServer* QQTSingleServer ( QObject* parent )
QQTLanProtocol* QQtLanServer ( QObject* parent ) QQTLanProtocol* QQtLanServer ( QObject* parent )
{ {
static QQTLanProtocol* p0 = NULL; static QQTLanProtocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new QQTLanProtocol ( parent ); p0 = new QQTLanProtocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );

View File

@ -3,7 +3,7 @@
#include "qqtprotocol.h" #include "qqtprotocol.h"
#include "qqtmessage.h" #include "qqtmessage.h"
#include "qqtsockettcpserver.h" #include "qqttcpserver.h"
class QQtLanMessage : public QQtMessage class QQtLanMessage : public QQtMessage
{ {
@ -58,7 +58,7 @@ public:
bool dispatcher ( const QByteArray& m ) override; bool dispatcher ( const QByteArray& m ) override;
}; };
QQtSocketTcpServer* QQTSingleServer ( QObject* parent ); QQtTcpServer* QQTSingleServer ( QObject* parent );
//new //new
QQTLanProtocol* QQtLanServer ( QObject* parent = 0 ); QQTLanProtocol* QQtLanServer ( QObject* parent = 0 );
#endif // QQTLANPROTOCOL_H #endif // QQTLANPROTOCOL_H

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const QQtUserMessage1& msg )
QQtUserProtocol1* QQtUserConnectionInstance1 ( QObject* parent ) QQtUserProtocol1* QQtUserConnectionInstance1 ( QObject* parent )
{ {
static QQtUserProtocol1* p0 = NULL; static QQtUserProtocol1* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new QQtUserProtocol1 ( parent ); p0 = new QQtUserProtocol1 ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class QQtUserMessage1 : public QQtMessage class QQtUserMessage1 : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const QQtUserMessage2& msg )
QQtUserProtocol2* QQtUserConnectionInstance2 ( QObject* parent ) QQtUserProtocol2* QQtUserConnectionInstance2 ( QObject* parent )
{ {
static QQtUserProtocol2* p0 = NULL; static QQtUserProtocol2* p0 = NULL;
static QQtSocketTcpClient* s0 = NULL; static QQtTcpClient* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new QQtUserProtocol2 ( parent ); p0 = new QQtUserProtocol2 ( parent );
s0 = new QQtSocketTcpClient ( parent ); s0 = new QQtTcpClient ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->connectToHost ( QHostAddress ( "192.168.0.100" ), 8000 ); s0->connectToHost ( QHostAddress ( "192.168.0.100" ), 8000 );
} }

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpclient.h> #include <qqttcpclient.h>
#include <QHostAddress> #include <QHostAddress>

View File

@ -1,5 +1,5 @@
#include "quserbluetoothprotocol.h" #include "quserbluetoothprotocol.h"
#include "qqtsocketbluetoothclient.h" #include "qqtbluetoothclient.h"
#include "qqtbluetoothmanager.h" #include "qqtbluetoothmanager.h"
QUserBluetoothProtocol::QUserBluetoothProtocol ( QObject* parent ) : QObject ( parent ) QUserBluetoothProtocol::QUserBluetoothProtocol ( QObject* parent ) : QObject ( parent )
@ -7,15 +7,15 @@ QUserBluetoothProtocol::QUserBluetoothProtocol ( QObject* parent ) : QObject ( p
} }
QQtSocketBluetoothClient* QQtUserBluetoothClientInstance ( QObject* parent ) QQtBluetoothClient* QQtUserBluetoothClientInstance ( QObject* parent )
{ {
static QQtSocketBluetoothClient* cli = nullptr; static QQtBluetoothClient* cli = nullptr;
if ( !cli ) if ( !cli )
{ {
QQtBluetoothManager* inst = QQtBluetoothManager::Instance ( parent ); QQtBluetoothManager* inst = QQtBluetoothManager::Instance ( parent );
inst->getDeviceList().first().address(); inst->getDeviceList().first().address();
cli = new QQtSocketBluetoothClient ( QBluetoothServiceInfo::RfcommProtocol, parent ); cli = new QQtBluetoothClient ( QBluetoothServiceInfo::RfcommProtocol, parent );
cli->setServiceAddress ( inst->getDeviceList().first().address() ); cli->setServiceAddress ( inst->getDeviceList().first().address() );
} }

View File

@ -2,7 +2,7 @@
#define QUSERBLUETOOTHPROTOCOL_H #define QUSERBLUETOOTHPROTOCOL_H
#include <QObject> #include <QObject>
#include "qqtsocketbluetoothclient.h" #include "qqtbluetoothclient.h"
class QUserBluetoothProtocol : public QObject class QUserBluetoothProtocol : public QObject
{ {
@ -15,6 +15,6 @@ signals:
public slots: public slots:
}; };
QQtSocketBluetoothClient* QQtUserBluetoothClientInstance ( QObject* parent = 0 ); QQtBluetoothClient* QQtUserBluetoothClientInstance ( QObject* parent = 0 );
#endif // QUSERBLUETOOTHPROTOCOL_H #endif // QUSERBLUETOOTHPROTOCOL_H

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode0Message& msg )
UserNode0Protocol* UserNode0ConnectionInstance ( QObject* parent ) UserNode0Protocol* UserNode0ConnectionInstance ( QObject* parent )
{ {
static UserNode0Protocol* p0 = NULL; static UserNode0Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode0Protocol ( parent ); p0 = new UserNode0Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode0Message : public QQtMessage class UserNode0Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode1Message& msg )
UserNode1Protocol* UserNode1ConnectionInstance ( QObject* parent ) UserNode1Protocol* UserNode1ConnectionInstance ( QObject* parent )
{ {
static UserNode1Protocol* p0 = NULL; static UserNode1Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode1Protocol ( parent ); p0 = new UserNode1Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode1Message : public QQtMessage class UserNode1Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode2Message& msg )
UserNode2Protocol* UserNode2ConnectionInstance ( QObject* parent ) UserNode2Protocol* UserNode2ConnectionInstance ( QObject* parent )
{ {
static UserNode2Protocol* p0 = NULL; static UserNode2Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode2Protocol ( parent ); p0 = new UserNode2Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode2Message : public QQtMessage class UserNode2Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode3Message& msg )
UserNode3Protocol* UserNode3ConnectionInstance ( QObject* parent ) UserNode3Protocol* UserNode3ConnectionInstance ( QObject* parent )
{ {
static UserNode3Protocol* p0 = NULL; static UserNode3Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode3Protocol ( parent ); p0 = new UserNode3Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode3Message : public QQtMessage class UserNode3Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode4Message& msg )
UserNode4Protocol* UserNode4ConnectionInstance ( QObject* parent ) UserNode4Protocol* UserNode4ConnectionInstance ( QObject* parent )
{ {
static UserNode4Protocol* p0 = NULL; static UserNode4Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode4Protocol ( parent ); p0 = new UserNode4Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode4Message : public QQtMessage class UserNode4Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode5Message& msg )
UserNode5Protocol* UserNode5ConnectionInstance ( QObject* parent ) UserNode5Protocol* UserNode5ConnectionInstance ( QObject* parent )
{ {
static UserNode5Protocol* p0 = NULL; static UserNode5Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode5Protocol ( parent ); p0 = new UserNode5Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode5Message : public QQtMessage class UserNode5Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode6Message& msg )
UserNode6Protocol* UserNode6ConnectionInstance ( QObject* parent ) UserNode6Protocol* UserNode6ConnectionInstance ( QObject* parent )
{ {
static UserNode6Protocol* p0 = NULL; static UserNode6Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode6Protocol ( parent ); p0 = new UserNode6Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode6Message : public QQtMessage class UserNode6Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode7Message& msg )
UserNode7Protocol* UserNode7ConnectionInstance ( QObject* parent ) UserNode7Protocol* UserNode7ConnectionInstance ( QObject* parent )
{ {
static UserNode7Protocol* p0 = NULL; static UserNode7Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode7Protocol ( parent ); p0 = new UserNode7Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode7Message : public QQtMessage class UserNode7Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode8Message& msg )
UserNode8Protocol* UserNode8ConnectionInstance ( QObject* parent ) UserNode8Protocol* UserNode8ConnectionInstance ( QObject* parent )
{ {
static UserNode8Protocol* p0 = NULL; static UserNode8Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode8Protocol ( parent ); p0 = new UserNode8Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode8Message : public QQtMessage class UserNode8Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserNode9Message& msg )
UserNode9Protocol* UserNode9ConnectionInstance ( QObject* parent ) UserNode9Protocol* UserNode9ConnectionInstance ( QObject* parent )
{ {
static UserNode9Protocol* p0 = NULL; static UserNode9Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserNode9Protocol ( parent ); p0 = new UserNode9Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserNode9Message : public QQtMessage class UserNode9Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest0Message& msg )
UserTest0Protocol* UserTest0ConnectionInstance ( QObject* parent ) UserTest0Protocol* UserTest0ConnectionInstance ( QObject* parent )
{ {
static UserTest0Protocol* p0 = NULL; static UserTest0Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest0Protocol ( parent ); p0 = new UserTest0Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest0Message : public QQtMessage class UserTest0Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest1Message& msg )
UserTest1Protocol* UserTest1ConnectionInstance ( QObject* parent ) UserTest1Protocol* UserTest1ConnectionInstance ( QObject* parent )
{ {
static UserTest1Protocol* p0 = NULL; static UserTest1Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest1Protocol ( parent ); p0 = new UserTest1Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest1Message : public QQtMessage class UserTest1Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest2Message& msg )
UserTest2Protocol* UserTest2ConnectionInstance ( QObject* parent ) UserTest2Protocol* UserTest2ConnectionInstance ( QObject* parent )
{ {
static UserTest2Protocol* p0 = NULL; static UserTest2Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest2Protocol ( parent ); p0 = new UserTest2Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest2Message : public QQtMessage class UserTest2Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest3Message& msg )
UserTest3Protocol* UserTest3ConnectionInstance ( QObject* parent ) UserTest3Protocol* UserTest3ConnectionInstance ( QObject* parent )
{ {
static UserTest3Protocol* p0 = NULL; static UserTest3Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest3Protocol ( parent ); p0 = new UserTest3Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest3Message : public QQtMessage class UserTest3Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest4Message& msg )
UserTest4Protocol* UserTest4ConnectionInstance ( QObject* parent ) UserTest4Protocol* UserTest4ConnectionInstance ( QObject* parent )
{ {
static UserTest4Protocol* p0 = NULL; static UserTest4Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest4Protocol ( parent ); p0 = new UserTest4Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest4Message : public QQtMessage class UserTest4Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest5Message& msg )
UserTest5Protocol* UserTest5ConnectionInstance ( QObject* parent ) UserTest5Protocol* UserTest5ConnectionInstance ( QObject* parent )
{ {
static UserTest5Protocol* p0 = NULL; static UserTest5Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest5Protocol ( parent ); p0 = new UserTest5Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest5Message : public QQtMessage class UserTest5Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest6Message& msg )
UserTest6Protocol* UserTest6ConnectionInstance ( QObject* parent ) UserTest6Protocol* UserTest6ConnectionInstance ( QObject* parent )
{ {
static UserTest6Protocol* p0 = NULL; static UserTest6Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest6Protocol ( parent ); p0 = new UserTest6Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest6Message : public QQtMessage class UserTest6Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest7Message& msg )
UserTest7Protocol* UserTest7ConnectionInstance ( QObject* parent ) UserTest7Protocol* UserTest7ConnectionInstance ( QObject* parent )
{ {
static UserTest7Protocol* p0 = NULL; static UserTest7Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest7Protocol ( parent ); p0 = new UserTest7Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest7Message : public QQtMessage class UserTest7Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest8Message& msg )
UserTest8Protocol* UserTest8ConnectionInstance ( QObject* parent ) UserTest8Protocol* UserTest8ConnectionInstance ( QObject* parent )
{ {
static UserTest8Protocol* p0 = NULL; static UserTest8Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest8Protocol ( parent ); p0 = new UserTest8Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest8Message : public QQtMessage class UserTest8Message : public QQtMessage
{ {

View File

@ -12,12 +12,12 @@ QDebug& operator << ( QDebug& dbg, const UserTest9Message& msg )
UserTest9Protocol* UserTest9ConnectionInstance ( QObject* parent ) UserTest9Protocol* UserTest9ConnectionInstance ( QObject* parent )
{ {
static UserTest9Protocol* p0 = NULL; static UserTest9Protocol* p0 = NULL;
static QQtSocketTcpServer* s0 = NULL; static QQtTcpServer* s0 = NULL;
if ( !p0 && !s0 ) if ( !p0 && !s0 )
{ {
p0 = new UserTest9Protocol ( parent ); p0 = new UserTest9Protocol ( parent );
s0 = new QQtSocketTcpServer ( parent ); s0 = new QQtTcpServer ( parent );
s0->installProtocol ( p0 ); s0->installProtocol ( p0 );
s0->listen ( QHostAddress::Any, 8000 ); s0->listen ( QHostAddress::Any, 8000 );

View File

@ -3,7 +3,7 @@
#include <qqtmessage.h> #include <qqtmessage.h>
#include <qqtprotocol.h> #include <qqtprotocol.h>
#include <qqtsockettcpserver.h> #include <qqttcpserver.h>
class UserTest9Message : public QQtMessage class UserTest9Message : public QQtMessage
{ {

View File

@ -0,0 +1,11 @@
#include "mainwindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

View File

@ -0,0 +1,14 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}

View File

@ -0,0 +1,22 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H

View File

@ -0,0 +1,24 @@
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>MainWindow</string>
</property>
<widget class="QMenuBar" name="menuBar" />
<widget class="QToolBar" name="mainToolBar" />
<widget class="QWidget" name="centralWidget" />
<widget class="QStatusBar" name="statusBar" />
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

View File

@ -0,0 +1,34 @@
#-------------------------------------------------
#
# Project created by QtCreator 2018-04-22T12:57:27
#
#-------------------------------------------------
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = qqtserverexample
TEMPLATE = app
# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui

View File

@ -1,6 +1,6 @@
#include "cedianudpserver.h" #include "cedianudpserver.h"
#include <QNetworkDatagram> #include <QNetworkDatagram>
CedianUdpServer::CedianUdpServer ( QObject* parent ) : QQtSocketUdpClient ( parent ) CedianUdpServer::CedianUdpServer ( QObject* parent ) : QQtUdpClient ( parent )
{ {
} }

View File

@ -1,10 +1,10 @@
#ifndef CEDIANUDPSERVER_H #ifndef CEDIANUDPSERVER_H
#define CEDIANUDPSERVER_H #define CEDIANUDPSERVER_H
#include <qqtsocketudpclient.h> #include <qqtudpclient.h>
#include <qqtcore.h> #include <qqtcore.h>
class CedianUdpServer : public QQtSocketUdpClient class CedianUdpServer : public QQtUdpClient
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -34,7 +34,7 @@ contains(CONFIG, administrator){
################################################################ ################################################################
##Multi-link technology ##Multi-link technology
################################################################ ################################################################
include($$PWD/app_multi_link_config.pri) include($$PWD/app_multi_link_technology.pri)
################################################################ ################################################################
##link QQt ##link QQt

View File

@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------- #--------------------------------------------------------------------------------
#app_multi_link_configure.pri #app_multi_link_technology.pri
##Multi-link technology (Multi Link technology) ##Multi-link technology (Multi Link technology)
##Multi-link 技术,支持多链接库增删的一门工程管理技术。 ##Multi-link 技术,支持多链接库增删的一门工程管理技术。

View File

@ -1,33 +1,33 @@
#include "qqtsocketbluetoothserver.h" #include "qqtbluetoothserver.h"
#include "qqtnetwork.h" #include "qqtnetwork.h"
#include "qqtsocketbluetoothclient.h" #include "qqtbluetoothclient.h"
QQtSocketBluetoothServer::QQtSocketBluetoothServer ( QBluetoothServiceInfo::Protocol serverType, QQtBluetoothServer::QQtBluetoothServer ( QBluetoothServiceInfo::Protocol serverType,
QObject* parent ) : QBluetoothServer ( serverType, parent ) QObject* parent ) : QBluetoothServer ( serverType, parent )
{ {
connect ( this, SIGNAL ( newConnection() ), connect ( this, SIGNAL ( newConnection() ),
this, SLOT ( comingNewConnection() ) ); this, SLOT ( comingNewConnection() ) );
} }
QQtSocketBluetoothServer::~QQtSocketBluetoothServer() QQtBluetoothServer::~QQtBluetoothServer()
{ {
close(); close();
} }
void QQtSocketBluetoothServer::comingNewConnection() void QQtBluetoothServer::comingNewConnection()
{ {
if ( !hasPendingConnections() ) if ( !hasPendingConnections() )
return; return;
QBluetoothSocket* comingSocket = nextPendingConnection(); QBluetoothSocket* comingSocket = nextPendingConnection();
QQtSocketBluetoothClient* clientSocket = new QQtSocketBluetoothClient ( this ); QQtBluetoothClient* clientSocket = new QQtBluetoothClient ( this );
connect ( clientSocket, SIGNAL ( disconnected() ), clientSocket, SLOT ( deleteLater() ) ); connect ( clientSocket, SIGNAL ( disconnected() ), clientSocket, SLOT ( deleteLater() ) );
clientSocket->installProtocol ( m_protocol ); clientSocket->installProtocol ( m_protocol );
clientSocket->setSocketDescriptor ( comingSocket->socketDescriptor(), QBluetoothServiceInfo::RfcommProtocol ); clientSocket->setSocketDescriptor ( comingSocket->socketDescriptor(), QBluetoothServiceInfo::RfcommProtocol );
} }
void QQtSocketBluetoothServer::installProtocol ( QQtProtocol* stack ) void QQtBluetoothServer::installProtocol ( QQtProtocol* stack )
{ {
if ( m_protocol ) if ( m_protocol )
return; return;
@ -35,7 +35,7 @@ void QQtSocketBluetoothServer::installProtocol ( QQtProtocol* stack )
m_protocol = stack; m_protocol = stack;
} }
void QQtSocketBluetoothServer::uninstallProtocol ( QQtProtocol* stack ) void QQtBluetoothServer::uninstallProtocol ( QQtProtocol* stack )
{ {
Q_UNUSED ( stack ) Q_UNUSED ( stack )
@ -45,7 +45,7 @@ void QQtSocketBluetoothServer::uninstallProtocol ( QQtProtocol* stack )
m_protocol = NULL; m_protocol = NULL;
} }
QQtProtocol* QQtSocketBluetoothServer::installedProtocol() QQtProtocol* QQtBluetoothServer::installedProtocol()
{ {
return m_protocol; return m_protocol;
} }

View File

@ -5,12 +5,12 @@
#include "qqtprotocol.h" #include "qqtprotocol.h"
#include <qqt-local.h> #include <qqt-local.h>
class QQTSHARED_EXPORT QQtSocketBluetoothServer : public QBluetoothServer class QQTSHARED_EXPORT QQtBluetoothServer : public QBluetoothServer
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QQtSocketBluetoothServer ( QBluetoothServiceInfo::Protocol serverType, QObject* parent = nullptr ); explicit QQtBluetoothServer ( QBluetoothServiceInfo::Protocol serverType, QObject* parent = nullptr );
~QQtSocketBluetoothServer(); ~QQtBluetoothServer();
void installProtocol ( QQtProtocol* stack ); void installProtocol ( QQtProtocol* stack );
void uninstallProtocol ( QQtProtocol* stack ); void uninstallProtocol ( QQtProtocol* stack );

View File

@ -0,0 +1,70 @@
#include "qqtprotocolmanager.h"
QQtProtocolManager::QQtProtocolManager ( QObject* parent ) : QObject ( parent )
{
}
QQtProtocolManager::~QQtProtocolManager()
{
}
#define pline2() pline() << metaObject()->className()
void QQtProtocolManager::translator ( const QByteArray& bytes )
{
// queued conn and queued package;
// direct conn and direct package;
static QByteArray sqbaBlockOnNet;
sqbaBlockOnNet += bytes;
//qint64 aaa = bytesAvailable();
//pline() << aaa;
do
{
quint16 nBlockLen = this->splitter ( sqbaBlockOnNet );
pline2() << sqbaBlockOnNet.size() << "..." << nBlockLen;
if ( sqbaBlockOnNet.length() < nBlockLen || nBlockLen < minlength() )
{
/*
*
*/
return;
}
else if ( nBlockLen > maxlength() )
{
/*
*
*/
sqbaBlockOnNet.clear();
pline2() << "forbidden package" << sqbaBlockOnNet.length() << nBlockLen;
return;
}
else if ( sqbaBlockOnNet.length() > nBlockLen )
{
/*
*
*
* :
*/
pline2() << "stick package" << sqbaBlockOnNet.length() << nBlockLen;
QByteArray netData;
netData.resize ( nBlockLen );
sqbaBlockOnNet >> netData;
dispatcher ( netData );
continue;
}
/*
*
*/
dispatcher ( sqbaBlockOnNet );
break;
} while ( 1 );
sqbaBlockOnNet.clear();
}

View File

@ -0,0 +1,63 @@
#ifndef QQTPROTOCOLMANAGER_H
#define QQTPROTOCOLMANAGER_H
#include <QObject>
#include <qqt-local.h>
#include "qqtmessage.h"
#include "qqtcore.h"
/**
* @brief The QQtProtocolManager class
* very good ideology and impliment
*/
class QQTSHARED_EXPORT QQtProtocolManager : public QObject
{
Q_OBJECT
public:
explicit QQtProtocolManager ( QObject* parent = 0 );
virtual ~QQtProtocolManager();
/*
* [emit] write(...)
*/
Q_SIGNALS:
qint64 write ( const QByteArray& );
public:
/**
* @brief
* QQtTcpSocket用的
* @param Qt通讯口readAll()bytes
* @return
*/
void translator ( const QByteArray& bytes );
/*
* need override
*/
protected:
/**
* @brief
* @return
*/
inline virtual quint16 minlength() { return 0; }
/**
* @brief
* @return
*/
inline virtual quint16 maxlength() { return 0xFFFF; }
/**
* @brief
* @param
* @return
*/
inline virtual quint16 splitter ( const QByteArray& ) { return 0; }
/**
* @brief
* @param
* @return 0 no dispatched(others) 1 dispatched(own)
*/
inline virtual bool dispatcher ( const QByteArray& ) { return 0; }
};
#endif // QQTPROTOCOLMANAGER_H

View File

@ -0,0 +1,70 @@
#include "qqtserverprotocol.h"
QQtServerProtocol::QQtServerProtocol ( QObject* parent ) : QObject ( parent )
{
}
QQtServerProtocol::~QQtServerProtocol()
{
}
#define pline2() pline() << metaObject()->className()
void QQtServerProtocol::translator ( const QByteArray& bytes )
{
// queued conn and queued package;
// direct conn and direct package;
static QByteArray sqbaBlockOnNet;
sqbaBlockOnNet += bytes;
//qint64 aaa = bytesAvailable();
//pline() << aaa;
do
{
quint16 nBlockLen = this->splitter ( sqbaBlockOnNet );
pline2() << sqbaBlockOnNet.size() << "..." << nBlockLen;
if ( sqbaBlockOnNet.length() < nBlockLen || nBlockLen < minlength() )
{
/*
*
*/
return;
}
else if ( nBlockLen > maxlength() )
{
/*
*
*/
sqbaBlockOnNet.clear();
pline2() << "forbidden package" << sqbaBlockOnNet.length() << nBlockLen;
return;
}
else if ( sqbaBlockOnNet.length() > nBlockLen )
{
/*
*
*
* :
*/
pline2() << "stick package" << sqbaBlockOnNet.length() << nBlockLen;
QByteArray netData;
netData.resize ( nBlockLen );
sqbaBlockOnNet >> netData;
dispatcher ( netData );
continue;
}
/*
*
*/
dispatcher ( sqbaBlockOnNet );
break;
} while ( 1 );
sqbaBlockOnNet.clear();
}

View File

@ -0,0 +1,63 @@
#ifndef QQTSERVERPROTOCOL_H
#define QQTSERVERPROTOCOL_H
#include <QObject>
#include <qqt-local.h>
#include "qqtmessage.h"
#include "qqtcore.h"
/**
* @brief The QQtServerProtocol class
* very good ideology and impliment
*/
class QQTSHARED_EXPORT QQtServerProtocol : public QObject
{
Q_OBJECT
public:
explicit QQtServerProtocol ( QObject* parent = 0 );
virtual ~QQtServerProtocol();
/*
* [emit] write(...)
*/
Q_SIGNALS:
qint64 write ( const QByteArray& );
public:
/**
* @brief
* QQtTcpSocket用的
* @param Qt通讯口readAll()bytes
* @return
*/
void translator ( const QByteArray& bytes );
/*
* need override
*/
protected:
/**
* @brief
* @return
*/
inline virtual quint16 minlength() { return 0; }
/**
* @brief
* @return
*/
inline virtual quint16 maxlength() { return 0xFFFF; }
/**
* @brief
* @param
* @return
*/
inline virtual quint16 splitter ( const QByteArray& ) { return 0; }
/**
* @brief
* @param
* @return 0 no dispatched(others) 1 dispatched(own)
*/
inline virtual bool dispatcher ( const QByteArray& ) { return 0; }
};
#endif // QQTSERVERPROTOCOL_H

View File

@ -1,27 +1,27 @@
#include "qqtsockettcpserver.h" #include "qqttcpserver.h"
#include "qqtnetwork.h" #include "qqtnetwork.h"
QQtSocketTcpServer::QQtSocketTcpServer ( QObject* parent ) : QQtTcpServer::QQtTcpServer ( QObject* parent ) :
QTcpServer ( parent ) QTcpServer ( parent )
{ {
} }
QQtSocketTcpServer::~QQtSocketTcpServer() QQtTcpServer::~QQtTcpServer()
{ {
if ( isListening() ) if ( isListening() )
close(); close();
} }
void QQtSocketTcpServer::incomingConnection ( qintptr handle ) void QQtTcpServer::incomingConnection ( qintptr handle )
{ {
QQtSocketTcpClient* clientSocket = new QQtSocketTcpClient ( this ); QQtTcpClient* clientSocket = new QQtTcpClient ( this );
clientSocket->setSocketDescriptor ( handle ); clientSocket->setSocketDescriptor ( handle );
connect ( clientSocket, SIGNAL ( disconnected() ), clientSocket, SLOT ( deleteLater() ) ); connect ( clientSocket, SIGNAL ( disconnected() ), clientSocket, SLOT ( deleteLater() ) );
clientSocket->installProtocol ( m_protocol ); clientSocket->installProtocol ( m_protocol );
} }
void QQtSocketTcpServer::installProtocol ( QQtProtocol* stack ) void QQtTcpServer::installProtocol ( QQtProtocol* stack )
{ {
if ( m_protocol ) if ( m_protocol )
return; return;
@ -29,7 +29,7 @@ void QQtSocketTcpServer::installProtocol ( QQtProtocol* stack )
m_protocol = stack; m_protocol = stack;
} }
void QQtSocketTcpServer::uninstallProtocol ( QQtProtocol* stack ) void QQtTcpServer::uninstallProtocol ( QQtProtocol* stack )
{ {
Q_UNUSED ( stack ) Q_UNUSED ( stack )
@ -39,7 +39,7 @@ void QQtSocketTcpServer::uninstallProtocol ( QQtProtocol* stack )
m_protocol = NULL; m_protocol = NULL;
} }
QQtProtocol* QQtSocketTcpServer::installedProtocol() QQtProtocol* QQtTcpServer::installedProtocol()
{ {
return m_protocol; return m_protocol;
} }

View File

@ -3,16 +3,16 @@
#include <QTcpServer> #include <QTcpServer>
#include "qqtprotocol.h" #include "qqtprotocol.h"
#include "qqtsockettcpclient.h" #include "qqttcpclient.h"
#include "qqt-local.h" #include "qqt-local.h"
#include "qqtcore.h" #include "qqtcore.h"
class QQTSHARED_EXPORT QQtSocketTcpServer : public QTcpServer class QQTSHARED_EXPORT QQtTcpServer : public QTcpServer
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QQtSocketTcpServer ( QObject* parent = 0 ); explicit QQtTcpServer ( QObject* parent = 0 );
~QQtSocketTcpServer(); ~QQtTcpServer();
void installProtocol ( QQtProtocol* stack ); void installProtocol ( QQtProtocol* stack );
void uninstallProtocol ( QQtProtocol* stack ); void uninstallProtocol ( QQtProtocol* stack );

View File

@ -1,6 +1,6 @@
#include "qqtsocketudpclient.h" #include "qqtudpserver.h"
QQtSocketUdpClient::QQtSocketUdpClient ( QObject* parent ) : QUdpSocket ( parent ) QQtUdpServer::QQtUdpServer ( QObject* parent ) : QUdpSocket ( parent )
{ {
connect ( this, SIGNAL ( stateChanged ( QAbstractSocket::SocketState ) ), this, connect ( this, SIGNAL ( stateChanged ( QAbstractSocket::SocketState ) ), this,
SLOT ( socketStateChanged ( QAbstractSocket::SocketState ) ) ); SLOT ( socketStateChanged ( QAbstractSocket::SocketState ) ) );
@ -23,7 +23,7 @@ QQtSocketUdpClient::QQtSocketUdpClient ( QObject* parent ) : QUdpSocket ( parent
m_protocol = NULL; m_protocol = NULL;
} }
void QQtSocketUdpClient::installProtocol ( QQtUdpProtocol* stack ) void QQtUdpServer::installProtocol ( QQtUdpProtocol* stack )
{ {
if ( m_protocol ) if ( m_protocol )
return; return;
@ -33,7 +33,7 @@ void QQtSocketUdpClient::installProtocol ( QQtUdpProtocol* stack )
this, SLOT ( slotWriteDatagram ( QByteArray, QHostAddress, quint16 ) ) ); this, SLOT ( slotWriteDatagram ( QByteArray, QHostAddress, quint16 ) ) );
} }
void QQtSocketUdpClient::uninstallProtocol ( QQtUdpProtocol* stack ) void QQtUdpServer::uninstallProtocol ( QQtUdpProtocol* stack )
{ {
Q_UNUSED ( stack ) Q_UNUSED ( stack )
@ -45,22 +45,22 @@ void QQtSocketUdpClient::uninstallProtocol ( QQtUdpProtocol* stack )
m_protocol = NULL; m_protocol = NULL;
} }
QQtUdpProtocol* QQtSocketUdpClient::installedProtocol() QQtUdpProtocol* QQtUdpServer::installedProtocol()
{ {
return m_protocol; return m_protocol;
} }
void QQtSocketUdpClient::domainHostFound() void QQtUdpServer::domainHostFound()
{ {
pline(); pline();
} }
/** /**
* @brief QQtSocketUdpClient::socketStateChanged * @brief QQtUdpClient::socketStateChanged
* @param eSocketState * @param eSocketState
* *
*/ */
void QQtSocketUdpClient::socketStateChanged ( QAbstractSocket::SocketState eSocketState ) void QQtUdpServer::socketStateChanged ( QAbstractSocket::SocketState eSocketState )
{ {
pline() << eSocketState; pline() << eSocketState;
@ -85,11 +85,11 @@ void QQtSocketUdpClient::socketStateChanged ( QAbstractSocket::SocketState eSock
} }
/** /**
* @brief QQtSocketUdpClient::socketErrorOccured * @brief QQtUdpClient::socketErrorOccured
* @param e * @param e
* *
*/ */
void QQtSocketUdpClient::socketErrorOccured ( QAbstractSocket::SocketError e ) void QQtUdpServer::socketErrorOccured ( QAbstractSocket::SocketError e )
{ {
/* /*
* *
@ -109,10 +109,10 @@ void QQtSocketUdpClient::socketErrorOccured ( QAbstractSocket::SocketError e )
} }
/** /**
* @brief QQtSocketUdpClient::socketConnected * @brief QQtUdpClient::socketConnected
* *
*/ */
void QQtSocketUdpClient::socketConnected() void QQtUdpServer::socketConnected()
{ {
pline() << peerName() << peerAddress().toString() << peerPort(); pline() << peerName() << peerAddress().toString() << peerPort();
/* /*
@ -122,26 +122,26 @@ void QQtSocketUdpClient::socketConnected()
} }
/** /**
* @brief QQtSocketUdpClient::socketDisconnect * @brief QQtUdpClient::socketDisconnect
* *
*/ */
void QQtSocketUdpClient::socketDisconnect() void QQtUdpServer::socketDisconnect()
{ {
pline(); pline();
} }
void QQtSocketUdpClient::updateProgress ( qint64 bytes ) void QQtUdpServer::updateProgress ( qint64 bytes )
{ {
Q_UNUSED ( bytes ) Q_UNUSED ( bytes )
//pline() << bytes; //pline() << bytes;
} }
qint64 QQtSocketUdpClient::slotWriteDatagram ( const QByteArray& datagram, const QHostAddress& host, quint16 port ) qint64 QQtUdpServer::slotWriteDatagram ( const QByteArray& datagram, const QHostAddress& host, quint16 port )
{ {
return writeDatagram ( datagram, host, port ); return writeDatagram ( datagram, host, port );
} }
void QQtSocketUdpClient::readyReadData() void QQtUdpServer::readyReadData()
{ {
/*为什么用while?*/ //Qt4 没有那么高级的一次性读取的接口?有 /*为什么用while?*/ //Qt4 没有那么高级的一次性读取的接口?有
while ( hasPendingDatagrams() ) while ( hasPendingDatagrams() )

View File

@ -0,0 +1,65 @@
#ifndef QQTUDPSERVER_H
#define QQTUDPSERVER_H
#include <QUdpSocket>
#include "qqtudpprotocol.h"
#include "qqtudpclient.h"
#include "qqt-local.h"
#include "qqtcore.h"
/*
* Udp通信服务器
*
* Udp通信服务器和客户端操作区别
*
* TCP一样需要处理多个客户端通信
*
*
*
* IP
*/
class QQtUdpServer : public QUdpSocket
{
Q_OBJECT
public:
explicit QQtUdpServer ( QObject* parent = nullptr );
virtual ~QQtUdpServer() {}
void installProtocol ( QQtUdpProtocol* stack );
void uninstallProtocol ( QQtUdpProtocol* stack );
QQtUdpProtocol* installedProtocol();
QList<QQtUdpClient*> getClientList() const {
return m_client_list;
}
signals:
void signalConnecting();
void signalConnectSucc();
void signalConnectFail();//
void signalDisConnectSucc();//maybe
void signalDisConnectFail();//
void signalUpdateProgress ( qint64 value );
public slots:
protected slots:
void readyReadData();
private slots:
void domainHostFound();
void socketStateChanged ( QAbstractSocket::SocketState );
void socketErrorOccured ( QAbstractSocket::SocketError );
void socketConnected();
void socketDisconnect();
void updateProgress ( qint64 bytes );
//如果有一个同名的槽参数不同并且被用宏控制起来Qt编译不过。
//Qt的元对象系统解析信号和槽函数不支持宏。
//QtUdpSocketwriteDatagram不是个槽。
qint64 slotWriteDatagram ( const QByteArray& datagram,
const QHostAddress& host, quint16 port );
private:
QQtUdpProtocol* m_protocol;
QList<QQtUdpClient*> m_client_list;
};
#endif // QQTUDPSERVER_H

View File

@ -0,0 +1 @@
#include "qqtudpserverprotocol.h"

View File

@ -0,0 +1,77 @@
#ifndef QQTUDPSERVELPROTOCOL_H
#define QQTUDPSERVELPROTOCOL_H
#include <QObject>
#include <qqt-local.h>
#include "qqtmessage.h"
#include "qqtcore.h"
#define QT_VERSION_DATAGRAM QT_VERSION_CHECK(5,8,0)
#if QT_VERSION > QT_VERSION_DATAGRAM
#include <QNetworkDatagram>
#endif
/*
*/
class QQTSHARED_EXPORT QQtUdpServerProtocol : public QObject
{
Q_OBJECT
public:
explicit QQtUdpServerProtocol ( QObject* parent = nullptr ) : QObject ( parent ) {
}
virtual ~QQtUdpServerProtocol() {}
#if QT_VERSION > QT_VERSION_DATAGRAM
qint64 writeDatagram ( const QNetworkDatagram& datagram ) {
QByteArray dg = datagram.data();
QHostAddress addr = datagram.destinationAddress();
int port = datagram.destinationPort();
emit writeDatagram ( dg, addr, ( quint16 ) port );
}
#endif
signals:
qint64 writeDatagram ( const QByteArray& datagram,
const QHostAddress& host, quint16 port );
public slots:
protected:
/**
* @brief
* @brief need override
* @param
* @return 0 no dispatched(others) 1 dispatched(own)
*/
inline virtual bool dispatcher ( const QByteArray& datagram,
const QHostAddress& host, quint16 port ) {
return 0;
}
/*
* dispatcher
*/
#if QT_VERSION > QT_VERSION_DATAGRAM
inline virtual bool dispatcher ( const QNetworkDatagram& ) { return 0; }
#endif
public:
/**
* @brief
* @brief QQtUdpSocket用的
* @param Qt通讯口readAll()bytes
* @return
*/
void translator ( const QByteArray& datagram,
const QHostAddress& host, quint16 port ) {
dispatcher ( datagram, host, port );
}
#if QT_VERSION > QT_VERSION_DATAGRAM
void translator ( const QNetworkDatagram& datagram ) {
dispatcher ( datagram );
}
#endif
};
#endif // QQTUDPSERVELPROTOCOL_H

View File

@ -1,18 +1,18 @@
#include "qqtsocketbluetoothclient.h" #include "qqtbluetoothclient.h"
#include <qqtcore.h> #include <qqtcore.h>
QQtSocketBluetoothClient::QQtSocketBluetoothClient ( QBluetoothServiceInfo::Protocol socketType, QObject* parent ) : QQtBluetoothClient::QQtBluetoothClient ( QBluetoothServiceInfo::Protocol socketType, QObject* parent ) :
QBluetoothSocket ( socketType, parent ) QBluetoothSocket ( socketType, parent )
{ {
initSocket(); initSocket();
} }
QQtSocketBluetoothClient::QQtSocketBluetoothClient ( QObject* parent ) : QBluetoothSocket ( parent ) QQtBluetoothClient::QQtBluetoothClient ( QObject* parent ) : QBluetoothSocket ( parent )
{ {
initSocket(); initSocket();
} }
void QQtSocketBluetoothClient::initSocket() void QQtBluetoothClient::initSocket()
{ {
connect ( this, SIGNAL ( stateChanged ( QBluetoothSocket::SocketState ) ), connect ( this, SIGNAL ( stateChanged ( QBluetoothSocket::SocketState ) ),
this, SLOT ( socketStateChanged ( QBluetoothSocket::SocketState ) ) ); this, SLOT ( socketStateChanged ( QBluetoothSocket::SocketState ) ) );
@ -39,7 +39,7 @@ void QQtSocketBluetoothClient::initSocket()
m_protocol = nullptr; m_protocol = nullptr;
} }
void QQtSocketBluetoothClient::installProtocol ( QQtProtocol* stack ) void QQtBluetoothClient::installProtocol ( QQtProtocol* stack )
{ {
if ( m_protocol ) if ( m_protocol )
return; return;
@ -49,7 +49,7 @@ void QQtSocketBluetoothClient::installProtocol ( QQtProtocol* stack )
this, SLOT ( write ( const QByteArray& ) ) ); this, SLOT ( write ( const QByteArray& ) ) );
} }
void QQtSocketBluetoothClient::uninstallProtocol ( QQtProtocol* stack ) void QQtBluetoothClient::uninstallProtocol ( QQtProtocol* stack )
{ {
Q_UNUSED ( stack ) Q_UNUSED ( stack )
@ -61,12 +61,12 @@ void QQtSocketBluetoothClient::uninstallProtocol ( QQtProtocol* stack )
m_protocol = NULL; m_protocol = NULL;
} }
QQtProtocol* QQtSocketBluetoothClient::installedProtocol() QQtProtocol* QQtBluetoothClient::installedProtocol()
{ {
return m_protocol; return m_protocol;
} }
void QQtSocketBluetoothClient::sendConnectMessage() void QQtBluetoothClient::sendConnectMessage()
{ {
pline() << isOpen() << state(); pline() << isOpen() << state();
@ -90,7 +90,7 @@ void QQtSocketBluetoothClient::sendConnectMessage()
} }
int QQtSocketBluetoothClient::sendDisConnectFromHost() int QQtBluetoothClient::sendDisConnectFromHost()
{ {
pline() << isOpen() << state(); pline() << isOpen() << state();
@ -110,40 +110,40 @@ int QQtSocketBluetoothClient::sendDisConnectFromHost()
} }
/** /**
* @brief QQtSocketBluetoothClient::socketStateChanged * @brief QQtBluetoothClient::socketStateChanged
* @param eSocketState * @param eSocketState
* *
*/ */
void QQtSocketBluetoothClient::socketStateChanged ( QBluetoothSocket::SocketState eSocketState ) void QQtBluetoothClient::socketStateChanged ( QBluetoothSocket::SocketState eSocketState )
{ {
pline() << eSocketState; pline() << eSocketState;
switch ( eSocketState ) switch ( eSocketState )
{ {
case ServiceLookupState: case ServiceLookupState:
case ConnectingState: case ConnectingState:
break; break;
case ConnectedState: case ConnectedState:
break; break;
case ClosingState: case ClosingState:
break; break;
case UnconnectedState: case UnconnectedState:
break; break;
default: default:
break; break;
} }
} }
/** /**
* @brief QQtSocketBluetoothClient::socketErrorOccured * @brief QQtBluetoothClient::socketErrorOccured
* @param e * @param e
* *
*/ */
void QQtSocketBluetoothClient::socketErrorOccured ( QBluetoothSocket::SocketError e ) void QQtBluetoothClient::socketErrorOccured ( QBluetoothSocket::SocketError e )
{ {
/* /*
* *
@ -152,18 +152,18 @@ void QQtSocketBluetoothClient::socketErrorOccured ( QBluetoothSocket::SocketErro
switch ( e ) switch ( e )
{ {
case HostNotFoundError: case HostNotFoundError:
default: default:
emit signalConnectFail(); emit signalConnectFail();
break; break;
} }
} }
/** /**
* @brief QQtSocketBluetoothClient::socketConnected * @brief QQtBluetoothClient::socketConnected
* *
*/ */
void QQtSocketBluetoothClient::socketConnected() void QQtBluetoothClient::socketConnected()
{ {
pline() << peerName() << peerAddress().toString() << peerPort(); pline() << peerName() << peerAddress().toString() << peerPort();
/* /*
@ -173,21 +173,21 @@ void QQtSocketBluetoothClient::socketConnected()
} }
/** /**
* @brief QQtSocketBluetoothClient::socketDisconnect * @brief QQtBluetoothClient::socketDisconnect
* *
*/ */
void QQtSocketBluetoothClient::socketDisconnect() void QQtBluetoothClient::socketDisconnect()
{ {
pline(); pline();
} }
void QQtSocketBluetoothClient::updateProgress ( qint64 bytes ) void QQtBluetoothClient::updateProgress ( qint64 bytes )
{ {
Q_UNUSED ( bytes ) Q_UNUSED ( bytes )
//pline() << bytes; //pline() << bytes;
} }
void QQtSocketBluetoothClient::connectToSingelHost() void QQtBluetoothClient::connectToSingelHost()
{ {
if ( !m_uuid.isNull() ) if ( !m_uuid.isNull() )
{ {
@ -208,7 +208,7 @@ void QQtSocketBluetoothClient::connectToSingelHost()
void QQtSocketBluetoothClient::readyReadData() void QQtBluetoothClient::readyReadData()
{ {
QByteArray bytes; QByteArray bytes;
bytes = readAll(); bytes = readAll();

View File

@ -5,13 +5,13 @@
#include "qqtprotocol.h" #include "qqtprotocol.h"
#include "qqt-local.h" #include "qqt-local.h"
class QQTSHARED_EXPORT QQtSocketBluetoothClient : public QBluetoothSocket class QQTSHARED_EXPORT QQtBluetoothClient : public QBluetoothSocket
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QQtSocketBluetoothClient ( QBluetoothServiceInfo::Protocol socketType = QBluetoothServiceInfo::RfcommProtocol, explicit QQtBluetoothClient ( QBluetoothServiceInfo::Protocol socketType = QBluetoothServiceInfo::RfcommProtocol,
QObject* parent = nullptr ); QObject* parent = nullptr );
explicit QQtSocketBluetoothClient ( QObject* parent = nullptr ); explicit QQtBluetoothClient ( QObject* parent = nullptr );
/** /**
* @brief setServiceInfo * @brief setServiceInfo

View File

@ -1,4 +1,4 @@
#include "qqtsockettcpclient.h" #include "qqttcpclient.h"
#include <QTcpSocket> #include <QTcpSocket>
#include <QHostInfo> #include <QHostInfo>
@ -6,7 +6,7 @@
#include "qqtnetwork.h" #include "qqtnetwork.h"
#include "qqtcore.h" #include "qqtcore.h"
QQtSocketTcpClient::QQtSocketTcpClient ( QObject* parent ) : QQtTcpClient::QQtTcpClient ( QObject* parent ) :
QTcpSocket ( parent ) QTcpSocket ( parent )
{ {
connect ( this, SIGNAL ( stateChanged ( QAbstractSocket::SocketState ) ), this, connect ( this, SIGNAL ( stateChanged ( QAbstractSocket::SocketState ) ), this,
@ -43,11 +43,11 @@ QQtSocketTcpClient::QQtSocketTcpClient ( QObject* parent ) :
m_protocol = NULL; m_protocol = NULL;
} }
QQtSocketTcpClient::~QQtSocketTcpClient() QQtTcpClient::~QQtTcpClient()
{ {
} }
void QQtSocketTcpClient::installProtocol ( QQtProtocol* stack ) void QQtTcpClient::installProtocol ( QQtProtocol* stack )
{ {
if ( m_protocol ) if ( m_protocol )
return; return;
@ -57,7 +57,7 @@ void QQtSocketTcpClient::installProtocol ( QQtProtocol* stack )
this, SLOT ( write ( const QByteArray& ) ) ); this, SLOT ( write ( const QByteArray& ) ) );
} }
void QQtSocketTcpClient::uninstallProtocol ( QQtProtocol* stack ) void QQtTcpClient::uninstallProtocol ( QQtProtocol* stack )
{ {
Q_UNUSED ( stack ) Q_UNUSED ( stack )
@ -69,12 +69,12 @@ void QQtSocketTcpClient::uninstallProtocol ( QQtProtocol* stack )
m_protocol = NULL; m_protocol = NULL;
} }
QQtProtocol* QQtSocketTcpClient::installedProtocol() QQtProtocol* QQtTcpClient::installedProtocol()
{ {
return m_protocol; return m_protocol;
} }
void QQtSocketTcpClient::SendConnectMessage() void QQtTcpClient::SendConnectMessage()
{ {
pline() << isValid() << isOpen() << state(); pline() << isValid() << isOpen() << state();
@ -98,7 +98,7 @@ void QQtSocketTcpClient::SendConnectMessage()
} }
int QQtSocketTcpClient::SendDisConnectFromHost() int QQtTcpClient::SendDisConnectFromHost()
{ {
pline() << isValid() << isOpen() << state(); pline() << isValid() << isOpen() << state();
@ -118,17 +118,17 @@ int QQtSocketTcpClient::SendDisConnectFromHost()
return true; return true;
} }
void QQtSocketTcpClient::domainHostFound() void QQtTcpClient::domainHostFound()
{ {
pline(); pline();
} }
/** /**
* @brief QQtSocketTcpClient::socketStateChanged * @brief QQtTcpClient::socketStateChanged
* @param eSocketState * @param eSocketState
* *
*/ */
void QQtSocketTcpClient::socketStateChanged ( QAbstractSocket::SocketState eSocketState ) void QQtTcpClient::socketStateChanged ( QAbstractSocket::SocketState eSocketState )
{ {
pline() << eSocketState; pline() << eSocketState;
@ -154,11 +154,11 @@ void QQtSocketTcpClient::socketStateChanged ( QAbstractSocket::SocketState eSock
} }
/** /**
* @brief QQtSocketTcpClient::socketErrorOccured * @brief QQtTcpClient::socketErrorOccured
* @param e * @param e
* *
*/ */
void QQtSocketTcpClient::socketErrorOccured ( QAbstractSocket::SocketError e ) void QQtTcpClient::socketErrorOccured ( QAbstractSocket::SocketError e )
{ {
/* /*
* *
@ -178,10 +178,10 @@ void QQtSocketTcpClient::socketErrorOccured ( QAbstractSocket::SocketError e )
} }
/** /**
* @brief QQtSocketTcpClient::socketConnected * @brief QQtTcpClient::socketConnected
* *
*/ */
void QQtSocketTcpClient::socketConnected() void QQtTcpClient::socketConnected()
{ {
pline() << peerName() << peerAddress().toString() << peerPort(); pline() << peerName() << peerAddress().toString() << peerPort();
/* /*
@ -191,21 +191,21 @@ void QQtSocketTcpClient::socketConnected()
} }
/** /**
* @brief QQtSocketTcpClient::socketDisconnect * @brief QQtTcpClient::socketDisconnect
* *
*/ */
void QQtSocketTcpClient::socketDisconnect() void QQtTcpClient::socketDisconnect()
{ {
pline(); pline();
} }
void QQtSocketTcpClient::updateProgress ( qint64 bytes ) void QQtTcpClient::updateProgress ( qint64 bytes )
{ {
Q_UNUSED ( bytes ) Q_UNUSED ( bytes )
//pline() << bytes; //pline() << bytes;
} }
void QQtSocketTcpClient::connectToSingelHost() void QQtTcpClient::connectToSingelHost()
{ {
int contype = eConType % m_serverIP.size(); int contype = eConType % m_serverIP.size();
QString ip = m_serverIP.at ( contype ); QString ip = m_serverIP.at ( contype );
@ -215,7 +215,7 @@ void QQtSocketTcpClient::connectToSingelHost()
} }
void QQtSocketTcpClient::readyReadData() void QQtTcpClient::readyReadData()
{ {
QByteArray bytes; QByteArray bytes;
bytes = readAll(); bytes = readAll();

View File

@ -1,6 +1,6 @@
/************************************************** /**************************************************
* QQtSocketTcpClient * QQtTcpClient
* QQtSocketTcpClient实现 * QQtTcpClient实现
**************************************************/ **************************************************/
#ifndef QQT_CLIENT_H #ifndef QQT_CLIENT_H
#define QQT_CLIENT_H #define QQT_CLIENT_H
@ -25,12 +25,12 @@
* splitterdispatcher * splitterdispatcher
* *
*/ */
class QQTSHARED_EXPORT QQtSocketTcpClient : public QTcpSocket class QQTSHARED_EXPORT QQtTcpClient : public QTcpSocket
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QQtSocketTcpClient ( QObject* parent = 0 ); explicit QQtTcpClient ( QObject* parent = 0 );
virtual ~QQtSocketTcpClient(); virtual ~QQtTcpClient();
void SetServerIPAddress ( QStringList ip ) { m_serverIP = ip; } void SetServerIPAddress ( QStringList ip ) { m_serverIP = ip; }
void SetServerPort ( quint32 p = 7079 ) { m_PORT = p; } void SetServerPort ( quint32 p = 7079 ) { m_PORT = p; }

View File

@ -0,0 +1,184 @@
#include "qqtudpclient.h"
QQtUdpClient::QQtUdpClient ( QObject* parent ) : QUdpSocket ( parent )
{
connect ( this, SIGNAL ( stateChanged ( QAbstractSocket::SocketState ) ), this,
SLOT ( socketStateChanged ( QAbstractSocket::SocketState ) ) );
// connected
connect ( this, SIGNAL ( connected() ), this, SLOT ( socketConnected() ) );
// disconnected
connect ( this, SIGNAL ( disconnected() ), this, SLOT ( socketDisconnect() ) );
// domain
connect ( this, SIGNAL ( hostFound() ), this, SLOT ( domainHostFound() ) );
// error
connect ( this, SIGNAL ( error ( QAbstractSocket::SocketError ) ), this,
SLOT ( socketErrorOccured ( QAbstractSocket::SocketError ) ) );
connect ( this, SIGNAL ( readyRead() ), this, SLOT ( readyReadData() ) );
connect ( this, SIGNAL ( bytesWritten ( qint64 ) ), this, SLOT ( updateProgress ( qint64 ) ) );
connect ( this, SIGNAL ( bytesWritten ( qint64 ) ), this, SIGNAL ( signalUpdateProgress ( qint64 ) ) );
m_protocol = NULL;
}
void QQtUdpClient::installProtocol ( QQtUdpProtocol* stack )
{
if ( m_protocol )
return;
m_protocol = stack;
connect ( m_protocol, SIGNAL ( writeDatagram ( QByteArray, QHostAddress, quint16 ) ),
this, SLOT ( slotWriteDatagram ( QByteArray, QHostAddress, quint16 ) ) );
}
void QQtUdpClient::uninstallProtocol ( QQtUdpProtocol* stack )
{
Q_UNUSED ( stack )
if ( !m_protocol )
return;
disconnect ( m_protocol, SIGNAL ( writeDatagram ( QByteArray, QHostAddress, quint16 ) ),
this, SLOT ( slotWriteDatagram ( QByteArray, QHostAddress, quint16 ) ) );
m_protocol = NULL;
}
QQtUdpProtocol* QQtUdpClient::installedProtocol()
{
return m_protocol;
}
void QQtUdpClient::domainHostFound()
{
pline();
}
/**
* @brief QQtUdpClient::socketStateChanged
* @param eSocketState
*
*/
void QQtUdpClient::socketStateChanged ( QAbstractSocket::SocketState eSocketState )
{
pline() << eSocketState;
switch ( eSocketState )
{
case QAbstractSocket::HostLookupState:
case QAbstractSocket::ConnectingState:
break;
case QAbstractSocket::ConnectedState:
break;
case QAbstractSocket::ClosingState:
break;
case QAbstractSocket::UnconnectedState:
break;
default:
break;
}
}
/**
* @brief QQtUdpClient::socketErrorOccured
* @param e
*
*/
void QQtUdpClient::socketErrorOccured ( QAbstractSocket::SocketError e )
{
/*
*
*/
pline() << e;
switch ( e )
{
case QAbstractSocket::RemoteHostClosedError:
break;
case QAbstractSocket::HostNotFoundError:
default:
emit signalConnectFail();
break;
}
}
/**
* @brief QQtUdpClient::socketConnected
*
*/
void QQtUdpClient::socketConnected()
{
pline() << peerName() << peerAddress().toString() << peerPort();
/*
* socket重建
*/
emit signalConnectSucc();
}
/**
* @brief QQtUdpClient::socketDisconnect
*
*/
void QQtUdpClient::socketDisconnect()
{
pline();
}
void QQtUdpClient::updateProgress ( qint64 bytes )
{
Q_UNUSED ( bytes )
//pline() << bytes;
}
qint64 QQtUdpClient::slotWriteDatagram ( const QByteArray& datagram, const QHostAddress& host, quint16 port )
{
return writeDatagram ( datagram, host, port );
}
void QQtUdpClient::readyReadData()
{
/*为什么用while?*/ //Qt4 没有那么高级的一次性读取的接口?有
while ( hasPendingDatagrams() )
{
QByteArray bytes;
qint64 maxlen = 0;
QHostAddress host;
quint16 port;
#if QT_VERSION > QT_VERSION_DATAGRAM
/*能够一次收够一条报文?测试的能。*/
QNetworkDatagram datagram = receiveDatagram();
/*由于添加了兼容Qt4的代码以上注释起来。*/
/*数据无意义 "" -1 在此设置*/
datagram.setDestination ( this->localAddress(), this->localPort() );
//pline() << "udp sender:" << datagram.senderAddress() << datagram.senderPort();
//pline() << "udp receiver:" << datagram.destinationAddress() << datagram.destinationPort();
m_protocol->translator ( datagram );
bytes = datagram.data();
host = datagram.senderAddress();
port = datagram.senderPort();
m_protocol->translator ( bytes, host, port );
#else
qint64 size = pendingDatagramSize();
//pline() << "udp new msg size:" << size;
//这里的buf用完, 已经释放。
char* data = new char[size + 1]();
qint64 len = readDatagram ( data, size, &host, &port );
pline() << len;
bytes.setRawData ( data, size );
delete[] data;
m_protocol->translator ( bytes, host, port );
#endif
}
}

View File

@ -7,16 +7,19 @@
#include "qqtcore.h" #include "qqtcore.h"
/* /*
* Udp通信不区分服务器和客户端 * Udp通信客户端
*
*
*
* *
* IP * IP
*/ */
class QQtSocketUdpClient : public QUdpSocket class QQTSHARED_EXPORT QQtUdpClient : public QUdpSocket
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit QQtSocketUdpClient ( QObject* parent = nullptr ); explicit QQtUdpClient ( QObject* parent = nullptr );
virtual ~QQtSocketUdpClient() {} virtual ~QQtUdpClient() {}
void installProtocol ( QQtUdpProtocol* stack ); void installProtocol ( QQtUdpProtocol* stack );
void uninstallProtocol ( QQtUdpProtocol* stack ); void uninstallProtocol ( QQtUdpProtocol* stack );

View File

@ -25,7 +25,10 @@ public:
#if QT_VERSION > QT_VERSION_DATAGRAM #if QT_VERSION > QT_VERSION_DATAGRAM
qint64 writeDatagram ( const QNetworkDatagram& datagram ) { qint64 writeDatagram ( const QNetworkDatagram& datagram ) {
//emit writeDatagram(); QByteArray dg = datagram.data();
QHostAddress addr = datagram.destinationAddress();
int port = datagram.destinationPort();
emit writeDatagram ( dg, addr, ( quint16 ) port );
} }
#endif #endif
@ -56,7 +59,7 @@ protected:
public: public:
/** /**
* @brief * @brief
* @brief QQtSocketUdpSocket用的 * @brief QQtUdpSocket用的
* @param Qt通讯口readAll()bytes * @param Qt通讯口readAll()bytes
* @return * @return
*/ */

View File

@ -549,15 +549,6 @@ void QQtWebAccessManager::localUpdateDownloadProgress ( qint64 bytesReceived, qi
emit updateDownloadProgress ( session, bytesReceived, bytesTotal ); emit updateDownloadProgress ( session, bytesReceived, bytesTotal );
} }
QQtWebAccessSession* QQtWebAccessSessionManager::newWebAccessSession()
{
QUuid uuid = QUuid::createUuid();
QQtWebAccessSession* session = new QQtWebAccessSession ( this );
session->setWebAccessSessionName ( uuid.toString() );
m_listWebAccessSession.push_back ( session );
return session;
}
QNetworkReply* QQtWebAccessSessionManager::getReplyHandlerByUrl ( QString& strUrl ) QNetworkReply* QQtWebAccessSessionManager::getReplyHandlerByUrl ( QString& strUrl )
{ {
QQtWebAccessSession* s0 = NULL; QQtWebAccessSession* s0 = NULL;

View File

@ -159,7 +159,13 @@ public:
* user set * user set
* @return * @return
*/ */
QQtWebAccessSession* newWebAccessSession(); QQtWebAccessSession* newWebAccessSession() {
QUuid uuid = QUuid::createUuid();
QQtWebAccessSession* session = new QQtWebAccessSession ( this );
session->setWebAccessSessionName ( uuid.toString() );
m_listWebAccessSession.push_back ( session );
return session;
}
int getSessionCount() const { int getSessionCount() const {
return m_listWebAccessSession.count(); return m_listWebAccessSession.count();

View File

@ -3,12 +3,14 @@
#include <QtWebSockets/QWebSocket> #include <QtWebSockets/QWebSocket>
#include <qqtcore.h> #include <qqtcore.h>
#include <qqt-local.h>
/** /**
* @brief The QQtWebClient class * @brief The QQtWebClient class
* QQtWebSocketClient通过安装QQtWebProtocol来实现和RawSocket相似的通信方式 * QQtWebSocketClient通过安装QQtWebProtocol来实现和RawSocket相似的通信方式
* QQtWebProtocol是否和QQtProtocol格式相同使QQtWebProtocol继承QQtProtocol * QQtWebProtocol是否和QQtProtocol格式相同使QQtWebProtocol继承QQtProtocol
*/ */
class QQtWebSocketClient : public QWebSocket class QQTSHARED_EXPORT QQtWebSocketClient : public QWebSocket
{ {
Q_OBJECT Q_OBJECT
public: public:

View File

@ -124,8 +124,8 @@ contains (DEFINES, __EXQUISITE__) {
} }
#mathml widget #mathml widget
#注释在qqt_header.pri打开 DEFINES += __MATHSUPPORT__ #注释在qqt_header.pri打开 DEFINES += __MATHWIDGETSUPPORT__
contains (DEFINES, __MATHSUPPORT__) { contains (DEFINES, __MATHWIDGETSUPPORT__) {
contains(QKIT_PRIVATE, WIN32|WIN64) { contains(QKIT_PRIVATE, WIN32|WIN64) {
#mathml #mathml
contains (DEFINES, QQT_LIBRARY) { contains (DEFINES, QQT_LIBRARY) {
@ -138,7 +138,7 @@ contains (DEFINES, __EXQUISITE__) {
HEADERS += $$PWD/exquisite/mathml/qtmmlwidget.h HEADERS += $$PWD/exquisite/mathml/qtmmlwidget.h
} }
contains (DEFINES, __LOGICCAMERA__) { contains (DEFINES, __LOGICCAMERAMODULE__) {
#dmmu support #dmmu support
#arm mips #arm mips
#TODO: +wince +android +ios +macOS +win +linux #TODO: +wince +android +ios +macOS +win +linux

View File

@ -169,6 +169,9 @@ contains(DEFINES, __QQTCHARTS__) {
##################QQtLogSystem Module############################### ##################QQtLogSystem Module###############################
DEFINES += __QQTLOGSYSTEMSUPPORT__ DEFINES += __QQTLOGSYSTEMSUPPORT__
###########################################################################
###QQtSocketClient多组功能组件。
############
##################QQt Network Module################################## ##################QQt Network Module##################################
#包括SerialPort Bluetooth TcpUdp #包括SerialPort Bluetooth TcpUdp
#包括HttpFtp 多路的HttpFtpQQtAccessManager WebService WebSocket Gumbo #包括HttpFtp 多路的HttpFtpQQtAccessManager WebService WebSocket Gumbo
@ -266,6 +269,7 @@ contains (DEFINES, __NETWORKSUPPORT__) {
##################Exquisite Widgets Module############################### ##################Exquisite Widgets Module###############################
#if you use Exquisite widgets, open this annotation #if you use Exquisite widgets, open this annotation
#精美模块,包含不少的精美组件,这个模块可以集中开关。 #精美模块,包含不少的精美组件,这个模块可以集中开关。
#依赖基础控件
DEFINES += __EXQUISITE__ DEFINES += __EXQUISITE__
contains (DEFINES, __EXQUISITE__) { contains (DEFINES, __EXQUISITE__) {
#if you use QR encode, open this annotation #if you use QR encode, open this annotation
@ -293,16 +297,31 @@ contains (DEFINES, __EXQUISITE__) {
} }
##################Mathes Module############################### ##################Mathes Module###############################
DEFINES += __MATHSUPPORT__ DEFINES += __MATHWIDGETSUPPORT__
#LOGIC CAMERA PREVIEW #LOGIC CAMERA PREVIEW
#depend on dmmu #depend on dmmu
DEFINES += __LOGICCAMERA__ DEFINES += __LOGICCAMERAMODULE__
#opengl module #opengl module
DEFINES += __OPENGLWIDGETS__ DEFINES += __OPENGLWIDGETS__
} }
########################################################################
###这个模块名为高级模块初始置入QQtSocketServer一组组件。
###如果初中级工程师能使用这个模块完成App那么必定是高分实现力学员。
###建议中级以上工程师尝试。2018年4月22日 星期天 11点08分
############
##################HighGrade Module###############################
#if you use HighGrade module, open this annotation
#高级模块,包含不少的高级功能组件,这个模块可以集中开关。
DEFINES += __HIGHGRADE__
#依赖网络模块
!contains (DEFINES, __NETWORKSUPPORT__): DEFINES -= __HIGHGRADE__
contains (DEFINES, __HIGHGRADE__) {
}
################################################################# #################################################################
##library ##library
################################################################## ##################################################################
@ -388,6 +407,9 @@ defineReplace(qqt_header){
$${path}/exquisite/qrcode/qrdecode/zxing/win32/zxing/msvc $${path}/exquisite/qrcode/qrdecode/zxing/win32/zxing/msvc
} }
#highgrade module
command += $${path}/highgrade
return ($$command) return ($$command)
} }

View File

@ -237,16 +237,14 @@ contains (DEFINES, __NETWORKSUPPORT__) {
#tcpudpsocket #tcpudpsocket
contains(DEFINES, __TCPUDPSOCKET__){ contains(DEFINES, __TCPUDPSOCKET__){
SOURCES += \ SOURCES += \
$$PWD/network/qqtsockettcpclient.cpp \ $$PWD/network/qqttcpclient.cpp
$$PWD/network/qqtsockettcpserver.cpp
HEADERS += \ HEADERS += \
$$PWD/network/qqtsockettcpclient.h \ $$PWD/network/qqttcpclient.h
$$PWD/network/qqtsockettcpserver.h
SOURCES += \ SOURCES += \
$$PWD/network/qqtsocketudpclient.cpp $$PWD/network/qqtudpclient.cpp
HEADERS += \ HEADERS += \
$$PWD/network/qqtsocketudpclient.h $$PWD/network/qqtudpclient.h
} }
#serialport #serialport
@ -260,11 +258,9 @@ contains (DEFINES, __NETWORKSUPPORT__) {
contains (DEFINES, __BLUETOOTH__) { contains (DEFINES, __BLUETOOTH__) {
#bluetooth socket #bluetooth socket
SOURCES += \ SOURCES += \
$$PWD/network/qqtsocketbluetoothclient.cpp \ $$PWD/network/qqtbluetoothclient.cpp
$$PWD/network/qqtsocketbluetoothserver.cpp
HEADERS += \ HEADERS += \
$$PWD/network/qqtsocketbluetoothserver.h \ $$PWD/network/qqtbluetoothclient.h
$$PWD/network/qqtsocketbluetoothclient.h
#bluetooth manager #bluetooth manager
SOURCES += \ SOURCES += \
$$PWD/network/qqtbluetoothmanager.cpp $$PWD/network/qqtbluetoothmanager.cpp
@ -293,12 +289,10 @@ contains (DEFINES, __NETWORKSUPPORT__) {
contains (DEFINES, __WEBSOCKETSUPPORT__) { contains (DEFINES, __WEBSOCKETSUPPORT__) {
SOURCES += \ SOURCES += \
$$PWD/network/qqtwebsocketserver.cpp \
$$PWD/network/qqtwebsocketclient.cpp \ $$PWD/network/qqtwebsocketclient.cpp \
$$PWD/network/qqtwebsocketprotocol.cpp $$PWD/network/qqtwebsocketprotocol.cpp
HEADERS += \ HEADERS += \
$$PWD/network/qqtwebsocketclient.h \ $$PWD/network/qqtwebsocketclient.h \
$$PWD/network/qqtwebsocketserver.h \
$$PWD/network/qqtwebsocketprotocol.h $$PWD/network/qqtwebsocketprotocol.h
} }
} }
@ -401,4 +395,38 @@ contains (DEFINES, __EXQUISITE__) {
} }
} }
contains (DEFINES, __HIGHGRADE__) {
SOURCES += \
$$PWD/highgrade/qqtprotocolmanager.cpp \
$$PWD/highgrade/qqtserverprotocol.cpp \
$$PWD/highgrade/qqtudpserverprotocol.cpp
HEADERS += \
$$PWD/highgrade/qqtprotocolmanager.h \
$$PWD/highgrade/qqtserverprotocol.h \
$$PWD/highgrade/qqtudpserverprotocol.h
contains(DEFINES, __TCPUDPSOCKET__){
SOURCES += \
$$PWD/highgrade/qqttcpserver.cpp
HEADERS += \
$$PWD/highgrade/qqttcpserver.h
SOURCES += \
$$PWD/highgrade/qqtudpserver.cpp
HEADERS += \
$$PWD/highgrade/qqtudpserver.h
}
contains(DEFINES, __BLUETOOTH) {
SOURCES += \
$$PWD/highgrade/qqtbluetoothserver.cpp
HEADERS += \
$$PWD/highgrade/qqtbluetoothserver.h
}
contains (DEFINES, __WEBSOCKETSUPPORT__) {
SOURCES += \
$$PWD/highgrade/qqtwebsocketserver.cpp
HEADERS += \
$$PWD/highgrade/qqtwebsocketserver.h
}
}
include ($$PWD/qqt_3rdparty.pri) include ($$PWD/qqt_3rdparty.pri)

Some files were not shown because too many files have changed in this diff Show More