QTfrontend/net/tcpBase.h
changeset 6616 f77bb02b669f
parent 6060 fdfc01419815
child 6700 e04da46ee43c
equal deleted inserted replaced
6615:65602f1ef0f8 6616:f77bb02b669f
    33 
    33 
    34 #define MAXMSGCHARS 255
    34 #define MAXMSGCHARS 255
    35 
    35 
    36 class TCPBase : public QObject
    36 class TCPBase : public QObject
    37 {
    37 {
    38   Q_OBJECT
    38         Q_OBJECT
    39 
    39 
    40  public:
    40     public:
    41   TCPBase(bool demoMode);
    41         TCPBase(bool demoMode);
    42   virtual ~TCPBase();
    42         virtual ~TCPBase();
    43 
    43 
    44  signals:
    44     signals:
    45   void isReadyNow();
    45         void isReadyNow();
    46 
    46 
    47  protected:
    47     protected:
    48   quint16 ipc_port;
    48         quint16 ipc_port;
    49 
    49 
    50   void Start();
    50         void Start();
    51 
    51 
    52   QByteArray readbuffer;
    52         QByteArray readbuffer;
    53 
    53 
    54   QByteArray toSendBuf;
    54         QByteArray toSendBuf;
    55   QByteArray demo;
    55         QByteArray demo;
    56 
    56 
    57   void SendIPC(const QByteArray & buf);
    57         void SendIPC(const QByteArray & buf);
    58   void RawSendIPC(const QByteArray & buf);
    58         void RawSendIPC(const QByteArray & buf);
    59 
    59 
    60   virtual QStringList getArguments()=0;
    60         virtual QStringList getArguments()=0;
    61   virtual void onClientRead();
    61         virtual void onClientRead();
    62   virtual void onClientDisconnect();
    62         virtual void onClientDisconnect();
    63   virtual void SendToClientFirst();
    63         virtual void SendToClientFirst();
    64 
    64 
    65  private:
    65     private:
    66   static QPointer<QTcpServer> IPCServer;
    66         static QPointer<QTcpServer> IPCServer;
    67 
    67 
    68   bool m_isDemoMode;
    68         bool m_isDemoMode;
    69   void RealStart();
    69         void RealStart();
    70   QPointer<QTcpSocket> IPCSocket;
    70         QPointer<QTcpSocket> IPCSocket;
    71 
    71 
    72  private slots:
    72     private slots:
    73   void NewConnection();
    73         void NewConnection();
    74   void ClientDisconnect();
    74         void ClientDisconnect();
    75   void ClientRead();
    75         void ClientRead();
    76   void StartProcessError(QProcess::ProcessError error);
    76         void StartProcessError(QProcess::ProcessError error);
    77 
    77 
    78   void tcpServerReady();
    78         void tcpServerReady();
    79 };
    79 };
    80 
    80 
    81 #endif // _TCPBASE_INCLUDED
    81 #endif // _TCPBASE_INCLUDED