2017-10-17 22:00:45 +08:00
|
|
|
#include "qqtlanprotocol.h"
|
|
|
|
|
2018-04-18 20:34:40 +08:00
|
|
|
QQTLanProtocol::QQTLanProtocol ( QObject* parent ) :
|
|
|
|
QQtProtocol ( parent )
|
2017-10-17 22:00:45 +08:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
quint16 QQTLanProtocol::minlength()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
quint16 QQTLanProtocol::maxlength()
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-18 20:34:40 +08:00
|
|
|
quint16 QQTLanProtocol::splitter ( const QByteArray& s )
|
2017-10-17 22:00:45 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-04-18 20:34:40 +08:00
|
|
|
bool QQTLanProtocol::dispatcher ( const QByteArray& m )
|
2017-10-17 22:00:45 +08:00
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2017-10-18 08:05:58 +08:00
|
|
|
|
|
|
|
|
2018-04-22 13:03:28 +08:00
|
|
|
QQtTcpServer* QQTSingleServer ( QObject* parent )
|
2017-10-18 08:05:58 +08:00
|
|
|
{
|
2018-04-22 13:03:28 +08:00
|
|
|
static QQtTcpServer* s = new QQtTcpServer ( parent );
|
2018-04-18 20:34:40 +08:00
|
|
|
s->listen ( QHostAddress::Any, 8000 );
|
2017-10-18 08:05:58 +08:00
|
|
|
return s;
|
|
|
|
}
|
2018-04-18 20:34:40 +08:00
|
|
|
|
|
|
|
QQTLanProtocol* QQtLanServer ( QObject* parent )
|
|
|
|
{
|
|
|
|
static QQTLanProtocol* p0 = NULL;
|
2018-04-22 13:03:28 +08:00
|
|
|
static QQtTcpServer* s0 = NULL;
|
2018-04-18 20:34:40 +08:00
|
|
|
if ( !p0 && !s0 )
|
|
|
|
{
|
|
|
|
p0 = new QQTLanProtocol ( parent );
|
|
|
|
|
2018-04-22 13:03:28 +08:00
|
|
|
s0 = new QQtTcpServer ( parent );
|
2018-04-18 20:34:40 +08:00
|
|
|
s0->listen ( QHostAddress::Any, 8000 );
|
|
|
|
s0->installProtocol ( p0 );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return p0;
|
|
|
|
}
|