Exemplo n.º 1
0
 private void readLoginSuccesfullStuff(IncomingPacket encPacket)
 {
    this.Slots = encPacket.ReadInt32();
 }
Exemplo n.º 2
0
        void OnNewPacket(IncomingPacket encPacket)
        {
            short length = encPacket.ReadInt16();
            int version = encPacket.ReadInt32();
            string encryptedPacket = encPacket.ReadString();

            try
            {
                byte[] decryptedPacket = this.RSAService.DecryptString(encryptedPacket);
                IncomingPacket packet = new IncomingPacket(decryptedPacket);
                
                short messageLength = packet.ReadInt16();
                int messageID = packet.ReadInt32();

                string dateTime = packet.ReadString();
                DateTime sendTime = DateTime.Parse(dateTime);
                DateTime now = DateTime.UtcNow;
                if (Math.Abs((sendTime - now).TotalHours) > 2)
                {
                    GotoDemoMode();
                    return;
                }
                switch (messageID) { 
                    case 1:
                        readLoginSuccesfullStuff(encPacket);
                        break;
                    case 2:
                        GotoDemoMode();
                        break;
                }
            }
            catch (EndOfStreamException)
            {
                //TODO fix malformed packet exception and kill connections maybe? or goto demo mode
            }
            catch
            {
                this.ClientModule.disconnect();
            }
        }
Exemplo n.º 3
0
 private void HandlePacket(IncomingPacket message)
 { 
     if (this.packetArrival != null)
         this.packetArrival.Invoke(message);
 }