コード例 #1
0
void CIOCPSocket2::SendCompressingPacket(const char *pData, int len)
{
    // Data's too short to bother with compression...
    if (len < 500)
    {
        Send((char *)pData, len);
        return;
    }

    if (len <= 0 || len >= 49152)
    {
        TRACE("### SendCompressingPacket Error : len = %d ### \n", len);
        return;
    }

    CCompressMng comp;
    int send_index = 0;
    char send_buff[49152];

    comp.PreCompressWork(pData, len);
    comp.Compress();

    SetByte(send_buff, WIZ_COMPRESS_PACKET, send_index);
    SetDWORD(send_buff, comp.m_nOutputBufferCurPos, send_index);
    SetDWORD(send_buff, comp.m_nOrgDataLength, send_index);
    SetDWORD(send_buff, comp.m_dwCrc, send_index);
    SetString(send_buff, comp.m_pOutputBuffer, comp.m_nOutputBufferCurPos, send_index);
    Send(send_buff, send_index);
}
コード例 #2
0
void CIOCPSocket2::SendCompressingPacket(const char *pData, int len)
{
	// Data's too short to bother with compression...
	if (len < 500)
	{
		Send((char *)pData, len);
		return;
	}
	
	CCompressMng comp;
	comp.PreCompressWork(pData, len);
	comp.Compress();

	Packet result(WIZ_COMPRESS_PACKET);
	result << comp.m_nOutputBufferCurPos << comp.m_nOrgDataLength << uint32(comp.m_dwCrc);
	result.append(comp.m_pOutputBuffer, comp.m_nOutputBufferCurPos);
	Send(&result);
}
コード例 #3
0
void CIOCPSocket2::SendCompressingPacket(Packet *pkt)
{
	// Data's too short to bother with compression...
	if (pkt->size() < 500)
	{
		Send(pkt);
		return;
	}

	// TO-DO: Replace this with LZF (again), so much simpler.
	CCompressMng comp;
	ByteBuffer buff(pkt->size() + 1);
	buff << pkt->GetOpcode() << *pkt;
	comp.PreCompressWork((const char *)buff.contents(), buff.size());
	comp.Compress();

	Packet result(WIZ_COMPRESS_PACKET);
	result << uint16(comp.m_nOutputBufferCurPos) << uint16(comp.m_nOrgDataLength) << uint32(comp.m_dwCrc);
	result.append(comp.m_pOutputBuffer, comp.m_nOutputBufferCurPos);
	Send(&result);
}