2018-04-19 23:03:39 +08:00
|
|
|
|
#include "usertest8protocol.h"
|
|
|
|
|
|
|
|
|
|
QDebug& operator << ( QDebug& dbg, const UserTest8Message& msg )
|
|
|
|
|
{
|
|
|
|
|
//这里打印一下,报文里面到底有什么信息,
|
|
|
|
|
//一般到这里的,都是被解析好的message。
|
|
|
|
|
|
|
|
|
|
dbg.nospace() << "{" << hex << msg.size() << "}";
|
|
|
|
|
return dbg.space();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UserTest8Protocol* UserTest8ConnectionInstance ( QObject* parent )
|
|
|
|
|
{
|
|
|
|
|
static UserTest8Protocol* p0 = NULL;
|
2018-04-22 13:03:28 +08:00
|
|
|
|
static QQtTcpServer* s0 = NULL;
|
2018-04-19 23:03:39 +08:00
|
|
|
|
if ( !p0 && !s0 )
|
|
|
|
|
{
|
|
|
|
|
p0 = new UserTest8Protocol ( parent );
|
|
|
|
|
|
2018-04-22 13:03:28 +08:00
|
|
|
|
s0 = new QQtTcpServer ( parent );
|
2018-04-19 23:03:39 +08:00
|
|
|
|
s0->installProtocol ( p0 );
|
|
|
|
|
s0->listen ( QHostAddress::Any, 8000 );
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return p0;
|
|
|
|
|
}
|