Beispiel #1
0
        void HandleNormalPackets(Queue <BasePacket> listOfPackets)
        {
            foreach (var packet in listOfPackets)
            {
                numPacketsReceived++;
                // normal processing
                EntityPacket ep = packet as EntityPacket;
                if (ep != null)
                {
                    //entityId = ep.entityId;
                    int tempEntityId = ep.entityId;
                    if (entityId == tempEntityId)
                    {
                        Console.Write("This entity packet updated {0}\n", tempEntityId);
                    }
                    else
                    {
                        Console.Write("Entity update packet {0}\n", tempEntityId);
                    }
                    entityId = tempEntityId;
                    continue;
                }
                KeepAlive ka = packet as KeepAlive;
                if (ka != null)
                {
                    KeepAliveResponse kar = (KeepAliveResponse)IntrepidSerialize.TakeFromPool(PacketType.KeepAliveResponse);
                    socket.Send(kar);
                }

                if (packet is ServerPingHopperPacket)
                {
                    ServerPingHopperPacket hopper = packet as ServerPingHopperPacket;
                    hopper.Stamp("client end");
                    hopper.PrintList();
                }
                if (packet.PacketType == PacketType.DataBlob)
                {
                    HandleBlobData(packet as DataBlob);
                }
            }
            foreach (var packet in listOfPackets)
            {
                if (packet.PacketType != PacketType.DataBlob)// tyhese need special handling
                {
                    IntrepidSerialize.ReturnToPool(packet);
                }
            }
        }
Beispiel #2
0
        void HandleNormalPackets(Queue <BasePacket> listOfPackets)
        {
            foreach (var packet in listOfPackets)
            {
                //Console.WriteLine("normal packet received {0} .. isLoggedIn = true", packet.PacketType);
                numPacketsReceived++;
                // normal processing
                if (packet is PlayerFullPacket && localPlayer.entityId == 0)
                {
                    localPlayer.entityId = (packet as PlayerFullPacket).entityId;
                }

                /*     ServerTick st = packet as ServerTick;
                 *   if(st != null)
                 *   {
                 *       Console.WriteLine("server tick {0}", st.TickCount);
                 *
                 *       continue;
                 *   }*/
                KeepAlive ka = packet as KeepAlive;
                if (ka != null)
                {
                    KeepAliveResponse kar = (KeepAliveResponse)IntrepidSerialize.TakeFromPool(PacketType.KeepAliveResponse);
                    socket.Send(kar);
                }

                if (packet is ServerPingHopperPacket)
                {
                    ServerPingHopperPacket hopper = packet as ServerPingHopperPacket;
                    hopper.Stamp("client end");
                    hopper.PrintList();
                }
                if (packet is WorldEntityPacket)
                {
                    WorldEntityPacket wep = packet as WorldEntityPacket;
                    if (localPlayer.entityId == wep.entityId)
                    {
                        localPlayer.position = wep.position.Get();
                        localPlayer.rotation = wep.rotation.Get();
                    }
                }
                EntityPacket ep = packet as EntityPacket;
                if (ep != null)
                {
                    //entityId = ep.entityId;
                    int tempEntityId = ep.entityId;
                    if (localPlayer.entityId == tempEntityId)
                    {
                        Console.Write("This entity packet updated {0}\n", tempEntityId);
                    }

                    /* else
                     * {
                     *   Console.Write("Entity update packet {0}\n", tempEntityId);
                     * }*/
                    continue;
                }

                // Console.WriteLine("normal packet received {0}", packet.PacketType);

                IntrepidSerialize.ReturnToPool(packet);
            }
        }