public Session Login(AuthenticationCredentials arg0)
 {
     int Id = Invoke("loginService", "login", new object[] { arg0.GetBaseTypedObject() });
     while (!results.ContainsKey(Id))
         System.Threading.Thread.Sleep(10);
     TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
     Session result = new Session(messageBody);
     results.Remove(Id);
     return result;
 }
 public async Task<Session> Login(AuthenticationCredentials arg0)
 {
     int Id = Invoke("loginService", "login", new object[] { arg0.GetBaseTypedObject() });
     while (!results.ContainsKey(Id))
         await Task.Delay(10);
     TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
     Session result = new Session(messageBody);
     results.Remove(Id);
     return result;
 }
 /// 0.)
 private void Login(AuthenticationCredentials arg0, Session.Callback callback)
 {
     Session cb = new Session(callback);
     InvokeWithCallback("loginService", "login", new object[] { arg0.GetBaseTypedObject() }, cb);
 }
#pragma warning disable 4014 //Code does not need to be awaited

        private async void GotLoginPacket(LoginDataPacket packet)
        {
            Client.LoginPacket = packet;
            Client.PlayerChampions = await Client.PVPNet.GetAvailableChampions();
            Client.PVPNet.OnError -= PVPNet_OnError;
            Client.GameConfigs = packet.GameTypeConfigs;
            Client.PVPNet.Subscribe("bc", packet.AllSummonerData.Summoner.AcctId);
            Client.PVPNet.Subscribe("cn", packet.AllSummonerData.Summoner.AcctId);
            Client.PVPNet.Subscribe("gn", packet.AllSummonerData.Summoner.AcctId);
            Client.IsLoggedIn = true;

            

            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() =>
            {
                Client.StatusContainer.Visibility = System.Windows.Visibility.Visible;
                Client.Container.Margin = new Thickness(0, 0, 0, 40);
                
                //Setup chat
                Client.ChatClient.AutoReconnect = 30;
                Client.ChatClient.KeepAlive = 10;
                Client.ChatClient.NetworkHost = "chat." + Client.Region.ChatName + ".lol.riotgames.com";
                Client.ChatClient.Port = 5223;
                Client.ChatClient.Server = "pvp.net";
                Client.ChatClient.SSL = true;
                Client.ChatClient.User = LoginUsernameBox.Text;
                Client.ChatClient.Password = "******" + LoginPasswordBox.Password;
                Client.ChatClient.OnInvalidCertificate += Client.ChatClient_OnInvalidCertificate;
                Client.ChatClient.OnMessage += Client.ChatClient_OnMessage;
                Client.ChatClient.Connect();

                Client.RostManager = new RosterManager();
                Client.RostManager.Stream = Client.ChatClient;
                Client.RostManager.AutoSubscribe = true;
                Client.RostManager.AutoAllow = jabber.client.AutoSubscriptionHanding.AllowAll;
                Client.RostManager.OnRosterItem += Client.RostManager_OnRosterItem;
                Client.RostManager.OnRosterEnd += new bedrock.ObjectHandler(Client.ChatClientConnect);

                Client.PresManager = new PresenceManager();
                Client.PresManager.Stream = Client.ChatClient;
                Client.PresManager.OnPrimarySessionChange += Client.PresManager_OnPrimarySessionChange;

                Client.ConfManager = new ConferenceManager();
                Client.ConfManager.Stream = Client.ChatClient;
                Client.Log("Connected and loged in as" + Client.ChatClient.User);

                Client.SwitchPage(new MainPage());
                Client.ClearPage(this);

                AuthenticationCredentials newCredentials = new AuthenticationCredentials();
                newCredentials.Username = LoginUsernameBox.Text;
                newCredentials.Password = LoginPasswordBox.Password;
                newCredentials.ClientVersion = Client.Version;
                newCredentials.IpAddress = GetNewIpAddress();
                newCredentials.Locale = Client.Region.Locale;
                newCredentials.Domain = "lolclient.lol.riotgames.com";

                Session login = await Client.PVPNet.Login(newCredentials);
                Client.PlayerSession = login;

                //We need this HeartBeat so it looks like this is the real client
                await Client.PVPNet.PerformLCDSHeartBeat(Convert.ToInt32(Client.LoginPacket.AllSummonerData.Summoner.AcctId), Client.PlayerSession.Token, Client.HeartbeatCount, DateTime.Now.ToString("ddd MMM d yyyy HH:mm:ss 'GMT-'%K"));
                Client.HeartbeatCount++;
            }));

            
        }