1 #include "testserver.h" 2 #include <QDebug> 3 #include "serverhandler.h" 4 TestServer(const QString & name,QObject * parent)5TestServer::TestServer(const QString &name, QObject *parent):PlatformServer(name, parent), 6 m_num(0) 7 { 8 9 } 10 startwork()11void TestServer::startwork() 12 { 13 this->start(); 14 } 15 stopwork()16void TestServer::stopwork() 17 { 18 this->quit(); 19 this->wait(); 20 } 21 sendData(const QByteArray & d)22void TestServer::sendData(const QByteArray &d) 23 { 24 Q_UNUSED(d) 25 m_num ++; 26 } 27 run()28void TestServer::run() 29 { 30 QString curValue =QString("current num: %1").arg(m_num); 31 msleep(1000); 32 foreach (ServerHandler *handler, m_handlers) { 33 handler->handleData(curValue.toLocal8Bit()); 34 } 35 } 36