Пример #1
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     Sucess    = iterator.ReadBoolean();
     ErrorCode = iterator.ReadUInt8();
     Message   = iterator.ReadString();
     Channel   = iterator.ReadUInt32();
 }
Пример #2
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     AppName       = iterator.ReadString();
     AppVersion    = iterator.ReadString();
     NetworkHash   = iterator.ReadUInt32();
     HasEncryption = iterator.ReadBoolean();
 }
Пример #3
0
        public static ToffeeInternalPacketReadResult Read(ToffeeParticipant receiver, byte[] packet)
        {
            try
            {
                // Iterate through the packet
                ToffeePacketIterator iterator = new ToffeePacketIterator(receiver, packet);

                // Get the header, data, and CRC
                InternalPacketHeader header = iterator.ReadStruct <InternalPacketHeader>();
                byte[] packetData           = iterator.ReadBytes(header.Length);
                uint   sentCrc = iterator.ReadUInt32();

                // Is the CRC correct?
                uint calculatedCrc = CRC.CalculateCRC32(packetData);
                if (sentCrc != calculatedCrc)
                {
                    return(new ToffeeInternalPacketReadResult(false, new InternalPacketHeader(), null));
                }

                // Is this packet compressed?
                if (header.Compressed)
                {
                    packetData = CompressionService.Decompress(packetData);
                }

                // Return the read result
                return(new ToffeeInternalPacketReadResult(true, header, packetData));
            }
            catch
            {
                return(new ToffeeInternalPacketReadResult(false, new InternalPacketHeader(), null));
            }
        }
Пример #4
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     Success          = iterator.ReadBoolean();
     ErrorCode        = iterator.ReadUInt8();
     Message          = iterator.ReadString();
     HeartbeatTime    = iterator.ReadUInt32();
     ForcedEncryption = iterator.ReadBoolean();
 }
Пример #5
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     Sender     = iterator.ReadUInt32();
     Receivers  = (uint[])iterator.ReadArray();
     OpCode     = iterator.ReadUInt16();
     Compressed = iterator.ReadBoolean();
     Length     = iterator.ReadUInt16();
 }
Пример #6
0
        public static ToffeeClientPacketReadResult Read(ToffeeParticipant receiver, byte[] packet)
        {
            try
            {
                // Is this packet encrypted?
                bool encrypted = packet[0] == 0x01;
                if (encrypted)
                {
                    // Is this client setup to use encryption?
                    if (receiver.UseEncryption)
                    {
                        packet = receiver.Encryption.Decrypt(packet.Skip(1).ToArray());
                    }
                }
                else
                {
                    packet = packet.Skip(1).ToArray();
                }

                // Iterate through the packet
                ToffeePacketIterator iterator = new ToffeePacketIterator(receiver, packet);

                // Get the header, data, and CRC
                ClientPacketHeader header     = iterator.ReadStruct <ClientPacketHeader>();
                byte[]             packetData = iterator.ReadBytes(header.Length);
                uint sentCrc = iterator.ReadUInt32();

                // Is the CRC correct?
                uint calculatedCrc = CRC.CalculateCRC32(packetData);
                if (sentCrc != calculatedCrc)
                {
                    return(new ToffeeClientPacketReadResult(false, encrypted, new ClientPacketHeader(), null));
                }

                // Is this packet compressed?
                if (header.Compressed)
                {
                    packetData = CompressionService.Decompress(packetData);
                }

                // Return the read result
                return(new ToffeeClientPacketReadResult(true, encrypted, header, packetData));
            }
            catch
            {
                return(new ToffeeClientPacketReadResult(false, false, new ClientPacketHeader(), null));
            }
        }
Пример #7
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     DistributedId = iterator.ReadUInt32();
     Destroyed     = iterator.ReadBoolean();
 }
Пример #8
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     DistributedId = iterator.ReadUInt32();
     ServiceType   = iterator.ReadUInt32();
     CurrentState  = (FieldUpdate[])iterator.ReadArray();
 }
Пример #9
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     DistributedId = iterator.ReadUInt32();
     ErrorCode     = iterator.ReadUInt8();
     Message       = iterator.ReadString();
 }
Пример #10
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     DistributedId = iterator.ReadUInt32();
     Updates       = (FieldUpdate[])iterator.ReadArray();
 }
Пример #11
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     FieldId    = iterator.ReadUInt32();
     Parameters = (byte[])iterator.ReadArray();
 }
Пример #12
0
 public void ReadFrom(ToffeePacketIterator iterator)
 {
     Name    = iterator.ReadString();
     Role    = iterator.ReadString();
     Channel = iterator.ReadUInt32();
 }