示例#1
0
        public void process_packet(PacketStream ps, int pktNum)
        {
            if (pktNum % 2 == 0) // if the packet is an even number, it means the server send a reliable packet, we have to send a acknowledge packet back
            {
                PacketStream h_shake = new PacketStream();
                h_shake.WriteShort(packetNumber); // own packet number
                h_shake.WriteByte(1);
                h_shake.WriteShort(pktNum);       // their packet number
                ch.SendStream(h_shake, false);
            }

            while (!ps.AtEnd())
            {
                int type1 = ps.ReadByte();


                if (known_table[type1] != null)
                {
                    known_table[type1](ps);
                }
                else
                {
                    LogConsole("unknown packet: type: " + type1 + "  packet: " + ps);
                    ps.SkipAll();
                }
            }

            //if (!ps.AtEnd())
            //  process_packet(ps, pktNum);
        }
示例#2
0
        public void process_packet(PacketStream ps,int pktNum)
        {
            if (pktNum % 2 == 0) // if the packet is an even number, it means the server send a reliable packet, we have to send a acknowledge packet back
            {
                PacketStream h_shake = new PacketStream();
                h_shake.WriteShort(packetNumber); // own packet number
                h_shake.WriteByte(1);
                h_shake.WriteShort(pktNum); // their packet number
                ch.SendStream(h_shake,false);
            }

            while (!ps.AtEnd())
            {

                int type1 = ps.ReadByte();

                if (known_table[type1] != null)
                {
                    known_table[type1](ps);
                }
                else
                {
                    LogConsole("unknown packet: type: " + type1 + "  packet: " + ps);
                    ps.SkipAll();
                }
            }

            //if (!ps.AtEnd())
              //  process_packet(ps, pktNum);
        }