USB_Config_Vendor/CC_SDK/Include/CCServlet/HttpSocketChannel.h

53 lines
1.7 KiB
C
Raw Permalink Normal View History

2026-02-03 14:36:30 +08:00
#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 send_status = false, send_start = false;
using ReadCallBack = std::function<void()>;
CCMutex _mutex_read;
ReadCallBack read_cb;
public:
String URL = "";
Queue<ByteArray> send_queue;
Queue<ByteArray> read_queue;
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() const;
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);
};
}
#endif