Chatterino
|
#include <BasicPubSubManager.hpp>
Public Member Functions | |
BasicPubSubManager (QString host) | |
virtual | ~BasicPubSubManager ()=default |
BasicPubSubManager (const BasicPubSubManager &)=delete | |
BasicPubSubManager (const BasicPubSubManager &&)=delete | |
BasicPubSubManager & | operator= (const BasicPubSubManager &)=delete |
BasicPubSubManager & | operator= (const BasicPubSubManager &&)=delete |
void | start () |
void | stop () |
Public Attributes | |
struct { | |
std::atomic< uint32_t > connectionsClosed {0} | |
std::atomic< uint32_t > connectionsOpened {0} | |
std::atomic< uint32_t > connectionsFailed {0} | |
} | diag |
Protected Types | |
using | WebsocketMessagePtr = websocketpp::config::asio_tls_client::message_type::ptr |
using | WebsocketContextPtr = websocketpp::lib::shared_ptr< boost::asio::ssl::context > |
Protected Member Functions | |
virtual void | onMessage (websocketpp::connection_hdl hdl, WebsocketMessagePtr msg)=0 |
virtual std::shared_ptr< BasicPubSubClient< Subscription > > | createClient (liveupdates::WebsocketClient &client, websocketpp::connection_hdl hdl) |
std::shared_ptr< BasicPubSubClient< Subscription > > | findClient (websocketpp::connection_hdl hdl) |
void | unsubscribe (const Subscription &subscription) |
void | subscribe (const Subscription &subscription) |
This class is the basis for connecting and interacting with simple PubSub servers over the Websocket protocol. It acts as a pool for connections (see BasicPubSubClient).
You can customize the clients, by creating your custom client in ::createClient.
You must implement onMessage. The method gets called for every received message on every connection. If you want to get the connection this message was received on, use findClient.
You must expose your own subscribe and unsubscribe methods (e.g. [un-]subscribeTopic). This manager does not keep track of the subscriptions.
Subscription | The subscription has the following requirements: It must have the methods QByteArray encodeSubscribe(), and QByteArray encodeUnsubscribe(). It must have an overload for QDebug &operator<< (see tests/src/BasicPubSub.cpp), a specialization for std::hash, and and overload for operator== and operator!=. |
|
protected |
|
protected |
|
inline |
|
virtualdefault |
|
delete |
|
delete |
|
inlineprotectedvirtual |
|
inlineprotected |
hdl | The handle of the client. |
|
protectedpure virtual |
|
delete |
|
delete |
|
inline |
|
inline |
|
inlineprotected |
|
inlineprotected |
std::atomic<uint32_t> chatterino::BasicPubSubManager< Subscription >::connectionsClosed {0} |
std::atomic<uint32_t> chatterino::BasicPubSubManager< Subscription >::connectionsFailed {0} |
std::atomic<uint32_t> chatterino::BasicPubSubManager< Subscription >::connectionsOpened {0} |
struct { ... } chatterino::BasicPubSubManager< Subscription >::diag |
This is only used for testing.