Beispiel #1
0
        public async void AddAccount(object sender, RoutedEventArgs e)
        {
            var        context        = RiotCalls.RegisterObjects();
            Region     Regiondata     = GetRegionFromTag.GetRegion(this.Region.Region.Tag.ToString());
            BaseRegion SelectedRegion = BaseRegion.GetRegion(this.Region.Region.Tag.ToString());

            Client.RtmpConnection = new RtmpClient(new System.Uri("rtmps://" + SelectedRegion.Server + ":2099"), context, ObjectEncoding.Amf3);
            await Client.RtmpConnection.ConnectAsync();

            HintLabel1_Copy.Content = Regiondata.Host;
            HintLabel.Visibility    = Visibility.Visible;

            try
            {
                LegacyPVP.Logic.RiotLogic.Login.AuthenticationCredentials lg = new Logic.RiotLogic.Login.AuthenticationCredentials();
                AuthenticationCredentials newCredentials = new AuthenticationCredentials();

                lg.Username      = LOLUsername.WaterTextbox.Text;
                lg.Password      = LOLPassword.WaterTextbox.Password;
                lg.ClientVersion = GetLatestVersions.GetLatestLolVersion(new System.Uri("http://ll.leagueoflegends.com/landingpage/data/na/en_US.js"));
                lg.IpAddress     = RiotCalls.GetIpAddress();
                lg.Locale        = SelectedRegion.Locale;
                lg.Domain        = "lolclient.lol.riotgames.com";

                try
                {
                    newCredentials.AuthToken = RiotCalls.GetAuthKey(LOLUsername.WaterTextbox.Text, LOLPassword.WaterTextbox.Password, Regiondata.LoginQueue.ToString());
                    HintLabel2.Content       = newCredentials.AuthToken;
                }
                catch (Exception f)
                {
                    HintLabel1.Content = newCredentials.ClientVersion;
                    HintLabel2.Content = newCredentials.Locale;

                    var fadeOutAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.5));
                    fadeOutAnimation.Completed += (x, y) =>
                    {
                        var fadeInAnimation = new DoubleAnimation(1, TimeSpan.FromSeconds(0.5));
                    };

                    if (f.Message.Contains("The remote name could not be resolved"))
                    {
                        HintLabel.Content = "Please make sure you are connected the internet!";
                    }
                    else if (f.Message.Contains("(403) Forbidden"))
                    {
                        HintLabel.Content = "Your username or password is incorrect!";
                    }
                    else
                    {
                        HintLabel.Content = f.Message;
                    }
                    //Client.RtmpConnection.Close();
                    return;
                }

                try
                {
                    LegacyPVP.Logic.RiotLogic.Login.AuthenticationCredentials[] Credentials;
                    Credentials = new LegacyPVP.Logic.RiotLogic.Login.AuthenticationCredentials[] { lg };
                    Session login = await RiotCalls.Login(Credentials);

                    Logic.RtmpsLogic.Logic.PlayerSession = login;
                    await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "bc", "bc-" + login.AccountSummary.AccountId.ToString());

                    await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "gn-" + login.AccountSummary.AccountId.ToString(), "gn-" + login.AccountSummary.AccountId.ToString());

                    await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "cn-" + login.AccountSummary.AccountId.ToString(), "cn-" + login.AccountSummary.AccountId.ToString());

                    bool LoggedIn = await Client.RtmpConnection.LoginAsync(LOLUsername.WaterTextbox.Text.ToLower(), login.Token);

                    LoginDataPacket packet = await RiotCalls.GetLoginDataPacketForUser();

                    string State = await RiotCalls.GetAccountState();

                    if (State != "ENABLED")
                    {
                        return;
                    }
                    Login.AddLolAccount(LOLUsername.WaterTextbox.Text, LOLPassword.WaterTextbox.Password, packet.AllSummonerData.Summoner.Name, Regiondata.RegionTag);
                    Client.RtmpConnection.Close();
                }
                catch (InvocationException getVersion)
                {
                    HintLabel.Content = getVersion.Message;

                    /*
                     * object[] array = (object[])((AsObject)getVersion.RootCause)["substitutionArguments"];
                     * if (array.Length == 2 && (string)array[0] == newCredentials.ClientVersion)
                     * {
                     *  newCredentials.ClientVersion = (string)array[1];
                     * }
                     * //*/
                }
                catch (ClientDisconnectedException error)
                {
                    HintLabel.Content = error.Message;
                }
            }
            catch (Exception x)
            {
                HintLabel.Content = x.Message;
            }
        }