#ifndef REMOTE_SERVER_H #define REMOTE_SERVER_H #include #include #include #include #include #include #include #include #include #include #include #include // constexpr int gBufferSize = 1024 * 1024; constexpr int gBufferSize = 256; using highClock_t = std::chrono::time_point; struct TranClient { std::shared_ptr wxSock; std::array buf; MutBuffer buffer; int64_t onlineTime; highClock_t lastRecvTime; }; class RemoteServer : public wxEvtHandler { public: RemoteServer(); public: bool Init(const wxString& ip, unsigned short port); int Run(); private: void OnServerEvent(wxSocketEvent& event); void thClientThread(const std::shared_ptr& wxSock, const wxString& id); private: bool thRun_{false}; wxWindowID serverId_; std::shared_mutex clientsMutex_; std::unique_ptr server_; std::unordered_map threads_; std::unordered_map> clients_; }; #endif // REMOTE_SERVER_H