|  | D++ (DPP)
    C++ Discord API Bot Library | 
Implements a websocket client based on the SSL client. More...
#include <wsclient.h>
 Inheritance diagram for dpp::WSClient:
 Inheritance diagram for dpp::WSClient: Collaboration diagram for dpp::WSClient:
 Collaboration diagram for dpp::WSClient:| Public Member Functions | |
| WSClient (const std::string &hostname, const std::string &port="443", const std::string &urlpath="") | |
| virtual | ~WSClient () | 
| virtual void | close () | 
| Close websocket.  More... | |
| virtual void | Error (uint32_t errorcode) | 
| Called upon error frame.  More... | |
| uint64_t | GetBytesIn () | 
| uint64_t | GetBytesOut () | 
| virtual bool | HandleBuffer (std::string &buffer) | 
| Processes incoming frames from the SSL socket input buffer.  More... | |
| virtual bool | HandleFrame (const std::string &buffer) | 
| Receives raw frame content only without headers.  More... | |
| virtual void | log (dpp::loglevel severity, const std::string &msg) | 
| Log a message.  More... | |
| void | ReadLoop () | 
| Nonblocking I/O loop.  More... | |
| virtual void | write (const std::string &data) | 
| Write to websocket. Encapsulates data in frames if the status is CONNECTED.  More... | |
| Public Attributes | |
| std::function< int()> | custom_readable_fd | 
| Attaching an additional file descriptor to this function will send notifications when there is data to read.  More... | |
| std::function< void()> | custom_readable_ready | 
| This event will be called when you can read from the custom fd.  More... | |
| std::function< int()> | custom_writeable_fd | 
| Attaching an additional file descriptor to this function will send notifications when you are able to write to the socket.  More... | |
| std::function< void()> | custom_writeable_ready | 
| This event will be called when you can write to a custom fd.  More... | |
| Protected Member Functions | |
| virtual void | Connect () | 
| WSState | GetState () | 
| virtual void | OneSecondTimer () | 
| Protected Attributes | |
| std::string | buffer | 
| uint64_t | bytes_in | 
| uint64_t | bytes_out | 
| std::string | cipher | 
| SSL_CTX * | ctx | 
| std::string | hostname | 
| time_t | last_tick | 
| bool | nonblocking | 
| std::string | obuffer | 
| std::string | port | 
| int | sfd | 
| SSL * | ssl | 
Implements a websocket client based on the SSL client.
| dpp::WSClient::WSClient | ( | const std::string & | hostname, | 
| const std::string & | port = "443", | ||
| const std::string & | urlpath = "" | ||
| ) | 
Connect to a specific websocket server.
| hostname | Hostname to connect to | 
| port | Port to connect to | 
| urlpath | The URL path components of the HTTP request to send | 
| 
 | virtual | 
Destructor
| 
 | virtual | 
Close websocket.
Reimplemented from dpp::SSLClient.
| 
 | protectedvirtual | 
(Re)connect
Reimplemented from dpp::SSLClient.
| 
 | virtual | 
Called upon error frame.
| errorcode | The error code from the websocket server | 
Reimplemented in dpp::DiscordClient, and dpp::DiscordVoiceClient.
| 
 | inherited | 
Get total bytes received
| 
 | inherited | 
Get total bytes sent
| 
 | protected | 
Get websocket state
| 
 | virtual | 
Processes incoming frames from the SSL socket input buffer.
| buffer | The buffer contents. Can modify this value removing the head elements when processed. | 
Reimplemented from dpp::SSLClient.
| 
 | virtual | 
Receives raw frame content only without headers.
| buffer | The buffer contents | 
Reimplemented in dpp::DiscordClient, and dpp::DiscordVoiceClient.
| 
 | virtualinherited | 
Log a message.
| severity | severity of log message | 
| msg | Log message to send | 
Reimplemented in dpp::DiscordClient, and dpp::DiscordVoiceClient.
| 
 | protectedvirtualinherited | 
Called every second
Reimplemented in dpp::DiscordClient, and dpp::DiscordVoiceClient.
| 
 | inherited | 
Nonblocking I/O loop.
| 
 | virtual | 
Write to websocket. Encapsulates data in frames if the status is CONNECTED.
| data | The data to send. | 
Reimplemented from dpp::SSLClient.
| 
 | protectedinherited | 
Input buffer received from openssl
| 
 | protectedinherited | 
Bytes in
| 
 | protectedinherited | 
Bytes out
| 
 | protectedinherited | 
SSL cipher in use
| 
 | protectedinherited | 
OpenSSL context
| 
 | inherited | 
Attaching an additional file descriptor to this function will send notifications when there is data to read.
NOTE: Only hook this if you NEED it as it can increase CPU usage of the thread! Returning -1 means that you don't want to be notified.
| 
 | inherited | 
This event will be called when you can read from the custom fd.
| 
 | inherited | 
Attaching an additional file descriptor to this function will send notifications when you are able to write to the socket.
NOTE: Only hook this if you NEED it as it can increase CPU usage of the thread! You should toggle this to -1 when you do not have anything to write otherwise it'll keep triggering repeatedly (it is level triggered).
| 
 | inherited | 
This event will be called when you can write to a custom fd.
| 
 | protectedinherited | 
Hostname connected to
| 
 | protectedinherited | 
For timers
| 
 | protectedinherited | 
True if in nonblocking mode. The socket switches to nonblocking mode once ReadLoop is called.
| 
 | protectedinherited | 
Output buffer for sending to openssl
| 
 | protectedinherited | 
Port connected to
| 
 | protectedinherited | 
Raw file descriptor of connection
| 
 | protectedinherited | 
OpenSSL session