Beispiel #1
0
        private void Login(Socket socket, PacketReader packet)
        {
            var credentials = PacketMapper.Map <LoginCredentials>(packet);

            if (credentials.Username.Length < 4 ||
                credentials.Username.Length > 14 ||
                credentials.Password.Length < 4 ||
                credentials.Password.Length > 14)
            {
                SendInvalidUsernameOrPassword(socket);
                return;
            }

            if (credentials.ClientVersion < 1102)
            {
                SendInvalidClientVersion(socket);
                return;
            }

            if (credentials.ItemDataFileLength.Length < 2 || credentials.ItemDataFileLength.Length > 15)
            {
                SendInvalidDataFile(socket);
                return;
            }

            try
            {
                var user = DataRepository.GetUser(credentials.Username, credentials.Password);
            }
            catch (UserNotFoundException)
            {
                SendInvalidUsernameOrPassword(socket);
            }
        }
Beispiel #2
0
        public void Enqueue(object obj)
        {
            if (TransmissionClosed)
            {
                return;
            }

            PacketWriter writer = null;

            if (typeof(PacketWriter).IsAssignableFrom(obj.GetType()))
            {
                writer = obj as PacketWriter;
            }
            else
            {
                writer = PacketMapper.Map <PacketWriter>(obj);
            }

            if (writer.LastTransmission)
            {
                TransmissionClosed = true;
            }

            lock (writeSyncRoot)
            {
                writeBuffer.AddRange(writer.Bytes);
            }
        }
Beispiel #3
0
 public PacketMappingProfile <TSource, TDestination> CreateMapping <TSource, TDestination>()
 {
     return(PacketMapper.CreateMapping <TSource, TDestination>());
 }