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