Esempio n. 1
0
 public override void OnRegister()
 {
     base.OnRegister();
     this.loginProxy = Facade.RetrieveProxy(Proxys.LOGIN_PROXY) as LoginProxy;
     if (Application.platform == RuntimePlatform.WindowsPlayer)
     {
         string[] commandLineArgs = Environment.GetCommandLineArgs();
         //Debug.Log(commandLineArgs);
         for (int i = 0; i < commandLineArgs.Length; i++)
         {
             Debug.Log(commandLineArgs[i]);
         }
         if (commandLineArgs.Length > 1)
         {
             GlobalData.LoginServer = commandLineArgs[1];
             GlobalData.LoginPort   = int.Parse(commandLineArgs[2]);
             GlobalData.UserName    = commandLineArgs[3];
             GlobalData.UserMac     = commandLineArgs[4];
             loginProxy.autoLogin   = true;
             CheckUserAgreement();
             return;
         }
     }
     if (loginProxy.autoLogin)
     {
         CheckUserAgreement();
     }
     else
     {
         loginView = (LoginView)UIManager.Instance.ShowUI(UIViewID.LOGIN_VIEW);
         loginView.ButtonAddListening(loginView.loginBtn, CheckUserAgreement);
         AudioSystem.Instance.PlayBgm("Voices/Bgm/91bgmusic");
     }
     //GameMgr.Instance.StartCoroutine(DownloadAssetBundle());
 }
Esempio n. 2
0
        static void Setup()
        {
            string username  = "******";
            string password  = "******";
            string storename = "store";


            LoginProxy service = new LoginProxy();

            try
            {
                service.Register(username, password, DateTime.Now, "shit");
                Console.WriteLine("Registering: " + username + ":" + password);

                Member member  = service.loginEx(username, password);
                int    storeId = service.AddStore(storename);
                Console.WriteLine("Opening store: " + storename + ":" + storeId);

                int product1Id = service.AddProductToStore(storeId, "product1", "testProduct", 10.0, "test");
                service.AddProductToStock(storeId, product1Id, 10);
                Console.WriteLine("Adding product: " + "product1" + ":" + product1Id);

                int product2Id = service.AddProductToStore(storeId, "product2", "testProduct", 5.0, "test");
                service.AddProductToStock(storeId, product1Id, 5);
                Console.WriteLine("Adding product: " + "product2" + ":" + product2Id);

                service.logout();
                Console.WriteLine("Setup Done");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
        private void Execute(object parameter)
        {
            Object[] parameters = parameter as Object[];

            String username = parameters[0] as String;
            String password = parameters[1] as String;

            CurrentUserControl = parameters[2] as UserControl;

            try
            {
                Account account = LoginProxy.ConnectToLoginService().Login(username, password);
                if (account == null)
                {
                    MessageBox.Show("Username or password is incorrect.");
                }
                else
                {
                    MessageBox.Show("Successfull login!");

                    CurrentUserControl.Content = new HomeViewModel(account);
                    CurrentUserControl.VerticalContentAlignment   = VerticalAlignment.Top;
                    CurrentUserControl.HorizontalContentAlignment = HorizontalAlignment.Left;
                    CurrentUserControl.Width  = 1500;
                    CurrentUserControl.Height = 1000;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($"Problem with connection. Message: {e.Message}");
            }
        }
Esempio n. 4
0
    public override void Execute(INotification notification)
    {
        LoginVO    lv   = notification.Body as LoginVO;
        LoginProxy temp = Facade.RetrieveProxy("LoginProxy") as LoginProxy;

        temp.Login(lv);
    }
Esempio n. 5
0
    public override void OnRegister()
    {
        base.OnRegister();
        this.loginProxy = Facade.RetrieveProxy(Proxys.LOGIN_PROXY) as LoginProxy;

        if (Application.platform == RuntimePlatform.WindowsPlayer)
        {
            string[] commandLineArgs = Environment.GetCommandLineArgs();
            Debug.Log(commandLineArgs);
            if (commandLineArgs.Length > 1)
            {
                GlobalData.LoginServer = commandLineArgs[1];
                GlobalData.LoginPort   = int.Parse(commandLineArgs[2]);
                GlobalData.UserName    = commandLineArgs[3];
                GlobalData.UserMac     = commandLineArgs[4];
                LoginProxy.autoLogin   = true;
                CheckUserAgreement();
                return;
            }
        }

        if (LoginProxy.autoLogin)
        {
            CheckUserAgreement();
        }
        else
        {
            this.View.LoginView = (LoginView)UIManager.Instance.ShowUI(UIViewID.LOGIN_VIEW);
            this.View.LoginView.ButtonAddListening(this.View.LoginView.LoginBtn, CheckUserAgreement);
            AudioSystem.Instance.PlayBgm(Resources.Load <AudioClip>("Voices/Bgm/HallBgm"));
        }
    }
Esempio n. 6
0
        public override void Execute(INotification notification)
        {
            base.Execute(notification);
            LoginProxy loginProxy = Facade.RetrieveProxy(nameof(LoginProxy)) as LoginProxy;

            loginProxy.RequestLogout();
        }
Esempio n. 7
0
        public IHttpActionResult CheckCredentials(JObject CredjObject)
        {
            string  UserName = ""; string Password = "";
            dynamic credsInput = CredjObject;

            if (CredjObject != null)
            {
                UserName = credsInput.UserName;
                Password = credsInput.Password;
            }
            bool    isValidCredential = false;
            UserDTO userDetails       = new UserDTO();

            try
            {
                string HashPassword = CipherService.GetCipherCreds(Password);
                userDetails = LoginProxy.GetUserDetailsByUserNameAndHashPassword(UserName, HashPassword);
                if (userDetails != null)
                {
                    isValidCredential = true;
                }
            }
            catch (CredentialDBException exceptions)
            {
                isValidCredential = false;
            }
            catch (Exception e)
            {
                isValidCredential = false;
            }

            return(Ok(isValidCredential));
        }
Esempio n. 8
0
        public async void AdminToken([FromBody] LoginProxy loginData)
        {
            try
            {
                var user       = GetUser(loginData, UserRoles.Admin);
                var encodedJwt = _userService.CreateToken(user);
                var response   = new
                {
                    access_token = encodedJwt,
                    userId       = user.Id
                };

                Response.ContentType = "application/json";
                await Response.WriteAsync(JsonConvert.SerializeObject(response, new JsonSerializerSettings {
                    Formatting = Formatting.Indented
                }));
            }
            catch (Exception e)
            {
                Response.StatusCode = 400;
                var errorRespone = new
                {
                    Status = false,
                    Error  = e.Message
                };
                await Response.WriteAsync(JsonConvert.SerializeObject(errorRespone, new JsonSerializerSettings {
                    Formatting = Formatting.Indented
                }));

                return;
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="LoginViewMediator"/> class.
        /// </summary>
        /// <param name="viewComponent">The view component.</param>
        public LoginViewMediator(Object viewComponent)
            : base(NAME, viewComponent)
        {
            loginProxy = Facade.RetrieveProxy(LoginProxy.NAME) as LoginProxy;

            LoginView.DoLogin += LoginView_DoLogin;
        }
Esempio n. 10
0
 public override void OnRegister()
 {
     base.OnRegister();
     hallProxy             = ApplicationFacade.Instance.RetrieveProxy(Proxys.HALL_PROXY) as HallProxy;
     loginProxy            = ApplicationFacade.Instance.RetrieveProxy(Proxys.LOGIN_PROXY) as LoginProxy;
     View.HallView         = (HallView)UIManager.Instance.ShowUI(UIViewID.HALL_VIEW);
     View.TopView          = (TopMenuView)UIManager.Instance.ShowUI(UIViewID.TOPMENU_VIEW);
     View.HallRoomListView = (HallRoomListView)UIManager.Instance.ShowUI(UIViewID.HALLROOMLIST_VIEW);
     View.MiddleView       = (MiddleMenuView)UIManager.Instance.ShowUI(UIViewID.MIDDLEMENU_VIEW);
     View.BottomView       = (BottomMenuView)UIManager.Instance.ShowUI(UIViewID.BOTTOMMENU_VIEW);
     TopMenuAddEvent();
     MiddleMenuAddEvent();
     BottomMenuAddEvent();
     RefreshUserInfo();
     AudioSystem.Instance.PlayBgm("Voices/Bgm/91bgmusic");
     if (GlobalData.LoginServer != "127.0.0.1" && NetMgr.Instance.ConnentionDic.ContainsKey(SocketType.BATTLE))
     {
         NetMgr.Instance.StopTcpConnection(SocketType.BATTLE);
         if (!NetMgr.Instance.ConnentionDic.ContainsKey(SocketType.HALL))
         {
             NetMgr.Instance.CreateConnect(SocketType.HALL, loginProxy.hallServerIP, loginProxy.hallServerPort);
         }
     }
     StartUp();
 }
Esempio n. 11
0
 public ChangePasswordViewModel(string username)
 {
     _username           = username;
     SavePasswordCommand = new DelegateCommand(async x => await SavePasswordAsync(x));
     _validator          = new UserCredentialsValidator();
     _loginService       = new LoginProxy();
     _profileProxy       = new UserProfileProxy();
 }
Esempio n. 12
0
 /// <summary>
 /// CfgPlayerProxy
 /// </summary>
 /// <returns></returns>
 private LoginProxy GetLoginProxy()
 {
     if (m_LoginProxy == null)
     {
         m_LoginProxy = (LoginProxy)Facade.RetrieveProxy(ProxyName.LoginProxy);
     }
     return(m_LoginProxy);
 }
Esempio n. 13
0
        //Command业务逻辑协调Model与View的逻辑
        public override void Execute(INotification notification)
        {
            base.Execute(notification);
            LoginProxy loginProxy = Facade.RetrieveProxy(nameof(LoginProxy)) as LoginProxy;
            var        tuple      = notification.Body as Tuple <string, string>;

            loginProxy.RequestLogin(tuple.Item1, tuple.Item2);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ApplicationMediator"/> class.
        /// </summary>
        /// <param name="viewComponent">The view component.</param>
        public ApplicationMediator(Object viewComponent)
            : base(NAME, viewComponent)
        {
            Facade.RegisterMediator(new LoginViewMediator(Application.LoginView));
            Facade.RegisterMediator(new LoggedInViewMediator(Application.LoggedInView));

            appProxy   = Facade.RetrieveProxy(ApplicationProxy.NAME) as ApplicationProxy;
            loginProxy = Facade.RetrieveProxy(LoginProxy.NAME) as LoginProxy;
        }
Esempio n. 15
0
        protected override void ProcessDemo()
        {
            var logInProxy = new LoginProxy(new LoginService());

            for (int i = 0; i <= 3; i++)
            {
                logInProxy.LogIn();
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Fulfill the use-case initiated by the given <c>INotification</c>
        /// </summary>
        /// <param name="notification">The <c>INotification</c> to handle</param>
        /// <remarks>
        /// In the Command Pattern, an application use-case typically begins with some user action, which results in an <c>INotification</c> being broadcast, which is handled by business logic in the <c>execute</c> method of an <c>ICommand</c>
        /// </remarks>
        public override void Execute(INotification notification)
        {
            LoginDto   loginDto   = notification.Body as LoginDto;
            LoginProxy loginProxy = Facade.RetrieveProxy(LoginProxy.NAME) as LoginProxy;

            if (loginProxy != null)
            {
                loginProxy.DoLogin(loginDto);
            }
        }
Esempio n. 17
0
    public override void Execute(INotification notification)
    {
        Dictionary <string, string> dic = notification.Body as Dictionary <string, string>;

        string     userName   = dic["username"].ToString();
        string     password   = dic["password"].ToString();
        LoginProxy levelProxy = (LoginProxy)LoginFade.GetInstance().RetrieveProxy(LoginProxy.NAME);

        levelProxy.ToLogin(userName, password);
    }
 /// <summary>
 /// Inicjalizuje nową instancję klasy RegisterUserViewModel
 /// </summary>
 /// <param name="validator">Validator danych wprowadzanych przez użytkownika</param>
 /// <param name="regiser">Instancja odpowiadająca za zapisanie użytkownika do bazy danych</param>
 public RegisterUserViewModel(IUserCredentialsValidator validator)
 {
     if (validator == null)
     {
         throw new ArgumentNullException();
     }
     _validator      = validator;
     _service        = new LoginProxy();
     NextCommand     = new DelegateCommand(async x => await NextScreenAsync(x));
     RegisterCommand = new DelegateCommand(async x => await RegisterAsync());
     CurrentScreen   = CurrentScreen.Credentials;
 }
Esempio n. 19
0
        public ResponseData Excute(LoginInfo data)
        {
            int    userId;
            int    userType;
            string passportId;

            if (!string.IsNullOrEmpty(data.RetailUser) && !string.IsNullOrEmpty(data.RetailToken))
            {
                ILogin login = LoginProxy.GetLogin(data.RetailID, data);
                login.Password = DecodePassword(login.Password);
                var watch = RunTimeWatch.StartNew("Request login server");
                try
                {
                    if (login.CheckLogin())
                    {
                        watch.Check("GetResponse");
                        userId     = int.Parse(login.UserID);
                        passportId = login.PassportID;
                        userType   = login.UserType;
                    }
                    else
                    {
                        //DoLoginFail();
                        throw new HandlerException(StateCode.Error, StateDescription.PassworkError);
                    }
                }
                finally
                {
                    watch.Flush(true, 100);
                }
            }
            else
            {
                if (string.IsNullOrEmpty(data.Pwd) || data.Pwd.Length < 5)
                {
                    throw new HandlerException(StateCode.Error, StateDescription.PassworkLengthError);
                }
                data.Pwd = DecodePassword(data.Pwd);
                //快速登录
                RegType regType;
                userId = SnsManager.LoginByDevice(data.Pid, data.Pwd, data.DeviceID, out regType, data.IsCustom);
                if (userId <= 0)
                {
                    throw new HandlerException(StateCode.PassworkError, StateDescription.PassworkError);
                }
                passportId = data.Pid;
                userType   = (int)regType;
            }

            return(AuthorizeLogin(userId, passportId, userType));
        }
Esempio n. 20
0
    public override void Execute(INotification notification)
    {
        LoginProxy    _proxy    = (LoginProxy)this.Facade.RetrieveProxy(LoginProxy.NAME);
        LoginMediator _mediator = (LoginMediator)this.Facade.RetrieveMediator(LoginMediator.NAME);

        switch (notification.Name)
        {
        case LoginNotify.ShowRole:
        {
            _mediator.ShowRoleUI();
            break;
        }
        }
    }
Esempio n. 21
0
    public void Init()
    {
        Player = new PlayerProxy();
        Player.Init();

        Login = new LoginProxy();
        Login.Init();

        Room = new RoomProxy();
        Room.Init();

        Battle = new BattleProxy();
        Battle.Init();
    }
Esempio n. 22
0
    public override void Execute(INotification notification)
    {
        LoginProxy loginProxy = Facade.RetrieveProxy(LoginProxy.NAME) as LoginProxy;

        switch (notification.Name)
        {
        case NotiConst.LOGIN_REQUEST:
            loginProxy.SendLogin(notification.Body as TempLogRegDataVO);
            break;

        case NotiConst.REGISTER_REQUEST:
            loginProxy.SendRegister(notification.Body as TempLogRegDataVO);
            break;
        }
    }
    public override void Execute(INotification noti)
    {
        Debug.Log("LoginCommand->Execute,处理'E_LOGIN'消息");

        switch (noti.Name)
        {
        case NotiConst.E_LOGIN:
            LoginProxy proxy = (LoginProxy)Facade.RetrieveProxy(LoginProxy.NAME);
            UserOV     obj   = (UserOV)noti.Body;
            proxy.SendLoginMsg(obj);
            break;

        default:
            break;
        }
    }
Esempio n. 24
0
        /// <summary>
        /// 确定重连
        /// </summary>
        void ConfirmReConnect()
        {
            isShowTimeOut = false;
            //foreach (KeyValuePair<SocketType, NSocket> keyValuePair in ConnentionDic)
            //{
            //    keyValuePair.Value.ReConnecting();
            //}
            if (SceneManager.GetActiveScene().name != SceneName.LOGIN)
            {
                LoginProxy loginProxy = ApplicationFacade.Instance.RetrieveProxy(Proxys.LOGIN_PROXY) as LoginProxy;
                loginProxy.autoLogin = true;
            }
            StopAllTcpConnection();
            var loadInfo = new LoadSceneInfo(ESceneID.SCENE_LOGIN, LoadSceneType.SYNC, LoadSceneMode.Single);

            ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
        }
Esempio n. 25
0
        private void myInit()
        {
            DataAccessDriver.UseStub = true;
            addTestStoreOwner1ToSystem();
            //set store and owner
            ownerObserver  = new testObserverAcceptence();
            storeOwnerUser = new LoginProxy();
            string loginAns   = storeOwnerUser.login(getStoreOwner1(), password);
            bool   loginError = loginAns == LoginProxy.successMsg;

            Assert.IsTrue(loginError, "can't log in");
            //set admin
            adminObserver = new testObserverAcceptence();
            adminUserL    = new LoginProxy();
            string loginAnsAdmin = adminUserL.login(adminUser, adminPass);
            bool   loginAdmin    = loginAnsAdmin == LoginProxy.successMsg;

            Assert.IsTrue(loginAdmin, "can't log in Admin");
        }
Esempio n. 26
0
 public UserConnectionInfo(bool isSecureConnection, uint id, IWebSocketMessageSender msgSender)
 {
     this.isSecureConnection = isSecureConnection;
     this.id         = id;
     user            = new LoginProxy();
     this.msgSender  = msgSender;
     messageHandlers = new Dictionary <string, Action <JObject, string> >()
     {
         { "signin", signInHandler },
         { "signout", signOutHandler },
         { "register", registerHandler },
         { "addstore", addStoreHandler },
         { "getstore", getStoreHandler },
         { "getproduct", getProductHandler },
         { "addproducttostore", addProductToStore },
         { "addproducttostock", addProductToStock },
         { "getallstores", getAllStoresHandler },
         { "addproducttobasket", addProductToBaksetHandler },
         { "getshoppingbasket", getShoppingBasketHandler },
         { "removeproductfromstore", removeProductFromStoreHandler },
         { "changeproductinfo", changeProductInfoHandler },   /// didn't test yet
         { "closestore", closeStoreHandler },
         { "searchproducts", searchProductsHandler },
         { "getallmembers", getAllMembersHandler },
         { "removeuser", removeUserHandler },
         { "getallmanagers", getAllManagersHandler },
         { "approveowenrshiprequest", approveOwnershipResponseHandler },
         { "disapproveowenrshiprequest", disapproveOwnershipResponseHandler },
         { "buyshoppingbasket", buyShoppingBasketHandler },
         { "getallproductsforstore", getAllProductsForStore },
         { "removestoremanager", removeStoreManagerHandler },
         { "addstoremanager", addStoreManagerHandler },
         { "ismanagestore", IsManageStoreHandler },
         { "addstoreowner", addStoreOwnerHandler },
         { "isadmin", isAdminHandler },
         { "editamount", editAmountHandler },
         { "addpurchsingpolicy", addPurchasingPolicyHandler },
         { "adddiscountpolicy", addDiscountPolicyHandler },
         { "getstorepolices", getAllPoliciesHandler }
     };
 }
Esempio n. 27
0
        private void closeStoreByAdminLiveNotification()
        {
            testObserverAcceptence managerObserver = null;
            LoginProxy             manager         = null;

            try
            {
                myInit();

                bool subscribe1 = storeOwnerUser.subscribeAsObserver(ownerObserver);
                Assert.IsTrue(subscribe1, "can't subscribe");
                //add manager
                addTestStoreManager1ToSystem();
                manager = new LoginProxy();
                //sign in and subscribe observer
                bool login = manager.login(getStoreManager1(), password) == LoginProxy.successMsg;
                Assert.IsTrue(login, "can't login manager");
                managerObserver = new testObserverAcceptence();
                bool subscribe2 = storeOwnerUser.subscribeAsObserver(managerObserver);
                Assert.IsTrue(subscribe2, "can't subscribe manger as observer");
                //close store as admin
                LoginProxy admin      = new LoginProxy();
                bool       adminLogin = admin.login("Admin", "Admin") == LoginProxy.successMsg;
                Assert.IsTrue(adminLogin, "can't login Admin");
                admin.closeStore(storeId); //TODO fix fails because admin can't close sotres

                bool hasMessages1 = ownerObserver.msg.Count == 1;
                Assert.IsTrue(hasMessages1, "owner didn't recieve message on close");

                bool hasMessages2 = managerObserver.msg.Count == 1;
                Assert.IsTrue(hasMessages2, "admin didn't recieve message on close");
            }
            finally
            {
                if (managerObserver != null & manager != null)
                {
                    manager.unSubscribeAsObserver(managerObserver);
                }
                myCleanUp();
            }
        }
Esempio n. 28
0
        private User GetUser(LoginProxy loginData, String role)
        {
            var user = _context.Users.FirstOrDefault(x => x.Login == loginData.Login || x.Email == loginData.Login);

            if (user == null)
            {
                throw new Exception("Неверный логин или пароль!");
            }

            bool validPassword = BCrypt.Net.BCrypt.Verify(loginData.Password, user.Password);

            if (!validPassword)
            {
                throw new Exception("Неверный логин или пароль!");
            }

            if (user.Role != role)
            {
                throw new Exception("Неверная роль!");
            }

            return(user);
        }
Esempio n. 29
0
    public override void OnShow(object msg)
    {
        base.OnShow(msg);
        m_IndexFocus = 0;
        m_BtnLogin.onClick.AddListener(OnClickBtnLogin);
        m_BtnServerList.onClick.AddListener(OnClickBtnServerList);
        m_BtnLogin.enabled = m_NameInput.text != string.Empty ? true : false;
        m_NameInput.onValueChanged.AddListener((str) =>
        {
            m_BtnLogin.enabled = m_NameInput.text != string.Empty ? true : false;
        });
        m_LoginProxy = Facade.RetrieveProxy(ProxyName.LoginProxy) as LoginProxy;
        if (SettingINI.Setting.TryGetValue(SettingINI.Setting.CombineKey(SettingINI.Constants.GROUP_LOGIN
                                                                         , SettingINI.Constants.KEY_DEFAULT_LAST_LOGIN_SERVER), out string defaultLastLoginServer))
        {
            m_LoginProxy.SetLastLoginServer(defaultLastLoginServer);
        }
        m_LoginProxy.LoadServerList();

        if (SettingINI.Setting.GetBoolValue(SettingINI.Setting.CombineKey(SettingINI.Constants.GROUP_LOGIN
                                                                          , SettingINI.Constants.KEY_DISPLAY_AGREEMENT_PANEL)
                                            , true) &&
            PlayerPrefs.GetString(GameConstant.FIRSTLOGIN) != "1")
        {
            GetGameObject().SetActive(false);
            UIManager.Instance.OpenPanel(UIPanel.AgreementPanel);
        }

        if (SettingINI.Setting.GetBoolValue(SettingINI.Setting.CombineKey(SettingINI.Constants.GROUP_LOGIN
                                                                          , SettingINI.Constants.KEY_AUTO_LOGIN)
                                            , false))
        {
            CoroutineHelper.GetInstance().StartCoroutine(AutoLogin());
        }

        m_VersionText.text = "The version number " + Application.version;
    }
Esempio n. 30
0
    public override void OnRegister()
    {
        base.OnRegister();
        hallProxy       = ApplicationFacade.Instance.RetrieveProxy(Proxys.HALL_PROXY) as HallProxy;
        loginProxy      = ApplicationFacade.Instance.RetrieveProxy(Proxys.LOGIN_PROXY) as LoginProxy;
        View.HallView   = (HallView)UIManager.Instance.ShowUI(UIViewID.HALL_VIEW);
        View.TopView    = (TopMenuView)UIManager.Instance.ShowUI(UIViewID.TOPMENU_VIEW);
        View.MiddleView = (MiddleMenuView)UIManager.Instance.ShowUI(UIViewID.MIDDLEMENU_VIEW);
        TopMenuAddEvent();
        MiddleMenuAddEvent();
        View.TopView.ViewRoot.SetActive(false);
        View.MiddleView.ViewRoot.SetActive(false);
        AudioSystem.Instance.PlayBgm(Resources.Load <AudioClip>("Voices/Bgm/HallBgm"));
        if (GlobalData.LoginServer != "127.0.0.1")
        {
            NetMgr.Instance.StopTcpConnection(SocketType.BATTLE);
            if (!NetMgr.Instance.ConnentionDic.ContainsKey(SocketType.HALL))
            {
                NetMgr.Instance.CreateConnect(SocketType.HALL, loginProxy.hallServerIP, loginProxy.hallServerPort);
            }
        }
        var startUpParam = AndroidSdkInterface.GetStartParam();

        if (startUpParam != null)
        {
            Dictionary <string, string> paramDic = StringUtil.ParseParam(startUpParam);
            if (paramDic.ContainsKey(StartUpParam.TYPE) && paramDic[StartUpParam.TYPE] == StartUpType.JOINROOM)
            {
                hallProxy.HallInfo.RoomCode = paramDic[StartUpParam.ROOMID];
                JoinInRoomC2S package = new JoinInRoomC2S();
                package.roomCode = hallProxy.HallInfo.RoomCode;
                package.seat     = 0;
                NetMgr.Instance.SendBuff <JoinInRoomC2S>(SocketType.HALL, MsgNoC2S.REQUEST_JOINROOM_C2S.GetHashCode(), 0, package);
            }
        }
    }
Esempio n. 31
0
        private void BeginLogin()
        {
            // Sanity check some of the parameters
            if (CurrentContext.Params.ViewerDigest == null)
                CurrentContext.Params.ViewerDigest = String.Empty;
            if (CurrentContext.Params.Version == null)
                CurrentContext.Params.Version = String.Empty;
            if (CurrentContext.Params.Platform == null)
                CurrentContext.Params.Platform = String.Empty;
            if (CurrentContext.Params.Options == null)
                CurrentContext.Params.Options = new List<string>();
            if (CurrentContext.Params.MAC == null)
                CurrentContext.Params.MAC = String.Empty;
            if (CurrentContext.Params.Channel == null)
                CurrentContext.Params.Channel = String.Empty;
            if (CurrentContext.Params.Password == null)
                CurrentContext.Params.Password = String.Empty;

            // Convert the password to MD5 if it isn't already
            if (CurrentContext.Params.Password.Length != 35 && !CurrentContext.Params.Password.StartsWith("$1$"))
                CurrentContext.Params.Password = Helpers.MD5(CurrentContext.Params.Password);

            // Override SSL authentication mechanisms. DO NOT convert this to the 
            // .NET 2.0 preferred method, the equivalent function in Mono has a 
            // different name and it will break compatibility!
            ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
            // TODO: At some point, maybe we should check the cert?

            LoginMethodParams loginParams;
            loginParams.first = CurrentContext.Params.FirstName;
            loginParams.last = CurrentContext.Params.LastName;
            loginParams.passwd = CurrentContext.Params.Password;
            loginParams.start = CurrentContext.Params.Start;
            loginParams.channel = CurrentContext.Params.Channel;
            loginParams.version = CurrentContext.Params.Version;
            loginParams.platform = CurrentContext.Params.Platform;
            loginParams.mac = CurrentContext.Params.MAC;
            loginParams.agree_to_tos = "true";
            loginParams.read_critical = "true";
            loginParams.viewer_digest = CurrentContext.Params.ViewerDigest;

            List<string> options = new List<string>(CurrentContext.Params.Options.Count + CallbackOptions.Values.Count);
            options.AddRange(CurrentContext.Params.Options);
            foreach (string[] callbackOpts in CallbackOptions.Values)
            {
                if (callbackOpts != null)
                    foreach (string option in callbackOpts)
                        if (!options.Contains(option)) // TODO: Replace with some kind of Dictionary/Set?
                            options.Add(option);
            }
            loginParams.options = options.ToArray();

            try
            {
                LoginProxy proxy = new LoginProxy();

                proxy.KeepAlive = false;
                proxy.ResponseEvent += new XmlRpcResponseEventHandler(proxy_ResponseEvent);
                proxy.Url = CurrentContext.Params.URI;
                proxy.XmlRpcMethod = CurrentContext.Params.MethodName;
#if !PocketPC
                proxy.Expect100Continue = false;
#endif

                // Start the request
                proxy.BeginLoginToSimulator(loginParams, new AsyncCallback(LoginMethodCallback), new object[] { proxy, CurrentContext });
            }
            catch (Exception e)
            {
                UpdateLoginStatus(LoginStatus.Failed, "Error opening the login server connection: " + e);
            }
        }