TreeFrogFramework: src/twebsocketendpoint.h Source File

13public:

16

17 QString className() const;

18 QString name() const;

19 void sendText(const QString &text);

20 void sendBinary(const QByteArray &binary);

21 void ping(const QByteArray &payload = QByteArray());

22 void sendPing(const QByteArray &payload = QByteArray());

24 void sendText(int sid, const QString &text);

25 void sendBinary(int sid, const QByteArray &binary);

27 void rollbackTransaction();

28 void subscribe(const QString &topic, bool local = true);

29 void unsubscribe(const QString &topic);

30 void unsubscribeFromAll();

31 void publish(const QString &topic, const QString &text);

32 void publish(const QString &topic, const QByteArray &binary);

33 void startKeepAlive(int interval);

34

37

38 QHostAddress peerAddress() const { return peerAddr; }

39 uint16_t peerPort() const { return peerPortNumber; }

40 void reset();

41

42 static bool isUserLoggedIn(const TSession &session);

43 static QString identityKeyOfLoginUser(const TSession &session);

44 static const QStringList &disabledEndpoints();

45

46protected:

47 virtual bool onOpen(const TSession &session);

48 virtual void onClose(int closeCode);

49 virtual void onTextReceived(const QString &text);

50 virtual void onBinaryReceived(const QByteArray &binary);

51 virtual void onPing(const QByteArray &payload);

52 virtual void onPong(const QByteArray &payload);

54 virtual bool transactionEnabled() const;

55 void sendPong(const QByteArray &payload = QByteArray());

56

57private:

58 enum TaskType {

59 OpenSuccess = 0,

60 OpenError,

61 SendText,

62 SendBinary,

63 SendClose,

64 SendPing,

65 SendPong,

66 SendTextTo,

67 SendBinaryTo,

68 SendCloseTo,

69 Subscribe,

70 Unsubscribe,

71 UnsubscribeFromAll,

72 PublishText,

73 PublishBinary,

74 StartKeepAlive,

75 StopKeepAlive,

76 };

77

78 bool rollbackRequested() const;

79

81 QList<QPair<int, QVariant>> taskList;

82 bool rollback {false};

83 QHostAddress peerAddr;

84 uint16_t peerPortNumber {0};

85

86 friend class TWebSocketWorker;

89};

93{

94 return QString(metaObject()->className());

95}

98{

99 rollback = true;

100}

108{

109 return false;

110}