/* * Copyright (C) 2016+ AzerothCore , released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2 * Copyright (C) 2008-2016 TrinityCore * Copyright (C) 2005-2009 MaNGOS */ #ifndef __REALMSOCKET_H__ #define __REALMSOCKET_H__ #include #include #include #include #include "Common.h" class RealmSocket : public ACE_Svc_Handler { private: typedef ACE_Svc_Handler Base; public: class Session { public: Session(void); virtual ~Session(void); virtual void OnRead(void) = 0; virtual void OnAccept(void) = 0; virtual void OnClose(void) = 0; }; RealmSocket(void); ~RealmSocket(void) override; [[nodiscard]] size_t recv_len(void) const; bool recv_soft(char* buf, size_t len); bool recv(char* buf, size_t len); void recv_skip(size_t len); bool send(const char* buf, size_t len); [[nodiscard]] const std::string& getRemoteAddress(void) const; [[nodiscard]] uint16 getRemotePort(void) const; int open(void*) override; int close(u_long) override; int handle_input(ACE_HANDLE = ACE_INVALID_HANDLE) override; int handle_output(ACE_HANDLE = ACE_INVALID_HANDLE) override; int handle_close(ACE_HANDLE = ACE_INVALID_HANDLE, ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK) override; void set_session(Session* session); private: ssize_t noblk_send(ACE_Message_Block& message_block); ACE_Message_Block input_buffer_; Session* session_; std::string _remoteAddress; uint16 _remotePort; }; #endif /* __REALMSOCKET_H__ */