Ejemplo n.º 1
0
        public void Login()
        {
            m_LoginResult = FacebookService.Login(
                "129594497748718", // My AppId: 129594497748718 ,Course AppId: 1450160541956417
                "public_profile",
                "user_about_me",
                "user_relationships",
                "user_relationship_details",
                "user_birthday",
                "user_friends",
                "publish_actions",
                "user_events",
                "user_posts",
                "user_photos",
                "user_status");

            if (!string.IsNullOrEmpty(m_LoginResult.AccessToken))
            {
                m_LoggedInUser = m_LoginResult.LoggedInUser;
            }
            else
            {
                throw new Exception(m_LoginResult.ErrorMessage);
            }

            if (LoginFinished != null)
            {
                LoginFinished.Invoke(this, EventArgs.Empty);
            }
        }
        private void OnLogin(object state)
        {
            if (string.IsNullOrEmpty(NickName))
            {
                MessageBox.Show("Будь ласка, введіть ім'я");
                return;
            }

            PlayerController.Instance.PlayerName = NickName;
            LoginFinished?.Invoke(this, null);
        }
        private void OnLogin(object state)
        {
            try
            {
                var domainPort = DomainPort.Split(':');
                var port       = int.Parse(domainPort[1]);
                SessionController.Instance.Connect(UserName, Password, domainPort[0], port);

                SessionController.Instance.Session.MarketDataClient.OnServerStateChanged.Subscribe(
                    OnMarketDataClientStateChanged);

                Window window = new MainWindow();
                window.Show();

                LoginFinished?.Invoke(this, null);
            }
            catch
            {
                MessageBox.Show("Fill in all the fields, please.");
            }
        }
Ejemplo n.º 4
0
        public async Task FinishLoginAsync()
        {
            string getResult = await netHandler.GETRequestAsync(redirectUri, true);

            HtmlDocument getDoc = new HtmlDocument();

            getDoc.LoadHtml(getResult);
            save         = new SaveState();
            save.cookies = new List <Cookie>();
            foreach (Cookie cookieToSave in netHandler.cookies.GetCookies(new Uri("https://" + host)))
            {
                save.cookies.Add(cookieToSave);
            }
            save.skey        = getDoc.DocumentNode.Descendants("skey").ElementAt(0).InnerText;
            save.wxsid       = getDoc.DocumentNode.Descendants("wxsid").ElementAt(0).InnerText;
            save.wxuin       = getDoc.DocumentNode.Descendants("wxuin").ElementAt(0).InnerText;
            save.pass_ticket = getDoc.DocumentNode.Descendants("pass_ticket").ElementAt(0).InnerText;
            save.host        = host;
            using (StreamWriter SW = new StreamWriter(File.Create(rootPath + "saved"), System.Text.Encoding.UTF8))
                await SW.WriteAsync(JsonConvert.SerializeObject(save));
            LoginFinished?.Invoke(this, null);
        }
Ejemplo n.º 5
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     TraceClientExtensions.TraceMessage(TraceEventType.Information, 1, $"Intentando hacer login con el usuario {txtUserName.Text}");
     if (string.IsNullOrEmpty(txtUserName.Text))
     {
         MessageBox.Show("Necesito un nombre de usuario");
     }
     else
     {
         ServerIP = txtServerIP.Text;
         GameName = cmbGameName.Text;
         UserName = txtUserName.Text;
         try
         {
             using (MyServiceClient c = new MyServiceClient(ServerIP))
             {
                 string result = c.Login(UserName, GameName, "");
                 if (result != "OK")
                 {
                     TraceClientExtensions.TraceMessage(TraceEventType.Error, 1,
                                                        $"Error al hacer login con el usuario {txtUserName.Text}: {result}");
                     MessageBox.Show("ERROR AL LOGGUEAR: " + result);
                 }
                 else
                 {
                     grpLogin.Enabled       = false;
                     lblWaitingPlayers.Text = "Esperando al resto de jugadores";
                     LoginFinished?.Invoke(this, EventArgs.Empty);
                 }
             }
         }
         catch (Exception ex)
         {
             TraceClientExtensions.TraceMessage(TraceEventType.Error, 1, $"Error al hacer login con el usuario {txtUserName.Text}: {ex.ToString()}");
             MessageBox.Show("Error al hacer login: " + ex.Message);
         }
     }
 }
Ejemplo n.º 6
0
 public void GoToNextScreen()
 {
     LoginFinished.Invoke(new LoginFinishedInvokerArgs(this));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Login here
 /// </summary>
 /// <param name="onFinish">Delegate for when Login is done.</param>
 /// <param name="email">Users e-mail address</param>
 /// <param name="password">Password</param>
 /// <param name="captcha">Captcha string if required</param>
 /// <param name="status">Status to log in as</param>
 public void Login(LoginFinished onFinish, LoginProgressUpdate onUpdate, string email, string password, string captcha, UserStatus status)
 {
     if(Socket.Connected)
     {
         Thread t = new Thread(() =>
                                   {
                                       //TODO Need to add a method to handle 2-step signin.
                                       _onLoginFinished = onFinish;
                                       String appName = "skylabs-LobbyClient-" + Version;
                                       Service s = new Service("code", appName);
                                       s.setUserCredentials(email, password);
                                       if(captcha != null && _mCaptchaToken != null)
                                       {
                                           onUpdate.Invoke("Verifying captcha");
                                           if(!String.IsNullOrWhiteSpace(captcha) || !String.IsNullOrWhiteSpace(_mCaptchaToken))
                                           {
                                               s.Credentials.CaptchaToken = _mCaptchaToken;
                                               s.Credentials.CaptchaAnswer = captcha;
                                           }
                                       }
                                       try
                                       {
                                           Debug.WriteLine("Querying Google...");
                                           onUpdate.Invoke("Logging into Google...");
                                           string ret = s.QueryClientLoginToken();
                                           onUpdate.Invoke("Sending login token to Server...");
                                           Debug.WriteLine("Received login token.");
                                           SocketMessage sm = new SocketMessage("login");
                                           sm.AddData("email", email);
                                           sm.AddData("token", ret);
                                           sm.AddData("status", status);
                                           WriteMessage(sm);
                                           onUpdate.Invoke("Waiting for server response...");
                                       }
                                       catch(CaptchaRequiredException ce)
                                       {
                                           _mCaptchaToken = ce.Token;
                                           if(OnCaptchaRequired != null) OnCaptchaRequired.Invoke("https://www.google.com/accounts/DisplayUnlockCaptcha", ce.Url);
                                       }
                                       catch(AuthenticationException re)
                                       {
                                           string cu = (string)re.Data["CaptchaUrl"];
                                           onFinish.Invoke(LoginResult.Failure, DateTime.Now, re.Message);
                                       }
                                       catch(WebException)
                                       {
                                           onFinish.Invoke(LoginResult.Failure, DateTime.Now, "Connection problem.");
                                       }
                                       onFinish.Invoke(LoginResult.WaitingForResponse, DateTime.Now, "");
                                   });
         t.Start();
     }
 }