Discord.C++ 0.13.0
Loading...
Searching...
No Matches
DiscordCPP::MainGateway Class Reference

#include <MainGateway.h>

Inheritance diagram for DiscordCPP::MainGateway:
DiscordCPP::Gateway

Public Member Functions

 MainGateway (std::string token, Intents intents, const int shard_id=0, const unsigned int num_shards=1)
 
 ~MainGateway () override=default
 
unsigned int get_shard_id ()
 
SharedFuture< void > connect (const std::string &url) override
 
- Public Member Functions inherited from DiscordCPP::Gateway
 Gateway (std::string token, const std::shared_ptr< Threadpool > &threadpool)
 
virtual ~Gateway ()
 
void set_message_handler (const std::function< void(json payload)> &handler)
 
SharedFuture< void > send (const json &message)
 
SharedFuture< void > close ()
 

Additional Inherited Members

- Protected Member Functions inherited from DiscordCPP::Gateway
void start_heartbeating ()
 
void on_websocket_disconnnect ()
 
- Protected Attributes inherited from DiscordCPP::Gateway
std::shared_ptr< Threadpoolthreadpool
 the threadpool used for tasks handling messages
 
boost::asio::io_context io_context
 boost io context used by the websocket client
 
boost::asio::ssl::context ssl_context
 ssl context used by the websocket client
 
std::unique_ptr< boost::beast::websocket::stream< boost::beast::ssl_stream< boost::asio::ip::tcp::socket > > > _client
 websocket client
 
std::string _url
 the url of the gateway
 
std::string _resume_url
 the url used for reconnecting
 
std::string _token
 token to identify with the gateway
 
unsigned int _heartbeat_interval
 heartbeat interval in milliseconds
 
bool _keepalive
 wether to keep the websocket alive or not
 
unsigned int _reconnect_timeout
 sometimes it is better a few seconds before reconnecting...
 
time_t _last_heartbeat_ack = 0
 timestamp of last heartbeat ack
 
std::thread _heartbeat_task
 heartbeat task
 
bool _connected
 indicator if Gateway is connected
 
Logger _log
 logging instance
 
std::function< void(json payload)> _message_handler
 the message handler set by using set_message_handler
 

Constructor & Destructor Documentation

◆ MainGateway()

DiscordCPP::MainGateway::MainGateway ( std::string token,
Intents intents,
const int shard_id = 0,
const unsigned int num_shards = 1 )

◆ ~MainGateway()

DiscordCPP::MainGateway::~MainGateway ( )
overridedefault

Member Function Documentation

◆ connect()

DiscordCPP::SharedFuture< void > DiscordCPP::MainGateway::connect ( const std::string & url)
overridevirtual

Reimplemented from DiscordCPP::Gateway.

◆ get_shard_id()

unsigned int DiscordCPP::MainGateway::get_shard_id ( )

The documentation for this class was generated from the following files: