QTfrontend/tcpBase.cpp
changeset 180 ea83b9e9057f
parent 179 06e472d3f9f8
child 183 57c2ef19f719
--- a/QTfrontend/tcpBase.cpp	Sun Oct 01 20:31:48 2006 +0000
+++ b/QTfrontend/tcpBase.cpp	Mon Oct 02 18:09:39 2006 +0000
@@ -42,7 +42,8 @@
 
 QList<TCPBase*> srvsList;
 
-TCPBase::TCPBase() 
+TCPBase::TCPBase(bool demoMode) :
+  m_isDemoMode(demoMode)
 {
   IPCServer = new QTcpServer(this);
   connect(IPCServer, SIGNAL(newConnection()), this, SLOT(NewConnection()));
@@ -138,3 +139,28 @@
 void TCPBase::SendToClientFirst()
 {
 }
+
+void TCPBase::SendIPC(const QByteArray & buf)
+{
+	if (buf.size() > MAXMSGCHARS) return;
+	quint8 len = buf.size();
+	RawSendIPC(QByteArray::fromRawData((char *)&len, 1) + buf);
+}
+
+void TCPBase::RawSendIPC(const QByteArray & buf)
+{
+	if (!IPCSocket)
+	{
+		toSendBuf += buf;
+	} else
+	{
+		if (toSendBuf.size() > 0)
+		{
+			IPCSocket->write(toSendBuf);
+			if(m_isDemoMode) demo->append(toSendBuf);
+			toSendBuf.clear();
+		}
+		IPCSocket->write(buf);
+		if(m_isDemoMode) demo->append(buf);
+	}
+}