12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- #ifndef CWEBSOCKETPROC_H
- #define CWEBSOCKETPROC_H
- #include <QtCore/QObject>
- #include <QtWebSockets/QWebSocket>
- #include <QTimer>
- #include <QMaskGenerator>
- class CWebsocketProc : public QObject
- {
- Q_OBJECT
- public:
- CWebsocketProc();
- ~CWebsocketProc();
- void setUrl(QString sUrl, QString sToken, QString sKey);
- void open();
- void open(QString sUrl, QString sToken, QString sKey);
- void close();
- qint64 sendText(QString sText);
- bool isConnected();
- signals:
- void connected();
- void clientOffLine();
- void networkWeak();
- void websocketError(QString sErrorStr);
- void mobileStatus(__int64 nExamRecordDataId, int nOrder, QString sScanStatus);
- void fileAnswer(__int64 nExamRecordDataId, int nOrder, QString sFileType, QString sFileUrl);
- private Q_SLOTS:
- void onDisconnected();
- void onConnected();
- void onTextReceived(QString msg);
- void reconnect();
- void onHeartBreatTimeout();
- private:
- QWebSocket *m_pWebsocket;
- QTimer *m_pTime;
- int m_nTimeOutLimit;
- int m_nTimeOutSecord;
- int m_nTimeOutTimes;
- QTimer *m_pHeartBeat;
- QString m_sUrl;
- QString m_sToken;
- QString m_sKey;
- bool m_bConnected;
- bool m_isExitClosed;
- __int64 m_lastRecvTime = 0;
- };
- extern std::shared_ptr<CWebsocketProc> g_websocketPtr;
- #endif // CWEBSOCKETPROC_H
|