| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
dpp::discord_client Class Reference

Implements a discord client. Each discord_client connects to one shard and derives from a websocket client. More...

`#include <discordclient.h>`

Inheritance diagram for dpp::discord_client:
[legend]
Collaboration diagram for dpp::discord_client:
[legend]

## Public Member Functions

| discord_client (discord_client &old, uint64_t sequence, const std::string &session_id)
| Construct a discord_client object from another discord_client object Used when resuming, the url to connect to will be taken from the resume url of the other object, along with the seq number.
| discord_client (dpp::cluster *_cluster, uint32_t _shard_id, uint32_t _max_shards, const std::string &_token, uint32_t intents=0, bool compressed=true, websocket_protocol_t ws_protocol=ws_json)
| Construct a new discord_client object.
virtual | ~discord_client ()=default
| Destroy the discord client object.
discord_client & | clear_queue ()
| Clear the outbound message queue.
virtual void | close () override
| Close websocket.
void | complete_handshake (const struct socket_events *ev)
| Called while SSL handshake is in progress. If the handshake completes, the state of the socket is progressed to an established state.
discord_client & | connect_voice (snowflake guild_id, snowflake channel_id, bool self_mute=false, bool self_deaf=false, bool enable_dave=true)
| Connect to a voice channel.
discord_client & | disconnect_voice (snowflake guild_id)
| Disconnect from the connected voice channel on a guild.
void | enable_raw_tracing ()
| For low-level debugging, calling this function will enable low level I/O logging for this connection to the logger. This can be very loud, and output a lot of data, so only enable it selectively where you need it.
virtual void | error (uint32_t errorcode) override
| Handle a websocket error.
uint64_t | get_bytes_in ()
| Get total bytes received.
uint64_t | get_bytes_out ()
| Get total bytes sent.
uint64_t | get_channel_count ()
| Get the Channel Count for this shard.
std::string | get_cipher ()
| Get SSL cipher name.
uint64_t | get_decompressed_bytes_in ()
| Get decompressed total bytes received.
uint64_t | get_guild_count ()
| Get the Guild Count for this shard.
uint64_t | get_member_count ()
| Get the Member Count for this shard.
size_t | get_queue_size ()
| Get the size of the outbound message queue.
uint64_t | get_unique_id () const
| Every request made has a unique ID. This increments for every request, starting at 1. You can use this for statistics, or to associate requests and replies in external event loops.
dpp::utility::uptime | get_uptime ()
| Returns the connection time of the shard.
voiceconn * | get_voice (snowflake guild_id)
| Get the dpp::voiceconn object for a specific guild on this shard.
virtual bool | handle_buffer (std::string &buffer) override
| Processes incoming frames from the SSL socket input buffer.
virtual void | handle_event (const std::string &event, json &j, const std::string &raw)
| Handle an event (opcode 0).
virtual bool | handle_frame (const std::string &buffer, ws_opcode opcode) override
| Handle JSON from the websocket.
bool | is_connected ()
| Returns true if the shard is connected.
virtual void | log (dpp::loglevel severity, const std::string &msg) const override
| Log a message to whatever log the user is using. The logged message is passed up the chain to the on_log event in user code which can then do whatever it wants to do with it.
virtual void | on_disconnect () override
| Called when the HTTP socket is closed.
void | on_error (dpp::socket fd, const struct dpp::socket_events &, int error_code)
| Called when there is an error on the TCP socket.
void | on_read (dpp::socket fd, const struct dpp::socket_events &ev)
| Called when the TCP socket has data to read.
void | on_write (dpp::socket fd, const struct dpp::socket_events &e)
| Called when the TCP socket can be written to without blocking.
virtual void | one_second_timer () override
| Fires every second from the underlying socket I/O loop, used for sending heartbeats and any queued outbound websocket frames.
void | queue_message (const std::string &j, bool to_front=false)
| Queue a message to be sent via the websocket.
void | read_loop ()
| Set up non blocking I/O and configure on_read, on_write and on_error.
void | run ()
| Start and monitor I/O loop.
void | send_close_packet ()
| Send OP_CLOSE error code 1000 to the other side of the connection. This indicates graceful close.
void | socket_write (const std::string_view data)
| Write to the output buffer.
virtual void | write (const std::string_view data, ws_opcode _opcode=OP_AUTO)
| Write to websocket. Encapsulates data in frames if the status is CONNECTED.

## Public Attributes

std::unordered_map< snowflake, std::shared_ptr< voiceconn > > | connecting_voice_channels
| List of voice channels we are connecting to keyed by guild id.
class dpp::cluster * | creator
| Owning cluster.
uint32_t | heartbeat_interval
| Heartbeat interval for sending heartbeat keepalive.
uint32_t | intents
| Privileged gateway intents.
bool | keepalive
| True if we are keeping the connection alive after it has finished.
time_t | last_heartbeat
| Last heartbeat.
time_t | last_heartbeat_ack
| Last heartbeat ACK (opcode 11).
uint64_t | last_seq
| Last sequence number received, for resumes and pings.
uint32_t | max_shards
| Total number of shards.
class cluster * | owner
| Owning cluster.
std::string | private_key_file
| Private key PEM file path for inbound SSL connections.
websocket_protocol_t | protocol
| Current websocket protocol, currently either ETF or JSON.
std::string | public_key_file
| Public key PEM file path for inbound SSL connections.
bool | ready
| True if READY or RESUMED has been received.
uint32_t | reconnects
| Reconnection count.
std::string | resume_gateway_url
| The gateway address we reconnect to when we resume a session.
uint32_t | resumes
| Resume count.
std::string | sessionid
| Discord session id.
uint32_t | shard_id
| Shard ID of this client.
std::string | token
| Discord bot token.
std::shared_mutex | voice_mutex
| Mutex for voice connections map.
double | websocket_ping
| Websocket latency in fractional seconds.

## Protected Member Functions

virtual void | connect () override
| Connect to websocket server.
void | disconnect_voice_internal (snowflake guild_id, bool send_json=true)
| Disconnect from the connected voice channel on a guild.
void | do_raw_trace (const std::string &message) const
| If raw_trace is set to true, log a debug message for this connection.
ws_state | get_state () const
| Get websocket state.
virtual void | on_buffer_drained ()
void | start_connecting ()
| Start connecting the websocket.
int | start_connecting (dpp::socket sockfd, const struct sockaddr *addr, socklen_t addrlen)
| Start connecting to a TCP socket. This simply calls connect() and checks for error return, as the timeout is now handled in the main IO events for the ssl_connection class.

## Protected Attributes

std::string | buffer
| Input buffer received from socket.
uint64_t | bytes_in
| Bytes in.
uint64_t | bytes_out
| Bytes out.
std::string | cipher
| SSL cipher in use.
uint8_t | connect_retries {0}
| How many times we retried connect().
bool | connected {false}
| True if connection is completed.
std::string | hostname
| Hostname connected to.
std::string | last_ping_message
| Stores the most recent ping message on this shard, which we check for to monitor latency.
time_t | last_tick
| For timers.
std::string | obuffer
| Output buffer for sending to socket.
bool | plaintext
| True for a plain text connection.
std::string | port
| Port connected to.
bool | raw_trace {false}
| Set this to true to log all IO to debug for this connection. This is an internal developer facility. Do not enable it unless you need to, as it will be very noisy.
dpp::socket | sfd
| Raw file descriptor of connection.
openssl_connection * | ssl
| Openssl opaque contexts.
time_t | start
| Start time of connection.
bool | tcp_connect_done {false}
| True if tcp connect() succeeded.
bool | timed_out
| If true the connection timed out while waiting, when waiting for SSL negotiation, TCP connect(), or HTTP.
time_t | timeout
| Time at which the connection should be abandoned, if we are still connecting or negotiating with a HTTP server.
timer | timer_handle
| Timer handle for one second timer.
uint64_t | unique_id
| Unique ID of socket used as a nonce You can use this to identify requests vs reply if you want. D++ itself only sets this, and does not use it in any logic. It starts at 1 and increments for each request made.

## Friends

class | dpp::cluster
| Needed to allow cluster::set_presence to use the ETF functions.
class | dpp::events::guild_create
| Needed so that guild_create can request member chunks if you have the correct intents.
class | dpp::events::voice_state_update
| Needed so that voice_state_update can call dpp::discord_client::disconnect_voice_internal.

## Detailed Description

Implements a discord client. Each discord_client connects to one shard and derives from a websocket client.

## Constructor & Destructor Documentation

## ◆ discord_client() [1/2]

dpp::discord_client::discord_client | ( | dpp::cluster * | _cluster,
|  | uint32_t | _shard_id,
|  | uint32_t | _max_shards,
|  | const std::string & | _token,
|  | uint32_t | intents = 0,
|  | bool | compressed = true,
|  | websocket_protocol_t | ws_protocol = ws_json )

Construct a new discord_client object.

Parameters

  _cluster | The owning cluster for this shard
  _shard_id | The ID of the shard to start
  _max_shards | The total number of shards across all clusters
  _token | The bot token to use for identifying to the websocket
  intents | Privileged intents to use, a bitmask of values from dpp::intents
  compressed | True if the received data will be gzip compressed
  ws_protocol | Websocket protocol to use for the connection, JSON or ETF

Exceptions

  std::bad_alloc | Passed up to the caller if any internal objects fail to allocate, after cleanup has completed

## ◆ discord_client() [2/2]

dpp::discord_client::discord_client | ( | discord_client & | old,
|  | uint64_t | sequence,
|  | const std::string & | session_id )

explicit

Construct a discord_client object from another discord_client object Used when resuming, the url to connect to will be taken from the resume url of the other object, along with the seq number.

Parameters

  old | Previous connection to resume from
  sequence | Sequence number of previous session
  session_id | Session ID of previous session

## ◆ ~discord_client()

virtual dpp::discord_client::~discord_client | ( |  | ) |

virtual default

Destroy the discord client object.

## Member Function Documentation

## ◆ clear_queue()

discord_client & dpp::discord_client::clear_queue | ( |  | ) |

Clear the outbound message queue.

Returns
  reference to self

## ◆ close()

virtual void dpp::websocket_client::close | ( |  | ) |

override virtual inherited

Close websocket.

Reimplemented from dpp::ssl_connection.

## ◆ complete_handshake()

void dpp::ssl_connection::complete_handshake | ( | const struct socket_events * | ev | ) |

inherited

Called while SSL handshake is in progress. If the handshake completes, the state of the socket is progressed to an established state.

Parameters

  ev | Socket events for the socket

## ◆ connect()

virtual void dpp::websocket_client::connect | ( |  | ) |

override protected virtual inherited

Connect to websocket server.

Reimplemented from dpp::ssl_connection.

## ◆ connect_voice()

discord_client & dpp::discord_client::connect_voice | ( | snowflake | guild_id,
|  | snowflake | channel_id,
|  | bool | self_mute = false,
|  | bool | self_deaf = false,
|  | bool | enable_dave = true )

Connect to a voice channel.

Parameters

  guild_id | Guild where the voice channel is
  channel_id | Channel ID of the voice channel
  self_mute | True if the bot should mute itself
  self_deaf | True if the bot should deafen itself
  enable_dave | True to enable DAVE E2EE

Returns
  reference to self

Note
  This is NOT a synchronous blocking call! The bot isn't instantly ready to send or listen for audio, as we have to wait for the connection to the voice server to be established! e.g. wait for dpp::cluster::on_voice_ready event, and then send the audio within that event.

## ◆ disconnect_voice()

discord_client & dpp::discord_client::disconnect_voice | ( | snowflake | guild_id | ) |

Disconnect from the connected voice channel on a guild.

Parameters

  guild_id | The guild who's voice channel you wish to disconnect from

Returns
  reference to self

Note
  This is NOT a synchronous blocking call! The bot isn't instantly disconnected.

## ◆ disconnect_voice_internal()

void dpp::discord_client::disconnect_voice_internal | ( | snowflake | guild_id,
|  | bool | send_json = true )

protected

Disconnect from the connected voice channel on a guild.

Parameters

  guild_id | The guild who's voice channel you wish to disconnect from
  send_json | True if we should send a json message confirming we are leaving the VC Should be set to false if we already receive this message in an event.

## ◆ do_raw_trace()

void dpp::ssl_connection::do_raw_trace | ( | const std::string & | message | ) | const

protected inherited

If raw_trace is set to true, log a debug message for this connection.

Parameters

  message | debug message

## ◆ enable_raw_tracing()

void dpp::ssl_connection::enable_raw_tracing | ( |  | ) |

inherited

For low-level debugging, calling this function will enable low level I/O logging for this connection to the logger. This can be very loud, and output a lot of data, so only enable it selectively where you need it.

Generally, you won't need this, it is a library development utility.

## ◆ error()

virtual void dpp::discord_client::error | ( | uint32_t | errorcode | ) |

override virtual

Handle a websocket error.

Parameters

  errorcode | The error returned from the websocket

Reimplemented from dpp::websocket_client.

## ◆ get_bytes_in()

uint64_t dpp::ssl_connection::get_bytes_in | ( |  | ) |

inherited

Get total bytes received.

Returns
  uint64_t bytes received

## ◆ get_bytes_out()

uint64_t dpp::ssl_connection::get_bytes_out | ( |  | ) |

inherited

Get total bytes sent.

Returns
  uint64_t bytes sent

## ◆ get_channel_count()

uint64_t dpp::discord_client::get_channel_count | ( |  | ) |

Get the Channel Count for this shard.

Returns
  uint64_t channel count

## ◆ get_cipher()

std::string dpp::ssl_connection::get_cipher | ( |  | ) |

inherited

Get SSL cipher name.

Returns
  std::string ssl cipher name

## ◆ get_decompressed_bytes_in()

uint64_t dpp::discord_client::get_decompressed_bytes_in | ( |  | ) |

Get decompressed total bytes received.

This will always return 0 if the connection is not compressed

Returns
  uint64_t compressed bytes received

## ◆ get_guild_count()

uint64_t dpp::discord_client::get_guild_count | ( |  | ) |

Get the Guild Count for this shard.

Returns
  uint64_t guild count

## ◆ get_member_count()

uint64_t dpp::discord_client::get_member_count | ( |  | ) |

Get the Member Count for this shard.

Returns
  uint64_t member count

## ◆ get_queue_size()

size_t dpp::discord_client::get_queue_size | ( |  | ) |

Get the size of the outbound message queue.

Returns
  The size of the queue

## ◆ get_state()

ws_state dpp::websocket_client::get_state | ( |  | ) | const

nodiscard protected inherited

Get websocket state.

Returns
  websocket state

## ◆ get_unique_id()

uint64_t dpp::ssl_connection::get_unique_id | ( |  | ) | const

inherited

Every request made has a unique ID. This increments for every request, starting at 1. You can use this for statistics, or to associate requests and replies in external event loops.

Returns
  Unique ID

## ◆ get_uptime()

dpp::utility::uptime dpp::discord_client::get_uptime | ( |  | ) |

Returns the connection time of the shard.

Returns
  dpp::utility::uptime Detail of how long the shard has been connected for

## ◆ get_voice()

voiceconn * dpp::discord_client::get_voice | ( | snowflake | guild_id | ) |

Get the dpp::voiceconn object for a specific guild on this shard.

Parameters

  guild_id | The guild ID to retrieve the voice connection for

Returns
  voiceconn* The voice connection for the guild, or nullptr if there is no voice connection to this guild.

## ◆ handle_buffer()

virtual bool dpp::websocket_client::handle_buffer | ( | std::string & | buffer | ) |

override virtual inherited

Processes incoming frames from the SSL socket input buffer.

Parameters

  buffer | The buffer contents. Can modify this value removing the head elements when processed.

Reimplemented from dpp::ssl_connection.

## ◆ handle_event()

virtual void dpp::discord_client::handle_event | ( | const std::string & | event,
|  | json & | j,
|  | const std::string & | raw )

virtual

Handle an event (opcode 0).

Parameters

  event | Event name, e.g. MESSAGE_CREATE
  j | JSON object for the event content
  raw | Raw JSON event string

## ◆ handle_frame()

virtual bool dpp::discord_client::handle_frame | ( | const std::string & | buffer,
|  | ws_opcode | opcode )

override virtual

Handle JSON from the websocket.

Parameters

  buffer | The entire buffer content from the websocket client
  opcode | The type of frame, e.g. text or binary

Returns
  True if a frame has been handled

Reimplemented from dpp::websocket_client.

## ◆ is_connected()

bool dpp::discord_client::is_connected | ( |  | ) |

Returns true if the shard is connected.

Returns
  True if connected

## ◆ log()

virtual void dpp::discord_client::log | ( | dpp::loglevel | severity,
|  | const std::string & | msg ) const

override virtual

Log a message to whatever log the user is using. The logged message is passed up the chain to the on_log event in user code which can then do whatever it wants to do with it.

Parameters

  severity | The log level from dpp::loglevel
  msg | The log message to output

Reimplemented from dpp::ssl_connection.

## ◆ on_buffer_drained()

virtual void dpp::ssl_connection::on_buffer_drained | ( |  | ) |

protected virtual inherited

Reimplemented in dpp::http_server_request.

## ◆ on_disconnect()

virtual void dpp::discord_client::on_disconnect | ( |  | ) |

override virtual

Called when the HTTP socket is closed.

Reimplemented from dpp::websocket_client.

## ◆ on_error()

void dpp::ssl_connection::on_error | ( | dpp::socket | fd,
|  | const struct dpp::socket_events & | ,
|  | int | error_code )

inherited

Called when there is an error on the TCP socket.

Parameters

  fd | File descriptor
  error_code | Error code

## ◆ on_read()

void dpp::ssl_connection::on_read | ( | dpp::socket | fd,
|  | const struct dpp::socket_events & | ev )

inherited

Called when the TCP socket has data to read.

Parameters

  fd | File descriptor
  ev | Socket events

## ◆ on_write()

void dpp::ssl_connection::on_write | ( | dpp::socket | fd,
|  | const struct dpp::socket_events & | e )

inherited

Called when the TCP socket can be written to without blocking.

Parameters

  fd | File descriptor
  e | Socket events

## ◆ one_second_timer()

virtual void dpp::discord_client::one_second_timer | ( |  | ) |

override virtual

Fires every second from the underlying socket I/O loop, used for sending heartbeats and any queued outbound websocket frames.

Reimplemented from dpp::websocket_client.

## ◆ queue_message()

void dpp::discord_client::queue_message | ( | const std::string & | j,
|  | bool | to_front = false )

Queue a message to be sent via the websocket.

Parameters

  j | The JSON data of the message to be sent
  to_front | If set to true, will place the message at the front of the queue not the back (this is for urgent messages such as heartbeat, presence, so they can take precedence over chunk requests etc)

## ◆ read_loop()

void dpp::ssl_connection::read_loop | ( |  | ) |

inherited

Set up non blocking I/O and configure on_read, on_write and on_error.

Exceptions

  std::exception | Any std::exception (or derivative) thrown from read_loop() indicates setup failed

## ◆ run()

void dpp::discord_client::run | ( |  | ) |

Start and monitor I/O loop.

## ◆ send_close_packet()

void dpp::websocket_client::send_close_packet | ( |  | ) |

inherited

Send OP_CLOSE error code 1000 to the other side of the connection. This indicates graceful close.

Note
  This informs Discord to invalidate the session, you cannot resume if you send this

## ◆ socket_write()

void dpp::ssl_connection::socket_write | ( | const std::string_view | data | ) |

inherited

Write to the output buffer.

Parameters

  data | Data to be written to the buffer.

Note
  The data may not be written immediately and may be written at a later time to the socket.

## ◆ start_connecting() [1/2]

void dpp::discord_client::start_connecting | ( |  | ) |

protected

Start connecting the websocket.

Called from the constructor, or during reconnection

## ◆ start_connecting() [2/2]

int dpp::ssl_connection::start_connecting | ( | dpp::socket | sockfd,
|  | const struct sockaddr * | addr,
|  | socklen_t | addrlen )

protected inherited

Start connecting to a TCP socket. This simply calls connect() and checks for error return, as the timeout is now handled in the main IO events for the ssl_connection class.

Parameters

  sockfd | socket descriptor
  addr | address to connect to
  addrlen | address length
  timeout_ms | timeout in milliseconds

Returns
  int -1 on error, 0 on success just like POSIX connect()

Exceptions

  dpp::connection_exception | on failure

## ◆ write()

virtual void dpp::websocket_client::write | ( | const std::string_view | data,
|  | ws_opcode | _opcode = OP_AUTO )

virtual inherited

Write to websocket. Encapsulates data in frames if the status is CONNECTED.

Parameters

  data | The data to send.
  _opcode | The opcode of the data to send, either binary or text. The default is to use the socket's opcode as set in the constructor.

## Friends And Related Symbol Documentation

## ◆ dpp::cluster

friend class dpp::cluster

friend

Needed to allow cluster::set_presence to use the ETF functions.

## ◆ dpp::events::guild_create

friend class dpp::events::guild_create

friend

Needed so that guild_create can request member chunks if you have the correct intents.

## ◆ dpp::events::voice_state_update

friend class dpp::events::voice_state_update

friend

Needed so that voice_state_update can call dpp::discord_client::disconnect_voice_internal.

## Member Data Documentation

## ◆ buffer

std::string dpp::ssl_connection::buffer

protected inherited

Input buffer received from socket.

## ◆ bytes_in

uint64_t dpp::ssl_connection::bytes_in

protected inherited

Bytes in.

## ◆ bytes_out

uint64_t dpp::ssl_connection::bytes_out

protected inherited

Bytes out.

## ◆ cipher

std::string dpp::ssl_connection::cipher

protected inherited

SSL cipher in use.

## ◆ connect_retries

uint8_t dpp::ssl_connection::connect_retries {0}

protected inherited

How many times we retried connect().

## ◆ connected

bool dpp::ssl_connection::connected {false}

protected inherited

True if connection is completed.

## ◆ connecting_voice_channels

std::unordered_map<snowflake, std::shared_ptr<voiceconn> > dpp::discord_client::connecting_voice_channels

List of voice channels we are connecting to keyed by guild id.

## ◆ creator

class dpp::cluster* dpp::discord_client::creator

Owning cluster.

## ◆ heartbeat_interval

uint32_t dpp::discord_client::heartbeat_interval

Heartbeat interval for sending heartbeat keepalive.

Note
  value in milliseconds

## ◆ hostname

std::string dpp::ssl_connection::hostname

protected inherited

Hostname connected to.

## ◆ intents

uint32_t dpp::discord_client::intents

Privileged gateway intents.

See also
  dpp::intents

## ◆ keepalive

bool dpp::ssl_connection::keepalive

inherited

True if we are keeping the connection alive after it has finished.

## ◆ last_heartbeat

time_t dpp::discord_client::last_heartbeat

Last heartbeat.

## ◆ last_heartbeat_ack

time_t dpp::discord_client::last_heartbeat_ack

Last heartbeat ACK (opcode 11).

## ◆ last_ping_message

std::string dpp::discord_client::last_ping_message

protected

Stores the most recent ping message on this shard, which we check for to monitor latency.

## ◆ last_seq

uint64_t dpp::discord_client::last_seq

Last sequence number received, for resumes and pings.

## ◆ last_tick

time_t dpp::ssl_connection::last_tick

protected inherited

For timers.

## ◆ max_shards

uint32_t dpp::discord_client::max_shards

Total number of shards.

## ◆ obuffer

std::string dpp::ssl_connection::obuffer

protected inherited

Output buffer for sending to socket.

## ◆ owner

class cluster* dpp::ssl_connection::owner

inherited

Owning cluster.

## ◆ plaintext

bool dpp::ssl_connection::plaintext

protected inherited

True for a plain text connection.

## ◆ port

std::string dpp::ssl_connection::port

protected inherited

Port connected to.

## ◆ private_key_file

std::string dpp::ssl_connection::private_key_file

inherited

Private key PEM file path for inbound SSL connections.

## ◆ protocol

websocket_protocol_t dpp::discord_client::protocol

Current websocket protocol, currently either ETF or JSON.

## ◆ public_key_file

std::string dpp::ssl_connection::public_key_file

inherited

Public key PEM file path for inbound SSL connections.

## ◆ raw_trace

bool dpp::ssl_connection::raw_trace {false}

protected inherited

Set this to true to log all IO to debug for this connection. This is an internal developer facility. Do not enable it unless you need to, as it will be very noisy.

## ◆ ready

bool dpp::discord_client::ready

True if READY or RESUMED has been received.

## ◆ reconnects

uint32_t dpp::discord_client::reconnects

Reconnection count.

## ◆ resume_gateway_url

std::string dpp::discord_client::resume_gateway_url

The gateway address we reconnect to when we resume a session.

## ◆ resumes

uint32_t dpp::discord_client::resumes

Resume count.

## ◆ sessionid

std::string dpp::discord_client::sessionid

Discord session id.

## ◆ sfd

dpp::socket dpp::ssl_connection::sfd

protected inherited

Raw file descriptor of connection.

## ◆ shard_id

uint32_t dpp::discord_client::shard_id

Shard ID of this client.

## ◆ ssl

openssl_connection* dpp::ssl_connection::ssl

protected inherited

Openssl opaque contexts.

## ◆ start

time_t dpp::ssl_connection::start

protected inherited

Start time of connection.

## ◆ tcp_connect_done

bool dpp::ssl_connection::tcp_connect_done {false}

protected inherited

True if tcp connect() succeeded.

## ◆ timed_out

bool dpp::websocket_client::timed_out

protected inherited

If true the connection timed out while waiting, when waiting for SSL negotiation, TCP connect(), or HTTP.

## ◆ timeout

time_t dpp::websocket_client::timeout

protected inherited

Time at which the connection should be abandoned, if we are still connecting or negotiating with a HTTP server.

## ◆ timer_handle

timer dpp::ssl_connection::timer_handle

protected inherited

Timer handle for one second timer.

## ◆ token

std::string dpp::discord_client::token

Discord bot token.

## ◆ unique_id

uint64_t dpp::ssl_connection::unique_id

protected inherited

Unique ID of socket used as a nonce You can use this to identify requests vs reply if you want. D++ itself only sets this, and does not use it in any logic. It starts at 1 and increments for each request made.

## ◆ voice_mutex

std::shared_mutex dpp::discord_client::voice_mutex

Mutex for voice connections map.

## ◆ websocket_ping

double dpp::discord_client::websocket_ping

Websocket latency in fractional seconds.

D++ Library version 9.0.13 D++ Library version 9.0.12 D++ Library version 9.0.11 D++ Library version 9.0.10 D++ Library version 9.0.9 D++ Library version 9.0.8 D++ Library version 9.0.7 D++ Library version 9.0.6 D++ Library version 9.0.5 D++ Library version 9.0.4 D++ Library version 9.0.3 D++ Library version 9.0.2 D++ Library version 9.0.1 D++ Library version 9.0.0 D++ Library version 1.0.2 D++ Library version 1.0.1 D++ Library version 1.0.0