当前位置: 首页>>代码示例>>C++>>正文


C++ Packet::AttachData方法代码示例

本文整理汇总了C++中Packet::AttachData方法的典型用法代码示例。如果您正苦于以下问题:C++ Packet::AttachData方法的具体用法?C++ Packet::AttachData怎么用?C++ Packet::AttachData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Packet的用法示例。


在下文中一共展示了Packet::AttachData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: IsValidPacket

bool Connections::IsValidPacket(void* PacketHeader, WORD PacketLength)
{
    if (GetHeaderSize() > PacketLength)
    {
        return false;
    }

    Packet packet;
    packet.AttachData((BYTE*)PacketHeader, PacketLength);

    return packet.IsValidPacket();
}
开发者ID:ChowZenki,项目名称:dboserver,代码行数:12,代码来源:Connections.cpp

示例2: CompleteRecv

int Connections::CompleteRecv(DWORD TransferedBytes)
{
    FUNCTION_BEGIN();

    if (0 == TransferedBytes)
    {
        return 1;
    }

    IncreaseBytesRecv(TransferedBytes);

    if (false == _recvBuffer.IncreasePushPos(TransferedBytes))
    {
        Logger::Log("Session[%X] Recv Buffer OverFlow : BufferCur[%d] BufferMax[%d] TransferedBytes[%u]\n", this, _recvBuffer.GetCurSize(), _recvBuffer.GetQueueSize(), TransferedBytes);
        return 2;
    }

    int rc = 0;
    WORD PacketLength = 0;

    Packet packet;
    do
    {
        rc = MakeSureCompletedPacket(&_recvBuffer, &PacketLength, _PacketEncoder);
        if (0 != rc)
        {
            if (2 == rc || 4 == rc)
            {
                break;
            }

            Logger::Log("Session[%X] MakeSureCompletedPacket Error[%d]\n", this, rc);
            return rc;
        }

        if (true != IsValidPacket(_recvBuffer.GetQueueWorkPtr(), PacketLength))
        {
            Logger::Log("true != IsValidPacket()\n");
        }

        packet.AttachData(_recvBuffer.GetQueueWorkPtr(), PacketLength);

        _recvBuffer.IncreaseWorkPos(packet.GetUsedSize());

        if (_PacketEncoder)
        {
            rc = _PacketEncoder->RxDecrypt(packet);
            if (0 != rc)
            {
                Logger::Log("Session[%X] RxDecrypt Error[%d]\n", this, rc);
                return rc;
            }
        }

        BYTE ValidSequence = (BYTE)(_PacketRecvCount & PACKET_MAX_SEQUENCE);
        if (false == HasValidSequence(packet.GetPacketHeader(), ValidSequence))
        {
            Logger::Log("Session[%X] Sequence Error[%d] PacketSEQ[%u] CurrentSEQ[%u]\n", this, rc, GetSequence(_recvBuffer.GetQueueWorkPtr()), ValidSequence);
            return 3; //ERR_NET_PACKET_SEQUENCE_FAIL
        }

        IncreasePacketRecv();

        _NetworkRef->PostNetEventMessage((WPARAM)NETEVENT_RECV, (LPARAM)this);


    } while (0 == rc);

    rc = PostRecv();
    if (0 != rc)
    {
        return rc;
    }

    return 0;
}
开发者ID:ChowZenki,项目名称:dboserver,代码行数:76,代码来源:Connections.cpp


注:本文中的Packet::AttachData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。