#ifndef CLIENTCORE_H #define CLIENTCORE_H #include #include #include #include #include #include #include #include #include #include class ClientCore : public wxEvtHandler { public: ClientCore(); public: bool Connect(const wxString& host, uint16_t port); void Disconnect(); public: bool GetOnlineList(InfoClientVec& infoClientVec); bool AskDirectory(const wxString& id, const wxString& path, DirFileInfoVec& dirInfoVec); private: void UseFrame(FrameBuffer* buf); private: void OnSocketEvent(wxSocketEvent& event); private: void HeartBeat(); template bool Send(const T& info, FrameBufferType type) { std::stringstream ss; cereal::BinaryOutputArchive archive(ss); archive(info); auto buf = std::make_shared(); buf->dataConst = ss.view().data(); buf->len = ss.str().size(); buf->dataType = type; return Send(buf.get()); } bool Send(FrameBuffer* buf); private: wxString id_; bool thRun_; MutBuffer buffer_; std::array buf_; std::shared_ptr socket_; std::shared_ptr heartsThread_; }; #endif // CLIENTCORE_H