public void NonActionPacket()
        {
            Packet packet = new TestNonActionPacket(playerId);

            packetReceiver.PacketReceived(packet);

            Queue <Packet> packets = packetReceiver.GetReceivedPackets();

            Assert.AreEqual(1, packets.Count);
            Assert.AreEqual(packet, packets.Dequeue());
        }
Beispiel #2
0
        public void ProcessPackets()
        {
            Queue <Packet> packets = chunkAwarePacketReceiver.GetReceivedPackets();

            foreach (Packet packet in packets)
            {
                if (packetProcessorsByType.ContainsKey(packet.GetType()))
                {
                    PacketProcessor processor = packetProcessorsByType[packet.GetType()];
                    processor.ProcessPacket(packet);
                }
                else
                {
                    Console.WriteLine("No packet processor for the given type: " + packet.GetType());
                }
            }
        }
        public void ProcessPackets()
        {
            Queue <Packet> packets = chunkAwarePacketReceiver.GetReceivedPackets();

            foreach (Packet packet in packets)
            {
                if (packetProcessorsByType.ContainsKey(packet.GetType()))
                {
                    try
                    {
                        PacketProcessor processor = packetProcessorsByType[packet.GetType()];
                        processor.ProcessPacket(packet, null);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error processing packet: " + packet + ": " + ex);
                    }
                }
                else
                {
                    ClientLogger.Debug("No packet processor for the given type: " + packet.GetType());
                }
            }
        }