QTfrontend/tcpBase.h
changeset 180 ea83b9e9057f
parent 179 06e472d3f9f8
child 183 57c2ef19f719
equal deleted inserted replaced
179:06e472d3f9f8 180:ea83b9e9057f
    43 #include <QProcess>
    43 #include <QProcess>
    44 
    44 
    45 #include <QImage>
    45 #include <QImage>
    46 
    46 
    47 #define IPC_PORT 46631
    47 #define IPC_PORT 46631
       
    48 #define MAXMSGCHARS 255
    48 
    49 
    49 class TCPBase : public QObject
    50 class TCPBase : public QObject
    50 {
    51 {
    51   Q_OBJECT
    52   Q_OBJECT
    52     
    53     
    53  public:
    54  public:
    54   TCPBase();
    55   TCPBase(bool demoMode);
    55 
    56 
    56  signals:
    57  signals:
    57   void isReadyNow();
    58   void isReadyNow();
    58 
    59 
    59  protected:
    60  protected:
    60   void Start();
    61   void Start();
    61 
    62 
    62   QTcpSocket * IPCSocket;
       
    63   QByteArray readbuffer;
    63   QByteArray readbuffer;
       
    64 
       
    65   QByteArray toSendBuf;
       
    66   QByteArray * demo;
       
    67 
       
    68   void SendIPC(const QByteArray & buf);
       
    69   void RawSendIPC(const QByteArray & buf);
    64 
    70 
    65   virtual QStringList setArguments()=0;
    71   virtual QStringList setArguments()=0;
    66   virtual void onClientRead();
    72   virtual void onClientRead();
    67   virtual void onClientDisconnect();
    73   virtual void onClientDisconnect();
    68   virtual void SendToClientFirst();
    74   virtual void SendToClientFirst();
    69   
       
    70 
    75 
    71  private:
    76  private:
       
    77   bool m_isDemoMode;
    72   void RealStart();
    78   void RealStart();
    73   QTcpServer * IPCServer;
    79   QTcpServer * IPCServer;
       
    80   QTcpSocket * IPCSocket;
    74 
    81 
    75  private slots:
    82  private slots:
    76   void NewConnection();
    83   void NewConnection();
    77   void ClientDisconnect();
    84   void ClientDisconnect();
    78   void ClientRead();
    85   void ClientRead();