Distribution_Service/CC_SDK/Include/CCServlet/HttpSocketChannel.h

62 lines
2.0 KiB
C
Raw Permalink Normal View History

2025-12-03 18:08:23 +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;
2026-03-24 14:43:26 +08:00
static CCMutex _mutex_;
2025-12-03 18:08:23 +08:00
bool SSL_Free = true;
2026-03-20 09:51:56 +08:00
bool isTimed = false;
2025-12-03 18:08:23 +08:00
bool send_status = false, send_start = false;
using ReadCallBack = std::function<void()>;
CCMutex _mutex_read;
ReadCallBack read_cb;
2026-03-20 09:51:56 +08:00
size_t start_time = 0;
2025-12-03 18:08:23 +08:00
public:
String URL = "";
Queue<ByteArray> send_queue;
Queue<ByteArray> read_queue;
2026-03-20 09:51:56 +08:00
bool keepAliceOut = false;
int KeepAliceCount = 0;
uint32_t KeepAliceTime = 0;
2025-12-03 18:08:23 +08:00
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;
2026-03-20 09:51:56 +08:00
[[nodiscard]] String readHeader();
2025-12-03 18:08:23 +08:00
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);
2026-03-20 09:51:56 +08:00
void TimeSend();
int getTimeout() const;
uint64_t getDataCount();
void setStartTime(size_t time);
2025-12-03 18:08:23 +08:00
};
}
#endif