Files
smartservice_native/hdssd/huslib/SohHandler.h
T
2026-05-20 03:08:08 +09:00

54 lines
1.0 KiB
C++

#ifndef SOH_HANDLER__H_
#define SOH_HANDLER__H_
#ifdef _WIN32
#pragma once
#endif
// size only in header
class HSohHandler : public HProtocolHandler
{
public:
enum
{
HH_SOH_MAX_COMMAND_PACKET_SIZE = 65536
};
HSohHandler();
~HSohHandler();
int SendPacket(const char * pData, size_t nSize);
// for zero copy
char * GetSBufPtr() { return m_pSendBuffer->Tail(); }
size_t GetSBufSize() { return m_pSendBuffer->RemainSize(); }
bool MarkUsedSBuf(size_t nSize) { return m_pSendBuffer->MoveTail(nSize); }
int SendBufferedPacket();
protected:
int SendBufferCommand();
void OnReceivedStatusFromTransport(int nStatus);
int OnReceivedFromTransport(const char * pData, int nSize);
int OnSendRetryToTransport();
bool OnPrepareReceive() { return true; }
virtual void OnInitialize(bool bIsSuccess) = 0;
virtual void OnTerminate() = 0;
virtual int OnReceivedBody(const char * pBody, int nSize) = 0;
protected:
HStreamBuffer * m_pRecvBuffer;
size_t m_nBodySize;
HStreamBuffer * m_pSendBuffer;
};
#endif // REDUNDANCY__H_