public override void Write(PacketOutput output)
 {
     output.Write(Time);
     output.Write(BulletId);
     output.Write(ObjectId);
     output.Write(TargetId);
 }
Exemple #2
0
 public override void Write(PacketOutput output)
 {
     output.Write(Time);
     Position.Write(output);
     SlotObject1.Write(output);
     SlotObject2.Write(output);
 }
        public void SendPacket(OutgoingPacket packet)
        {
            if (!_socket.Connected)
            {
                return;
            }
            MemoryStream ms = new MemoryStream();

            using (PacketOutput output = new PacketOutput(ms))
            {
                output.Write(0);
                output.Write(packet.GetPacketType().ToId());
                packet.Write(output);
            }
            byte[] buffer = ms.ToArray();
            _outgoingEncryption.Cipher(buffer, 5);
            int size = buffer.Length;

            byte[] a = BitConverter.GetBytes(IPAddress.NetworkToHostOrder(size));
            buffer[0] = a[0];
            buffer[1] = a[1];
            buffer[2] = a[2];
            buffer[3] = a[3];
            _socket?.Send(buffer);
        }
        public void Read_Packet_Without_Content()
        {
            PacketOutput output = _packetReader.Read("mapclean");

            Check.That(output.Header).Is("mapclean");
            Check.That(output.Content).IsNullOrEmpty();
        }
 public override void Write(PacketOutput output)
 {
     output.Write(Time);
     output.Write(BulletId);
     output.Write(ContainerType);
     StartingPos.Write(output);
     output.Write(Angle);
 }
Exemple #6
0
 public override void Write(PacketOutput output)
 {
     output.Write((short)Offer.Length);
     foreach (var slot in Offer)
     {
         output.Write(slot);
     }
 }
Exemple #7
0
 public override void Write(PacketOutput output)
 {
     output.Write(TickId);
     output.Write(Time);
     NewPosition.Write(output);
     output.Write((short)Records.Count);
     foreach (var record in Records)
     {
         record.Write(output);
     }
 }
 public override void Write(PacketOutput output)
 {
     output.Write((short)ClientOffer.Length);
     foreach (bool slot in ClientOffer)
     {
         output.Write(slot);
     }
     output.Write((short)PartnerOffer.Length);
     foreach (bool slot in PartnerOffer)
     {
         output.Write(slot);
     }
 }
        public void Read_Packet_With_Complex_Content()
        {
            PacketOutput output = _packetReader.Read("inv 1 0.5.4.1.0 1.2.9.7.0");

            Check.That(output.Header).Is("inv");
            Check.That(output.Content).IsNotNullOrEmpty();

            string[] contentSplit = output.Content.Split(' ');

            Check.That(contentSplit).CountIs(3);
            Check.That(contentSplit).HasElementAt(0).WhichIs("1");
            Check.That(contentSplit).HasElementAt(1).WhichIs("0.5.4.1.0");
            Check.That(contentSplit).HasElementAt(2).WhichIs("1.2.9.7.0");
        }
        public void Read_Packet_With_Content()
        {
            PacketOutput output = _packetReader.Read("lev 1 5000 2 10000");

            Check.That(output.Header).Is("lev");
            Check.That(output.Content).IsNotNullOrEmpty();

            string[] contentSplit = output.Content.Split(' ');

            Check.That(contentSplit).CountIs(4);
            Check.That(contentSplit).HasElementAt(0).Which.Is("1");
            Check.That(contentSplit).HasElementAt(1).Which.Is("5000");
            Check.That(contentSplit).HasElementAt(2).Which.Is("2");
            Check.That(contentSplit).HasElementAt(3).Which.Is("10000");
        }
        public IPacket Deserialize(string packet)
        {
            PacketOutput output     = _packetReader.Read(packet);
            CachedType   cachedType = _reflectionCache.GetCachedType(output.Header);

            if (string.IsNullOrEmpty(output.Header))
            {
                throw new InvalidOperationException("Failed to deserialize packet");
            }

            char firstChar = output.Header[0];

            if (firstChar == '$' || firstChar == '%')
            {
                string   name = output.Header.Remove(0);
                string[] args = output.Content.Split(' ');

                _logger.Debug($"[DESERIALIZER] Deserialized Command packet [Header: {firstChar} / Name {name}]");
                return(new CommandPacket
                {
                    Header = $"{firstChar}",
                    Content = output.Content,
                    Name = name,
                    Arguments = args
                });
            }

            if (cachedType == null)
            {
                _logger.Debug($"[DESERIALIZER] No type found in cache for header {output.Header}");
                return(new UnknownPacket
                {
                    Header = output.Header,
                    Content = packet
                });
            }

            var deserialized = (IPacket)_conversionFactory.ToObject(output.Content, cachedType.PacketType);

            deserialized.Header  = output.Header;
            deserialized.Content = output.Content;

            _logger.Debug($"[DESERIALIZER] {output.Header} successfully deserialized to {deserialized.GetType()}");
            return(deserialized);
        }
Exemple #12
0
        public override void Write(PacketOutput output)
        {
            output.WriteUTF(BuildVersion);
            output.Write(GameId);
            output.WriteUTF(Guid);
            Random random = new Random();

            output.Write(random.Next(1000000000));
            output.WriteUTF(Password);
            output.Write(random.Next(1000000000));
            output.WriteUTF(Secret);
            output.Write(KeyTime);
            output.Write((short)Key.Length);
            output.Write(Key);
            output.WriteUTF32(MapJSON);
            output.WriteUTF(EntryTag);
            output.WriteUTF(GameNet);
            output.WriteUTF(GameNetUserId);
            output.WriteUTF(PlayPlatform);
            output.WriteUTF(PlatformToken);
            output.WriteUTF(UserToken);
        }
Exemple #13
0
 public override void Write(PacketOutput output)
 {
 }
Exemple #14
0
 public override void Write(PacketOutput output)
 {
     output.Write(Serial);
     output.Write(Time);
 }
Exemple #15
0
 public override void Write(PacketOutput output)
 {
     output.Write(CommandType);
     output.Write(InstanceId);
 }
 public override void Write(PacketOutput output)
 {
     output.WriteUTF(Name);
     output.Write(GuildRank);
 }
Exemple #17
0
 public override void Write(PacketOutput output)
 {
     SlotObject.Write(output);
 }
Exemple #18
0
 public override void Write(PacketOutput output)
 {
     output.WriteUTF(Text);
 }
Exemple #19
0
 public void Write(PacketOutput output)
 {
     output.Write(Time);
     output.Write(X);
     output.Write(Y);
 }
Exemple #20
0
 public override void Write(PacketOutput output)
 {
     output.Write(ConditionEffect);
     output.Write(ConditionDuration);
 }
Exemple #21
0
 public override void Write(PacketOutput output)
 {
     output.Write(ObjectId);
     output.Write(Quantity);
 }
Exemple #22
0
 public override void Write(PacketOutput output)
 {
     output.WriteUTF(AccountId);
     output.WriteUTF(Token);
 }
Exemple #23
0
 public override void Write(PacketOutput output)
 {
     output.Write(CharId);
     output.Write(IsFromArena);
 }
 public abstract void Write(PacketOutput output);
Exemple #25
0
 public override void Write(PacketOutput output)
 {
     output.Write(PetId);
     output.Write(SkinType);
     output.Write(Currency);
 }
Exemple #26
0
 public void Write(PacketOutput output)
 {
     output.Write(ObjectId);
     output.Write(SlotId);
     output.Write(ObjectType);
 }
Exemple #27
0
 public override void Write(PacketOutput output)
 {
     output.Write(ClassType);
     output.Write(SkinType);
 }
 public override void Write(PacketOutput output)
 {
     output.Write(AccountListId);
     output.Write(Add);
     output.Write(ObjectId);
 }
 public override void Write(PacketOutput output)
 {
     output.Write(ItemType);
 }