![]() |
D++ (DPP)
C++ Discord API Bot Library
|
Creates a HTTP server which listens for incoming Discord interactions, and if verified as valid, raises them as cluster events, returning the response back. Note that Discord requires all interaction endpoints to have a valid SSL certificate (not self signed) so in most cases you should put this port behind a reverse proxy, e.g. nginx, apache, etc. More...
#include <discord_webhook_server.h>
Public Member Functions | |
discord_webhook_server (cluster *creator, const std::string &discord_public_key, const std::string_view address, uint16_t port, const std::string &ssl_private_key="", const std::string &ssl_public_key="") | |
Constructor for creation of a HTTP(S) server. More... | |
void | handle_request (http_server_request *request) |
Handle Discord outbound webhook. More... | |
virtual | ~discord_webhook_server ()=default |
Virtual dtor. More... | |
void | emplace (socket newfd) override |
Emplace a new request into the connection pool. More... | |
virtual void | handle_accept (socket sfd, const struct socket_events &e) |
Handle a new incoming socket with accept() Accepts a new connection, and calls emplace() if valid. More... | |
Public Attributes | |
signature_verifier | verifier |
Verifier for signed requests. More... | |
std::string | public_key_hex |
Public key from application dashboard. More... | |
http_server_request_event | request_handler |
Request handler callback to use for all incoming HTTP(S) requests. More... | |
uint16_t | bound_port |
Port we are listening on. More... | |
raii_socket | fd |
The listening socket for incoming connections. More... | |
std::unordered_map< socket, std::unique_ptr< http_server_request > > | connections |
Active connections for the server of type T. More... | |
cluster * | creator |
Cluster creator. More... | |
bool | plaintext |
True if plain text connections to the server are allowed. More... | |
std::string | private_key_file |
Private key PEM file path, if running an SSL server. More... | |
std::string | public_key_file |
Public key PEM file path, if running an SSL server. More... | |
event_handle | close_event |
Event to handle socket removal from the connection map. More... | |
socket_events | events |
Socket events for listen socket in the socket engine. More... | |
Creates a HTTP server which listens for incoming Discord interactions, and if verified as valid, raises them as cluster events, returning the response back. Note that Discord requires all interaction endpoints to have a valid SSL certificate (not self signed) so in most cases you should put this port behind a reverse proxy, e.g. nginx, apache, etc.
dpp::discord_webhook_server::discord_webhook_server | ( | cluster * | creator, |
const std::string & | discord_public_key, | ||
const std::string_view | address, | ||
uint16_t | port, | ||
const std::string & | ssl_private_key = "" , |
||
const std::string & | ssl_public_key = "" |
||
) |
Constructor for creation of a HTTP(S) server.
creator | Cluster creator |
discord_public_key | Public key for the application from the application dashboard page |
address | address to bind to, use "0.0.0.0" to bind to all local addresses |
port | port to bind to. You should generally use a port > 1024. |
ssl_private_key | Private key PEM file for HTTPS/SSL. If empty, a plaintext server is created |
ssl_public_key | Public key PEM file for HTTPS/SSL. If empty, a plaintext server is created |
|
virtualdefault |
Virtual dtor.
|
overridevirtualinherited |
Emplace a new request into the connection pool.
newfd | file descriptor of new request |
Implements dpp::socket_listener< http_server_request >.
|
inlinevirtualinherited |
Handle a new incoming socket with accept() Accepts a new connection, and calls emplace() if valid.
sfd | File descriptor for listening socket |
e | socket events for the listening socket |
void dpp::discord_webhook_server::handle_request | ( | http_server_request * | request | ) |
Handle Discord outbound webhook.
request | Request from discord |
|
inherited |
Port we are listening on.
|
inherited |
Event to handle socket removal from the connection map.
|
inherited |
Active connections for the server of type T.
|
inherited |
Cluster creator.
|
inherited |
Socket events for listen socket in the socket engine.
|
inherited |
The listening socket for incoming connections.
|
inherited |
True if plain text connections to the server are allowed.
|
inherited |
Private key PEM file path, if running an SSL server.
|
inherited |
Public key PEM file path, if running an SSL server.
std::string dpp::discord_webhook_server::public_key_hex |
Public key from application dashboard.
|
inherited |
Request handler callback to use for all incoming HTTP(S) requests.
signature_verifier dpp::discord_webhook_server::verifier |
Verifier for signed requests.