Files
Client/Server/AdminTool/AdminToolLibrary/network/buffer/RYL_CumulateBuffer.cpp
LGram16 dd97ddec92 Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 20:17:20 +09:00

70 lines
1.5 KiB
C++

#include "stdafx.h"
#include < Stream/Buffer/Buffer.h >
#include < Stream/Buffer/BufferFactory.h >
#include < Network/Session/Session.h >
#include < Network/Buffer/Ryl_CumulateBuffer.h >
//사용용도는 Loop나 연속적으로 패킷을 보낼상항이 생겼을경우 일단 이놈한테 누적시키고 보내버리자....
CCumulateBuffer::CCumulateBuffer(unsigned long BufferLength, CSession* pSession)
{
m_lpBuffer = new char[BufferLength];
m_lpSession = pSession;
m_lpNowPos = m_lpBuffer;
m_lpEndPos = m_lpBuffer + BufferLength;
m_BufferLength = BufferLength;
m_FillLength = 0;
}
CCumulateBuffer::~CCumulateBuffer( )
{
if(m_FillLength) SendAll();
if(m_lpBuffer)
{
delete [] m_lpBuffer;
}
}
char* CCumulateBuffer::GetBuffer(unsigned int Length)
{
if((m_lpNowPos + Length) > m_lpEndPos)
{
//버퍼에 더이상 들어갈 공간이 없다 버퍼의 내용을 전부 비우자.
//버퍼에 누적된 패킷을 전부 보내버리잣..
if(!SendAll())
{
return NULL;
}
}
char* PktPos = m_lpNowPos;
m_lpNowPos += Length; // 다음 패킷이 누적될 포인터
m_FillLength += Length; // 현재 버퍼 사용량
return PktPos; // 누적될 지점
}
//PktBase를 상속받은 패킷을 꼭~ WrapHeader을 해줘야한다 안하면 싼다..
bool CCumulateBuffer::SendAll()
{
CBuffer* SendBuffer = CREATE_BUFFER(m_lpSession->GetPolicy().GetBufferFactory(), m_FillLength);
if((SendBuffer == NULL) || (m_lpSession == NULL))
{
return false;
}
SendBuffer->push(m_lpBuffer, m_FillLength);
m_lpNowPos = m_lpBuffer;
m_FillLength = 0;
return m_lpSession->SendPending(SendBuffer);
}