#ifndef CC_SOCKET_CHANNEL_H #define CC_SOCKET_CHANNEL_H #include "OpenSSL/CCSSL.h" #include "Socket/CCClientSocket.h" #include "CCLogger.h" #include "EventLoop.h" #define SocketClientNULL "Error_10030" #define CC_R_BUFFER_SIZE 1 #define CC_S_BUFFER_SIZE 1024 #define File_Buffer_Max 4096 namespace CTL { class HttpSocketChannel { SSL_Client* ssl_client_t = nullptr; ClientSocket* client_t = nullptr; unsigned long TimingTime = 1000; Logger_Level level = Debug; EventLoop* m_eventLoop = nullptr; inline static CCMutex _mutex_; bool SSL_Free = true; bool isTimed = false; bool send_status = false, send_start = false; using ReadCallBack = std::function; CCMutex _mutex_read; ReadCallBack read_cb; size_t start_time = 0; public: String URL = ""; Queue send_queue; Queue read_queue; bool keepAliceOut = false; int KeepAliceCount = 0; uint32_t KeepAliceTime = 0; private: void MessagePrint(const CTL::String& str,Logger_Level level = Debug) const; public: HttpSocketChannel(ClientSocket* client,SSL_Client* ssl_client); ~HttpSocketChannel(); [[nodiscard]] SSL_Client* getSSLClient() const; [[nodiscard]] ClientSocket* getClient() const; [[nodiscard]] String readHeader(); int receive(char* buffer,size_t size) const; int write(const char* buffer,size_t size) const; void setTimeOut(int ms); void releaseSSL(); [[nodiscard]] bool getSend_status() const; [[nodiscard]] bool getSend_start() const; void setSend_status(bool status); void setSend_start(bool status); void setEventLoop(EventLoop* eventLoop); void setReadFun(const ReadCallBack& cb); void TimeSend(); int getTimeout() const; uint64_t getDataCount(); void setStartTime(size_t time); }; } #endif