MCPcopy Create free account
hub / github.com/brainboxdotcc/DPP / main

Function main

src/httpservertest/httpservertest.cpp:34–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32}
33
34int main() {
35 using namespace std::chrono_literals;
36 char* t = getenv("DPP_UNIT_TEST_TOKEN");
37 if (t) {
38 dpp::cluster bot(t, 0, dpp::NO_SHARDS, 1, 1, false, dpp::cache_policy::cpol_none);
39 dpp::http_server *server1{nullptr}, *server2{nullptr};
40
41 bot.on_log([&](const dpp::log_t& log) {
42 std::cout << "[" << dpp::utility::current_date_time() << "] " << dpp::utility::loglevel(log.severity) << ": " << log.message << std::endl;
43 });
44 bot.on_ready([&](const dpp::ready_t& ready) {
45
46 /* A plaintext HTTP server on port 3011 */
47 server1 = new dpp::http_server(&bot, "0.0.0.0", 3011, [&bot](dpp::http_server_request* request) {
48 respond(*request);
49 });
50
51 /* An SSL enabled HTTPS server on port 3042 */
52 server2 = new dpp::http_server(&bot, "0.0.0.0", 3042, [&bot](dpp::http_server_request* request) {
53 respond(*request);
54 }, "../../testdata/localhost.key", "../../testdata/localhost.pem");
55
56 /* A discord interactions endpoint on port 3010 */
57 bot.enable_webhook_server(getenv("DPP_PUBLIC_KEY"), "0.0.0.0", 3010);
58 });
59 bot.on_slashcommand([&](const dpp::slashcommand_t& event) {
60 event.reply("hello");
61 });
62
63 bot.start(dpp::st_wait);
64 }
65}

Callers

nothing calls this directly

Calls 5

current_date_timeFunction · 0.85
respondFunction · 0.85
startMethod · 0.80
loglevelFunction · 0.50
replyMethod · 0.45

Tested by

no test coverage detected