Exemplo n.º 1
0
        private void Run()
        {
            // We should never exit from this loop
            try
            {
                while (true)
                {
                    Thread.Sleep(1);

                    if (Environment.HasShutdownStarted)
                    {
                        // This will shutdown all the nodes
                        // throw new ProxyClosingException();
                        return;
                    }

                    if (this.Queue.Count == 0)
                    {
                        continue;
                    }

                    // Thread safe stuff
                    lock (this.Queue)
                    {
                        LoginQueueEntry now = this.Queue.Dequeue();

                        if (now == null)
                        {
                            continue;
                        }

                        HandleLogin(now);
                    }
                }
            }
            catch (ThreadAbortException)
            {
                // throw new ProxyClosingException();
                return;
            }

            /*catch (ProxyClosingException)
             * {
             *  throw new ProxyClosingException();
             * }*/
            catch (Exception ex)
            {
                Log.Error("Unhandled exception... " + ex.Message);
                Log.Error("Stack trace: " + ex.StackTrace);
            }

            Log.Error("LoginQueue is closing... Bye Bye!");
        }
Exemplo n.º 2
0
        public void Enqueue(ClientConnection connection, AuthenticationReq request)
        {
            // Just to be thread safe
            lock (this.Queue)
            {
                LoginQueueEntry entry = new LoginQueueEntry();

                entry.Connection = connection;
                entry.Request    = request;

                this.Queue.Enqueue(entry);
            }
        }
Exemplo n.º 3
0
        public void HandleLogin(LoginQueueEntry entry)
        {
            Log.Debug("Processing login for " + entry.Request.user_name);
            LoginStatus status = LoginStatus.Waiting;

            long accountID = 0;
            bool banned    = false;
            long role      = 0;

            // First check if the account exists
            if (this.mAccountDB.AccountExists(entry.Request.user_name) == false)
            {
                if (this.mConfiguration.Autoaccount == true)
                {
                    Log.Info($"Auto account enabled, creating account for user {entry.Request.user_name}");

                    // Create the account
                    this.mAccountDB.CreateAccount(entry.Request.user_name, entry.Request.user_password, (ulong)this.mConfiguration.Role);
                }
            }

            if ((this.mAccountDB.LoginPlayer(entry.Request.user_name, entry.Request.user_password, ref accountID, ref banned, ref role) == false) || (banned == true))
            {
                Log.Trace(": Rejected by database");

                status = LoginStatus.Failed;
            }
            else
            {
                Log.Trace(": success");

                status = LoginStatus.Sucess;
            }

            entry.Connection.SendLoginNotification(status, accountID, role);
        }