protected override void ProcessReceivedBuffer(Client Sender, BufferStream Buffer) { ulong lastAckID = Buffer.ReadUInt64(); uint ackMask = Buffer.ReadUInt32(); bool isReliable = Buffer.ReadBool(); ulong packetID = Buffer.ReadUInt64(); ushort sliceCount = Buffer.ReadUInt16(); ushort sliceIndex = Buffer.ReadUInt16(); BufferStream buffer = new BufferStream(Buffer.Buffer, Constants.UDP.PACKET_HEADER_SIZE, Buffer.Size - Constants.UDP.PACKET_HEADER_SIZE); UDPClient client = (UDPClient)Sender; IncomingUDPPacketsHolder incomingHolder = (isReliable ? client.IncomingReliablePacketHolder : client.IncomingNonReliablePacketHolder); IncomingUDPPacket packet = incomingHolder.GetPacket(packetID); if (packet == null) { packet = new IncomingUDPPacket(packetID, sliceCount); incomingHolder.AddPacket(packet); } packet.SetSliceBuffer(sliceIndex, buffer); if (packet.IsCompleted) { if (incomingHolder.LastID < packet.ID) { incomingHolder.SetLastID(packet.ID); } if (isReliable) { ProcessIncomingReliablePackets(client); } else { ProcessIncomingNonReliablePacket(client, packet); } } OutgoingUDPPacketsHolder outgoingHolder = (isReliable ? client.OutgoingReliablePacketHolder : client.OutgoingNonReliablePacketHolder); outgoingHolder.SetLastAckID(lastAckID); outgoingHolder.SetAckMask(ackMask); if (isReliable) { ProcessOutgoingReliablePackets(client); } else { ProcessOutgoingNonReliablePackets(client); } }
protected override void HandlePingPacketPayload(BufferStream Buffer) { base.HandlePingPacketPayload(Buffer); ulong lastAckID = Buffer.ReadUInt64(); uint ackMask = Buffer.ReadUInt32(); outgoingReliablePacketHolder.SetLastAckID(lastAckID); outgoingReliablePacketHolder.SetAckMask(ackMask); lastAckID = Buffer.ReadUInt64(); ackMask = Buffer.ReadUInt32(); outgoingNonReliablePacketHolder.SetLastAckID(lastAckID); outgoingNonReliablePacketHolder.SetAckMask(ackMask); }