#ifndef NETWORK_WEBSOCKET_HPP_ #define NETWORK_WEBSOCKET_HPP_ #include #include #include #include class EventEmitter { private: using eventHandlers = std::function; std::unordered_map> handlers; protected: void emit(const std::string& event, const nlohmann::json& data); public: void getEvents() const; void start() const; void on(const std::string& event, eventHandlers handler); void once(const std::string& event, const eventHandlers& handler); void off(const std::string& event, eventHandlers handler); }; class WebSocket : public EventEmitter { private: std::string token; int intents; bool isBot; ix::WebSocket webSocket; const nlohmann::json payload = { {"op", GatewayOpcodes::Heartbeat}, {"d", nullptr} }; WebSocket(const std::string& token, int intents, bool isBot); public: auto operator=(const WebSocket&)->WebSocket & = delete; auto operator=(WebSocket&&)->WebSocket & = delete; WebSocket(WebSocket&&) = delete; WebSocket(const WebSocket&) = delete; _maybe_unused void sendPresenceUpdate(const char* statusType, const std::string& activityName, const int& activityType); static auto getInstance(const std::string& token = "", int intents = 0, bool bot = true) -> WebSocket&; ~WebSocket(); auto getToken() const->std::string; auto getIntents() const -> int; }; #endif