玉兔远程控制 0.1.0-bate8
载入中...
搜索中...
未找到
Channel.h
1// Author: Kang Lin <kl222@126.com>
2
3#ifndef CDATACHANNEL_H
4#define CDATACHANNEL_H
5
6#pragma once
7
8#include <QIODevice>
9#include <QTcpSocket>
10#include <QMessageBox>
11#include <QMutex>
12#include "plugin_export.h"
13#include "Stats.h"
14
15#define DEFAULT_TIMEOUT 500000
16
27class PLUGIN_EXPORT CChannel : public QIODevice
28{
29 Q_OBJECT
30
31public:
37 explicit CChannel(QTcpSocket* pSocket, QObject *parent = nullptr);
38 virtual ~CChannel();
39
45 virtual bool open(OpenMode mode) override;
46 virtual void close() override;
47
50 virtual QString GetDetails();
51
53 static int InitTranslation();
55 static int RemoveTranslation();
56
57Q_SIGNALS:
65 void sigError(int nErr, const QString& szErr);
66
71 void sigSecurityLevel(CSecurityLevel::Levels level);
76 void sigSend(quint64 counts);
81 void sigReceive(quint64 counts);
82
83private Q_SLOTS:
84 void slotError(QAbstractSocket::SocketError e);
85
86private:
87 QTcpSocket* m_pSocket;
88
89protected:
90 explicit CChannel(QObject *parent = nullptr);
91
92 // QIODevice interface
93protected:
94 virtual qint64 readData(char *data, qint64 maxlen) override;
95 virtual qint64 writeData(const char *data, qint64 len) override;
96 virtual bool isSequential() const override;
97};
98
99#endif // CDATACHANNEL_H
通道接口类。此类默认实现一个 TCP 的通道。
Definition Channel.h:28
void sigSend(quint64 counts)
Send data counts
void sigConnected()
emit when the channel is connected.
void sigReceive(quint64 counts)
Receive data counts
void sigDisconnected()
emit when the channel is disconnected
void sigError(int nErr, const QString &szErr)
emit when the channel is error
void sigSecurityLevel(CSecurityLevel::Levels level)
当安全级别改变时触发