#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); }