Esempio n. 1
0
        private void FlushPackets()
        {
            while (PacketQueue.Count > 0)
            {
                ServerPacket packet;
                if (PacketQueue.TryDequeue(out packet))
                {
                    if (packet.Header.HasFlag(PacketHeaderFlags.EncryptedChecksum) && ConnectionData.PacketSequence < 2)
                    {
                        ConnectionData.PacketSequence = 2;
                    }

                    packet.Header.Sequence = ConnectionData.PacketSequence++;
                    packet.Header.Id       = 0x0B; // This value is currently the hard coded Server ID. It can be something different...
                    packet.Header.Table    = 0x14;
                    packet.Header.Time     = (ushort)ConnectionData.ServerTime;

                    if (packet.Header.Sequence >= 2u)
                    {
                        CachedPackets.TryAdd(packet.Header.Sequence, packet);
                    }

                    SendPacket(packet);
                }
            }
        }
Esempio n. 2
0
        private void FlushPackets()
        {
            while (PacketQueue.Count > 0)
            {
                ServerPacket packet;
                if (PacketQueue.TryDequeue(out packet))
                {
                    if (packet.Header.HasFlag(PacketHeaderFlags.EncryptedChecksum) && ConnectionData.PacketSequence < 2)
                    {
                        ConnectionData.PacketSequence = 2;
                    }

                    packet.Header.Sequence = ConnectionData.PacketSequence++;
                    packet.Header.Id       = (ushort)(connectionType == ConnectionType.Login ? 0x0B : 0x18);
                    packet.Header.Table    = 0x14;
                    packet.Header.Time     = (ushort)ConnectionData.ServerTime;

                    if (packet.Header.Sequence >= 2u)
                    {
                        CachedPackets.TryAdd(packet.Header.Sequence, packet);
                    }

                    SendPacket(packet);
                }
            }
        }
Esempio n. 3
0
        private void AcknowledgeSequence(uint sequence)
        {
            //TODO Sending Acks seems to cause some issues.  Needs further research.
            //if (!sendAck)
            //    sendAck = true;
            var removalList = CachedPackets.Where(x => x.Key < sequence);

            foreach (var item in removalList)
            {
                ServerPacket removedPacket;
                CachedPackets.TryRemove(item.Key, out removedPacket);
            }
        }
Esempio n. 4
0
        private void Retransmit(uint sequence)
        {
            ServerPacket cachedPacket;

            if (CachedPackets.TryGetValue(sequence, out cachedPacket))
            {
                Console.WriteLine("Retransmit " + sequence);
                if (!cachedPacket.Header.HasFlag(PacketHeaderFlags.Retransmission))
                {
                    cachedPacket.Header.Flags |= PacketHeaderFlags.Retransmission;
                }
                SendPacketRaw(cachedPacket);
            }
        }