Exemplo n.º 1
0
        private async void GotPlayerData(LoginDataPacket packet)
        {
            Client.RtmpConnection.MessageReceived += OnMessageReceived;
            AllSummonerData PlayerData = packet.AllSummonerData;
            SummonerNameLabel.Content = PlayerData.Summoner.Name;
            if (Client.LoginPacket.AllSummonerData.SummonerLevel.Level < 30)
            {
                PlayerProgressBar.Value = (PlayerData.SummonerLevelAndPoints.ExpPoints / PlayerData.SummonerLevel.ExpToNextLevel) * 100;
                PlayerProgressLabel.Content = String.Format("Level {0}", PlayerData.SummonerLevel.Level);
                PlayerCurrentProgressLabel.Content = String.Format("{0}XP", PlayerData.SummonerLevelAndPoints.ExpPoints);
                PlayerAimProgressLabel.Content = String.Format("{0}XP", PlayerData.SummonerLevel.ExpToNextLevel);
            }
            else
            {
                SummonerLeaguesDTO MyLeagues = await RiotCalls.GetAllLeaguesForPlayer(PlayerData.Summoner.SumId);
                GotLeaguesForPlayer(MyLeagues);
            }

            if (packet.BroadcastNotification.broadcastMessages != null)
            {
                Dictionary<string, object> Message = packet.BroadcastNotification.broadcastMessages[0] as Dictionary<string, object>;
                BroadcastMessage.Text = Convert.ToString(Message["content"]);
            }

            foreach (PlayerStatSummary x in packet.PlayerStatSummaries.PlayerStatSummarySet)
            {
                if (x.PlayerStatSummaryTypeString == "Unranked")
                {
                    Client.IsRanked = false;
                    Client.AmountOfWins = x.Wins;
                }
                if (x.PlayerStatSummaryTypeString == "RankedSolo5x5")
                {
                    Client.IsRanked = true;
                    Client.AmountOfWins = x.Wins;
                    break;
                }
            }

            if (packet.ReconnectInfo != null)
            {
                ;
            }

            Client.InfoLabel.Content = "IP: " + Client.LoginPacket.IpBalance + " ∙ RP: " + Client.LoginPacket.RpBalance;
            int ProfileIconID = Client.LoginPacket.AllSummonerData.Summoner.ProfileIconId;
            string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ProfileIconID + ".png");
            ProfileImage.Source = Client.GetImage(uriSource);
            Client.MainPageProfileImage = ProfileImage;

            RefreshTimer = new System.Windows.Forms.Timer();
            RefreshTimer.Tick += new EventHandler(RefreshTimer_Tick);
            RefreshTimer.Interval = 300000; // 5 minutes
            RefreshTimer.Start();
        }
        private async void GotLoginPacket(LoginDataPacket packet)
        {
            Client.LoginPacket = packet;
            Client.PlayerChampions = await RiotCalls.GetAvailableChampions();
            //Client.PVPNet.OnError -= PVPNet_OnError;
            Client.GameConfigs = packet.GameTypeConfigs;
            Client.IsLoggedIn = true;

            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                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 = Dns.GetHostAddresses("chat." + Client.Region.ChatName + ".lol.riotgames.com")[0].ToString();
                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.SwitchPage(new MainPage());
            }));
        }
 private void GotPlayerData(LoginDataPacket packet)
 {
     Client.RiotConnection.MessageReceived += PVPNet_OnMessageReceived;
     UpdateSummonerInformation();
 }
Exemplo n.º 4
0
        internal static LoginDataPacket AddAccount(LoginDataPacket packet)
        {
            if (packet == null)
                return new LoginDataPacket();

            accountslist.Add(packet.AllSummonerData.Summoner.Name, packet);

            return packet;
        }
        private void GotLoginPacket(LoginDataPacket packet)
        {
            if (packet.AllSummonerData == null)
            {
                Client.RiotConnection.CallbackException -= client_CallbackException;
                Client.RiotConnection.MessageReceived -= client_MessageReceived;
                //Just Created Account, need to put logic here.
                Client.done = false;
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    var createSummoner = new CreateSummonerNameOverlay();
                    Client.OverlayContainer.Content = createSummoner.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                }));
                while (!Client.done)
                {
                }
                Login();
                return;
            }
            Client.LoginPacket = packet;
            if (packet.AllSummonerData.Summoner.ProfileIconId == -1)
            {
                Client.RiotConnection.CallbackException -= client_CallbackException;
                Client.RiotConnection.MessageReceived -= client_MessageReceived;
                Client.done = false;
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    Client.OverlayContainer.Content = new ChooseProfilePicturePage().Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                }));
                while (!Client.done)
                {
                }
                Login();

                return;
            }

            Client.RiotConnection.MessageReceived += Client.OnMessageReceived;
            Client.RiotConnection.Disconnected += Client.RiotConnection_Disconnected;
            Client.GameConfigs = packet.GameTypeConfigs;
            Client.IsLoggedIn = true;


            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                MessageBox.Show("Do not play ANY games. I am not sure if they will work ~eddy", "XMPP", MessageBoxButton.OK, MessageBoxImage.Warning);
                Client.StatusContainer.Visibility = Visibility.Visible;
                Client.Container.Margin = new Thickness(0, 0, 0, 40);
                //You have to hand implement this
                //Client.XmppConnection.AutoReconnect = 30;
                Client.XmppConnection = new agsXMPP.XmppClientConnection("pvp.net", 5223)
                {
                    AutoResolveConnectServer = false,
                    ConnectServer = "chat." + Client.Region.ChatName + ".lol.riotgames.com",
                    Resource = "xiff",
                    UseSSL = true,
                    KeepAliveInterval = 10,
                    KeepAlive = true
                };
                Client.XmppConnection.UseCompression = true;
                Client.XmppConnection.OnMessage += Client.XmppConnection_OnMessage;
                Client.XmppConnection.OnError += Client.XmppConnection_OnError;
                Client.XmppConnection.OnLogin += (o) => 
                {
                    Client.Log("Connected to XMPP Server");
                    //Set up chat
                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        if (invisibleLoginCheckBox.IsChecked != true)
                            Client.XmppConnection.Send(new Presence(ShowType.chat, Client.GetPresence(), 0) { Type = PresenceType.available });
                        else
                            Client.XmppConnection.Send(new Presence(ShowType.NONE, Client.GetPresence(), 0) { Type = PresenceType.invisible });
                    }));
                };
                Client.RostManager = new RosterManager(Client.XmppConnection);
                Client.XmppConnection.OnRosterItem += Client.RostManager_OnRosterItem;
                Client.XmppConnection.OnRosterEnd += Client.ChatClientConnect;
                Client.PresManager = new PresenceManager(Client.XmppConnection);
                Client.XmppConnection.OnPresence += Client.XmppConnection_OnPresence;
                if (!Client.Garena)
                {
                    Client.userpass = new KeyValuePair<string, string>(LoginUsernameBox.Text,
                        "AIR_" + LoginPasswordBox.Password);
                    
                    Client.XmppConnection.Open(LoginUsernameBox.Text, "AIR_" + LoginPasswordBox.Password);

                    //Client.XmppConnection.OnInvalidCertificate += Client.XmppConnection_OnInvalidCertificate;
                }
                else
                {
                    Client.XmppConnection.ConnectServer = "chat" + Client.Region.ChatName + ".lol.garenanow.com";
                    var gas = getGas();
                    Client.XmppConnection.Open(Client.UID, "AIR_" + gas);
                    Client.userpass = new KeyValuePair<string, string>(Client.UID, "AIR_" + gas);
                }

                //Client.PresManager.OnPrimarySessionChange += Client.PresManager_OnPrimarySessionChange;
                /*
                Client.ConfManager = new ConferenceManager
                {
                    Stream = Client.XmppConnection
                };
                //*/
                //switch
                Client.Log("Connected to " + Client.Region.RegionName + " and logged in as " +
                           Client.LoginPacket.AllSummonerData.Summoner.Name);

                //Gather data and convert it that way that it does not cause errors
                PlatformGameLifecycleDTO data = (PlatformGameLifecycleDTO)Client.LoginPacket.ReconnectInfo;

                Client.MainPage = new MainPage();
                if (data != null && data.Game != null)
                {
                    Client.Log(data.PlayerCredentials.ChampionId.ToString(CultureInfo.InvariantCulture));
                    Client.CurrentGame = data.PlayerCredentials;
                    Client.GameType = data.Game.GameType;
                    Client.SwitchPage(new InGame());
                }
                else
                    Client.SwitchPage(Client.MainPage);

                Client.ClearPage(typeof(LoginPage));
            }));
        }