TreeFrogFramework  2.8
tpublisher.h
Go to the documentation of this file.
1 #pragma once
2 #include <QMap>
3 #include <QObject>
4 #include <QString>
5 #include <TGlobal>
6 
7 class TAbstractWebSocket;
8 class Pub;
9 
10 
11 class T_CORE_EXPORT TPublisher : public QObject {
12  Q_OBJECT
13 public:
14  void subscribe(const QString &topic, bool local, TAbstractWebSocket *socket);
15  void unsubscribe(const QString &topic, TAbstractWebSocket *socket);
16  void unsubscribeFromAll(TAbstractWebSocket *socket);
17  void publish(const QString &topic, const QString &text, TAbstractWebSocket *socket);
18  void publish(const QString &topic, const QByteArray &binary, TAbstractWebSocket *socket);
19  static TPublisher *instance();
20 
21 protected:
22  Pub *create(const QString &topic);
23  Pub *get(const QString &topic);
24  void release(const QString &topic);
25  static QObject *castToObject(TAbstractWebSocket *socket);
26 
27 protected slots:
28  void receiveSystemBus();
29 
30 private:
31  TPublisher();
32  QMap<QString, Pub *> pubobj;
33 
36 };
37 
The TPublisher class provides a means of publish subscribe messaging for websocket.
Definition: tpublisher.h:11
#define T_CORE_EXPORT
Definition: tdeclexport.h:28
#define T_DISABLE_COPY(Class)
Definition: tdeclexport.h:37
#define T_DISABLE_MOVE(Class)
Definition: tdeclexport.h:41