QTfrontend/tcpBase.cpp
changeset 180 ea83b9e9057f
parent 179 06e472d3f9f8
child 183 57c2ef19f719
equal deleted inserted replaced
179:06e472d3f9f8 180:ea83b9e9057f
    40 
    40 
    41 #include "hwconsts.h"
    41 #include "hwconsts.h"
    42 
    42 
    43 QList<TCPBase*> srvsList;
    43 QList<TCPBase*> srvsList;
    44 
    44 
    45 TCPBase::TCPBase() 
    45 TCPBase::TCPBase(bool demoMode) :
       
    46   m_isDemoMode(demoMode)
    46 {
    47 {
    47   IPCServer = new QTcpServer(this);
    48   IPCServer = new QTcpServer(this);
    48   connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
    49   connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
    49   IPCServer->setMaxPendingConnections(1);
    50   IPCServer->setMaxPendingConnections(1);
    50 }
    51 }
   136 }
   137 }
   137 
   138 
   138 void TCPBase::SendToClientFirst()
   139 void TCPBase::SendToClientFirst()
   139 {
   140 {
   140 }
   141 }
       
   142 
       
   143 void TCPBase::SendIPC(const QByteArray & buf)
       
   144 {
       
   145 	if (buf.size() > MAXMSGCHARS) return;
       
   146 	quint8 len = buf.size();
       
   147 	RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf);
       
   148 }
       
   149 
       
   150 void TCPBase::RawSendIPC(const QByteArray & buf)
       
   151 {
       
   152 	if (!IPCSocket)
       
   153 	{
       
   154 		toSendBuf += buf;
       
   155 	} else
       
   156 	{
       
   157 		if (toSendBuf.size() > 0)
       
   158 		{
       
   159 			IPCSocket->write(toSendBuf);
       
   160 			if(m_isDemoMode) demo->append(toSendBuf);
       
   161 			toSendBuf.clear();
       
   162 		}
       
   163 		IPCSocket->write(buf);
       
   164 		if(m_isDemoMode) demo->append(buf);
       
   165 	}
       
   166 }