Пример #1
0
        public override void OnDataRecieved(ClientInfo info)
        {
            if (!info.Entered)
            {
                if ((DataBaseCommand)info.Buffer[1] == DataBaseCommand.CheckLogin)
                {
                    int    BufferLength = info.Buffer[0];
                    byte[] ar           = new byte[BufferLength - 2];
                    Array.Copy(info.Buffer, 2, ar, 0, BufferLength - 2);

                    /*SymmetricCryption LoginCrypt = new SymmetricCryption(NetKey, NetVector);
                     * string LogPas = LoginCrypt.Decrypt(ar);*/
                    string LogPas = Encoding.UTF8.GetString(ar);
                    foreach (string Line in LoginPassword)
                    {
                        if (Line == LogPas)
                        {
                            info.Entered = true;
                            break;
                        }
                    }
                    if (!info.Entered)
                    {
                        info.Socket.Shutdown(System.Net.Sockets.SocketShutdown.Both);
                    }
                }
            }
            else
            {
                BooksDatabase.Update(info.Buffer);

                // check if the stream is empty
                if (info.Socket.Available == 0)
                {
                    OnRecieveCompleted();
                }
            }
            base.OnDataRecieved(info);
        }
Пример #2
0
 public override void OnDataRecieved(byte[] data)
 {
     BooksDatabase.Update(data);
     base.OnDataRecieved(data);
 }