| 1 | /************************************************************************************ |
| 2 | * |
| 3 | * D++, A Lightweight C++ library for Discord |
| 4 | * |
| 5 | * SPDX-License-Identifier: Apache-2.0 |
| 6 | * Copyright 2021 Craig Edwards and D++ contributors |
| 7 | * (https://github.com/brainboxdotcc/DPP/graphs/contributors) |
| 8 | * |
| 9 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 | * you may not use this file except in compliance with the License. |
| 11 | * You may obtain a copy of the License at |
| 12 | * |
| 13 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 14 | * |
| 15 | * Unless required by applicable law or agreed to in writing, software |
| 16 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 18 | * See the License for the specific language governing permissions and |
| 19 | * limitations under the License. |
| 20 | * |
| 21 | ************************************************************************************/ |
| 22 | |
| 23 | #include <dpp/dpp.h>cxx . . $ `<file>/include/dpp/dpp.h`/ |
| 24 | #include <iostream> |
| 25 | #include <thread> |
| 26 | #include <atomic> |
| 27 | #ifndef _WIN32 |
| 28 | #include <csignal> |
| 29 | #endif |
| 30 | |
| 31 | dppcxx . . $ dpp/::clustercxx . . $ dpp/cluster#* scxx . . $ s.{nullptr}; |
| 32 | stdcxx . . $ std/::atomic_boolcxx . . $ std/atomic_bool# signalledcxx . . $ signalled.{false}; |
| 33 | |
| 34 | int maincxx . . $ main(b126dc7c1de90089).() { |
| 35 | using namespace stdcxx . . $ std/::chrono_literals; |
| 36 | char* t = getenv("DPP_UNIT_TEST_TOKEN"); |
| 37 | if (t) { |
| 38 | dppcxx . . $ dpp/::clustercxx . . $ dpp/cluster# soak_testcxx . . $ dpp/cluster#cluster(13cb741d36ace229).(tcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., dppcxx . . $ dpp/::i_default_intentscxx . . $ dpp/i_default_intents. | dppcxx . . $ dpp/::i_guild_memberscxx . . $ dpp/i_guild_members., 1, 0, 1); |
| 39 | scxx . . $ s. = &soak_test; |
| 40 | //soak_test.set_websocket_protocol(dpp::ws_etf); |
| 41 | soak_test.on_logcxx . . $ dpp/cluster#on_log.(cxx . . $ dpp/event_router_t#`operator()`(7d840609c6f74506).[&](const dppcxx . . $ dpp/::log_tcxx . . $ dpp/log_t#& log) { |
| 42 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "[" <<cxx . . $ std/`operator<<`(88df5bef833f7f83). dppcxx . . $ dpp/::utilitycxx . . $ dpp/utility/::current_date_timecxx . . $ dpp/utility/current_date_time(efd28698952f529a).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "] " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). dppcxx . . $ dpp/::utilitycxx . . $ dpp/utility/::loglevelcxx . . $ dpp/utility/loglevel(bd6669da0656db).(log.severitycxx . . $ dpp/log_t#severity.) <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). ": " <<cxx . . $ std/`operator<<`(88df5bef833f7f83). log.messagecxx . . $ dpp/log_t#message. <<cxx . . $ std/basic_ostream#`operator<<`(f46f7e25851d787a). stdcxx . . $ std/::endlcxx . . $ std/endl(345bf97a19cc83a9).; |
| 43 | }); |
| 44 | soak_test.startcxx . . $ dpp/cluster#start(fa7c3f1aeb8ff3e5).(dppcxx . . $ dpp/::st_returncxx . . $ dpp/st_return.); |
| 45 | |
| 46 | #ifndef _WIN32 |
| 47 | signal(SIGUSR1cxx . . $ `<external>/1457673850468744829/signum-arch.h:49:9`!, [](int sig) { |
| 48 | signalledcxx . . $ signalled. =cxx . . $ std/atomic#`operator=`(4264aff4942d46ac). true; |
| 49 | }); |
| 50 | #endif |
| 51 | |
| 52 | while (true) { |
| 53 | stdcxx . . $ std/::this_threadcxx . . $ std/this_thread/::sleep_forcxx . . $ std/this_thread/sleep_for(fb2140da9187dddf).(1scxx . . $ std/literals/chrono_literals/`operator""s`(563d2251ecf9d1e7).); |
| 54 | dppcxx . . $ dpp/::discord_clientcxx . . $ dpp/discord_client#* dc = soak_test.get_shardcxx . . $ dpp/cluster#get_shard(ed3cdbf35672c617).(0); |
| 55 | if (dc != nullptr) { |
| 56 | if (time(nullptr) % 60 == 0) { |
| 57 | stdcxx . . $ std/::coutcxx . . $ std/cout. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "Websocket latency: " <<cxx . . $ std/basic_ostream#`operator<<`(d90e0e305b0e25c2). stdcxx . . $ std/::fixedcxx . . $ std/fixed(cf36cc481190cd1f). <<cxx . . $ std/basic_ostream#`operator<<`(968942d578224538). dc->websocket_pingcxx . . $ dpp/discord_client#websocket_ping. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Guilds: " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). dppcxx . . $ dpp/::get_guild_countcxx . . $ dpp/get_guild_count(f708dce9a8856c70).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). " Users: " <<cxx . . $ std/basic_ostream#`operator<<`(b09cd8ec4365c7ed). dppcxx . . $ dpp/::get_user_countcxx . . $ dpp/get_user_count(f708dce9a8856c70).() <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\n"; |
| 58 | } |
| 59 | if (signalledcxx . . $ signalled.) { |
| 60 | signalledcxx . . $ signalled. =cxx . . $ std/atomic#`operator=`(4264aff4942d46ac). false; |
| 61 | dc->closecxx . . $ dpp/websocket_client#close(49f6e7a06ebc5aa8).(); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | } |