This commit is contained in:
fluttershy 2025-01-30 23:21:16 +05:00
parent 5a34d87814
commit 6e0d3ace47
3 changed files with 9 additions and 7 deletions

View File

@ -1,6 +1,7 @@
Checks: >
Checks:
'-*,
clang-analyzer-*,
modernize-*,
performance-*,
bugprone-*,
cppcoreguidelines-*
cppcoreguidelines-*'

View File

@ -1,9 +1,9 @@
#include "websocket.hpp"
void EventEmitter::emit(const std::string& event, const nlohmann::json& data) {
if (auto it = handlers.find(event); it != handlers.end()) {
for (const auto& handler : it->second) {
std::for_each(it->second.begin(), it->second.end(), [&data](const auto& handler) {
handler(data);
}
});
}
}
void EventEmitter::getEvents() {
@ -30,9 +30,9 @@ void EventEmitter::off(const std::string& event, eventHandlers handler) {
auto it = handlers.find(event);
if (it != handlers.end()) {
auto& vec = it->second;
vec.erase(std::remove_if(vec.begin(), vec.end(), [&handler](const eventHandlers& h) {
vec.erase(std::ranges::remove_if(vec, [&handler](const eventHandlers& h) {
return h.target<eventHandlers>() == handler.target<eventHandlers>();
}), vec.end());
}).begin(), vec.end());
}
}
WebSocket::WebSocket(const std::string& token, int intents, bool isBot) : token(token), intents(intents), isBot(isBot) {
@ -55,7 +55,7 @@ WebSocket::WebSocket(const std::string& token, int intents, bool isBot) : token(
}
})},
{"status", "idle"},
{"since", 91879201},
{"since", 0},
{"afk", false}
}}
}}

View File

@ -1,6 +1,7 @@
#ifndef NETWORK_WEBSOCKET_HPP_
#define NETWORK_WEBSOCKET_HPP_
#include <includes.hpp>
#include <ranges>
#include <ixwebsocket/IXNetSystem.h>
#include <ixwebsocket/IXWebSocket.h>
class EventEmitter {