Exemple #1
0
        public string Login(string username)
        {
            //TODO make mqDriver into mqDriver for all servers

            IServerDestributer serverDist = new LocalServerDestributer();

            string    reqServer = serverDist.RequestServer();
            IMQDriver mqDriver  = serverDist.GetMQDriver(reqServer);

            LockUsername(username, mqDriver);

            //TODO make mqDriver into single server mqDriver
            string command = Config.GenerateCommand(Config.CMD.LOGIN_REQUEST, Thread.CurrentThread.ManagedThreadId, username, reqServer, GetClientIP());

            bool serverResponded = false;

            mqDriver.OnResponseRecieved += (cmd) =>
            {
                string   comType  = GetCmdType(Config.CMD.LOGIN_RESPONSE);
                string[] comParts = cmd.Split(':');

                if (comParts[0].Equals(comType))
                {
                    if (comParts[1].Equals(Thread.CurrentThread.ManagedThreadId))
                    {
                        if (comParts[2].ToUpper().Equals("OK"))
                        {
                            serverResponded = true;
                        }
                        else
                        {
                            throw new FaultException(cmd);
                        }
                    }
                }
            };

            Wait(ref serverResponded);

            ReleaseUsername(username, mqDriver);

            mqDriver.ListenerOpen = false;

            return(GetServerDestributor().RequestServer());
        }
Exemple #2
0
        public string Login(string username)
        {
            //TODO make mqDriver into mqDriver for all servers

            IServerDestributer serverDist = new LocalServerDestributer();

            string reqServer = serverDist.RequestServer();
            IMQDriver mqDriver = serverDist.GetMQDriver(reqServer);

            LockUsername(username, mqDriver);

            //TODO make mqDriver into single server mqDriver
            string command = Config.GenerateCommand(Config.CMD.LOGIN_REQUEST, Thread.CurrentThread.ManagedThreadId, username, reqServer, GetClientIP());

            bool serverResponded = false;

            mqDriver.OnResponseRecieved += (cmd) =>
            {
                string comType = GetCmdType(Config.CMD.LOGIN_RESPONSE);
                string[] comParts = cmd.Split(':');

                if (comParts[0].Equals(comType))
                {
                    if (comParts[1].Equals(Thread.CurrentThread.ManagedThreadId))
                    {
                        if (comParts[2].ToUpper().Equals("OK"))
                        {
                            serverResponded = true;
                        }
                        else
                        {
                            throw new FaultException(cmd);
                        }
                    }
                }
            };

            Wait(ref serverResponded);

            ReleaseUsername(username, mqDriver);

            mqDriver.ListenerOpen = false;

            return GetServerDestributor().RequestServer();
        }