예제 #1
0
 internal static void OnMessageReceived(object sender, MessageReceivedEventArgs message)
 {
     MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
     {
         if (message.Body is StoreAccountBalanceNotification)
         {
             StoreAccountBalanceNotification newBalance = (StoreAccountBalanceNotification)message.Body;
             InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp;
             LoginPacket.IpBalance = newBalance.Ip;
             LoginPacket.RpBalance = newBalance.Rp;
         }
         else if (message.Body is GameNotification)
         {
             GameNotification notification = (GameNotification)message.Body;
             MessageOverlay messageOver = new MessageOverlay();
             messageOver.MessageTitle.Content = notification.Type;
             switch (notification.Type)
             {
                 case "PLAYER_BANNED_FROM_GAME":
                     messageOver.MessageTitle.Content = "Banned from custom game";
                     messageOver.MessageTextBox.Text = "You have been banned from this custom game!";
                     break;
                 case "PLAYER_QUIT":
                     string[] Name = await RiotCalls.GetSummonerNames(new double[1] { Convert.ToDouble((string)notification.MessageArgument) });
                     messageOver.MessageTitle.Content = "Player has left the queue";
                     messageOver.MessageTextBox.Text = Name[0] + " has left the queue";
                     break;
                 default:
                     messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine;
                     messageOver.MessageTextBox.Text += Convert.ToString(notification.MessageArgument);
                     break;
             }
             OverlayContainer.Content = messageOver.Content;
             OverlayContainer.Visibility = Visibility.Visible;
             QuitCurrentGame();
         }
         else if (message.Body is EndOfGameStats)
         {
             EndOfGameStats stats = message.Body as EndOfGameStats;
             EndOfGamePage EndOfGame = new EndOfGamePage(stats);
             OverlayContainer.Visibility = Visibility.Visible;
             OverlayContainer.Content = EndOfGame.Content;
         }
         else if (message.Body is StoreFulfillmentNotification)
         {
             PlayerChampions = await RiotCalls.GetAvailableChampions();
         }
         else if (message.Body is GameDTO)
         {
             GameDTO Queue = message.Body as GameDTO;
             if (!IsInGame && Queue.GameState != "TERMINATED" && Queue.GameState != "TERMINATED_IN_ERROR")
             {
                 MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                 {
                     Client.OverlayContainer.Content = new QueuePopOverlay(Queue).Content;
                     Client.OverlayContainer.Visibility = Visibility.Visible;
                 }));
             }
         }
         else if (message.Body is SearchingForMatchNotification)
         {
             SearchingForMatchNotification Notification = message.Body as SearchingForMatchNotification;
             if (Notification.PlayerJoinFailures != null && Notification.PlayerJoinFailures.Count > 0)
             {
                 MessageOverlay messageOver = new MessageOverlay();
                 messageOver.MessageTitle.Content = "Could not join the queue";
                 foreach (QueueDodger x in Notification.PlayerJoinFailures)
                 {
                     messageOver.MessageTextBox.Text += x.Summoner.Name + " is unable to join the queue as they recently dodged a game." + Environment.NewLine;
                     TimeSpan time = TimeSpan.FromMilliseconds(x.PenaltyRemainingTime);
                     messageOver.MessageTextBox.Text += "You have " + string.Format("{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again";
                 }
                 OverlayContainer.Content = messageOver.Content;
                 OverlayContainer.Visibility = Visibility.Visible;
             }
         }
     }));
 }
예제 #2
0
        //internal static Inviter CurrentInviter;

        internal static void OnMessageReceived(object sender, object message)
        {
            MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
            {
                if (message is StoreAccountBalanceNotification)
                {
                    StoreAccountBalanceNotification newBalance = (StoreAccountBalanceNotification)message;
                    InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp;
                    Client.LoginPacket.IpBalance = newBalance.Ip;
                    Client.LoginPacket.RpBalance = newBalance.Rp;
                }
                else if (message is GameNotification)
                {
                    GameNotification notification = (GameNotification)message;
                    MessageOverlay messageOver = new MessageOverlay();
                    messageOver.MessageTitle.Content = notification.Type;
                    switch (notification.Type)
                    {
                        case "PLAYER_BANNED_FROM_GAME":
                            messageOver.MessageTitle.Content = "Banned from custom game";
                            messageOver.MessageTextBox.Text = "You have been banned from this custom game!";
                            break;

                        default:
                            messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine;
                            messageOver.MessageTextBox.Text = Convert.ToString(notification.MessageArgument);
                            break;
                    }
                    Client.OverlayContainer.Content = messageOver.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                    Client.ClearPage(new CustomGameLobbyPage());
                    Client.SwitchPage(new MainPage());
                }
                else if (message is EndOfGameStats)
                {
                    EndOfGameStats stats = message as EndOfGameStats;
                    EndOfGamePage EndOfGame = new EndOfGamePage(stats);
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                    Client.OverlayContainer.Content = EndOfGame.Content;
                }
                else if (message is StoreFulfillmentNotification)
                {
                    PlayerChampions = await PVPNet.GetAvailableChampions();
                }
                else if (message is Inviter)
                {
                    Inviter stats = message as Inviter;
                    //CurrentInviter = stats;
                }
                else if (message is InvitationRequest)
                {
                    InvitationRequest stats = message as InvitationRequest;
                    Inviter Inviterstats = message as Inviter;
                    //TypedObject body = (TypedObject)to["body"];
                    MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        //Gameinvite stuff
                        GameInvitePopup pop = new GameInvitePopup(stats);
                        //await Invite.Callback;
                        //Invite.InvitationRequest(body);
                        pop.HorizontalAlignment = HorizontalAlignment.Right;
                        pop.VerticalAlignment = VerticalAlignment.Bottom;
                        pop.Height = 230;
                        Client.NotificationGrid.Children.Add(pop);
                        //Client.InviteJsonRequest = LegendaryClient.Logic.JSON.InvitationRequest.PopulateGameInviteJson();
                        //message.GetType() == typeof(GameInvitePopup)
                    }));
                }
            }));
        }
예제 #3
0
        internal static void OnMessageReceived(object sender, object message)
        {
            MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
            {
                if (message is StoreAccountBalanceNotification)
                {
                    StoreAccountBalanceNotification newBalance = (StoreAccountBalanceNotification)message;
                    InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp;
                    Client.LoginPacket.IpBalance = newBalance.Ip;
                    Client.LoginPacket.RpBalance = newBalance.Rp;
                }
                else if (message is GameNotification)
                {
                    GameNotification notification = (GameNotification)message;
                    MessageOverlay messageOver = new MessageOverlay();
                    messageOver.MessageTitle.Content = notification.Type;
                    switch (notification.Type)
                    {
                        case "PLAYER_BANNED_FROM_GAME":
                            messageOver.MessageTitle.Content = "Banned from custom game";
                            messageOver.MessageTextBox.Text = "You have been banned from this custom game!";
                            break;

                        default:
                            messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine;
                            messageOver.MessageTextBox.Text = Convert.ToString(notification.MessageArgument);
                            break;
                    }
                    Client.OverlayContainer.Content = messageOver.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                    Client.ClearPage(new CustomGameLobbyPage());
                    Client.SwitchPage(new MainPage());
                }
                else if (message is EndOfGameStats)
                {
                    EndOfGameStats stats = message as EndOfGameStats;
                    EndOfGamePage EndOfGame = new EndOfGamePage(stats);
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                    Client.OverlayContainer.Content = EndOfGame.Content;
                }
                else if (message is StoreFulfillmentNotification)
                {
                    PlayerChampions = await PVPNet.GetAvailableChampions();
                }
            }));
        }
예제 #4
0
#pragma warning disable 4014

        internal static void OnMessageReceived(object sender, MessageReceivedEventArgs message)
        {
            Log("Message received! The type is: " + message.Body.GetType());
            MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
            {
                var balance = message.Body as StoreAccountBalanceNotification;
                if (balance != null)
                {
                    StoreAccountBalanceNotification newBalance = balance;
                    InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp;
                    LoginPacket.IpBalance = newBalance.Ip;
                    LoginPacket.RpBalance = newBalance.Rp;
                }
                else
                {
                    var gameNotification = message.Body as GameNotification;
                    if (gameNotification != null)
                    {
                        GameNotification notification = gameNotification;
                        var messageOver = new MessageOverlay { MessageTitle = { Content = notification.Type } };
                        switch (notification.Type)
                        {
                            case "PLAYER_BANNED_FROM_GAME":
                                messageOver.MessageTitle.Content = "Banned from custom game";
                                messageOver.MessageTextBox.Text = "You have been banned from this custom game!";
                                break;
                            case "PLAYER_QUIT":
                                messageOver.MessageTitle.Content = "Player quit";
                                var name = await RiotCalls.GetSummonerNames(new[] { Convert.ToDouble(notification.MessageArgument) });
                                messageOver.MessageTextBox.Text = name[0] + " quit from queue!";
                                break;
                            default:
                                messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine;
                                messageOver.MessageTextBox.Text = System.Convert.ToString(notification.MessageArgument);
                                break;
                        }
                        OverlayContainer.Content = messageOver.Content;
                        OverlayContainer.Visibility = Visibility.Visible;
                        ClearPage(typeof(CustomGameLobbyPage));
                        if (notification.Type != "PLAYER_QUIT")
                            SwitchPage(Client.MainPage);
                    }
                    else if (message.Body is EndOfGameStats)
                    {
                        var stats = (EndOfGameStats)message.Body;
                        var EndOfGame = new EndOfGamePage(stats);
                        ClearPage(typeof(TeamQueuePage));
                        OverlayContainer.Visibility = Visibility.Visible;
                        OverlayContainer.Content = EndOfGame.Content;
                    }
                    else if (message.Body is StoreFulfillmentNotification)
                    {
                        PlayerChampions = await RiotCalls.GetAvailableChampions();
                    }
                    else if (message.Body is Inviter)
                    {
                        var stats = (Inviter)message.Body;
                        //CurrentInviter = stats;
                    }
                    else if (message.Body is InvitationRequest)
                    {
                        var stats = (InvitationRequest)message.Body;
                        if (stats.Inviter == null)
                            return;


                        if (InviteData.ContainsKey(stats.InvitationId))
                        {
                            InviteInfo x = InviteData[stats.InvitationId];
                            if (x.Inviter != null)
                                return;
                        }
                        
                        MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                        {
                            var pop = new GameInvitePopup(stats)
                            {
                                HorizontalAlignment = HorizontalAlignment.Right,
                                VerticalAlignment = VerticalAlignment.Bottom,
                                Height = 230
                            };

                            NotificationGrid.Children.Add(pop);
                        }));
                        MainWin.FlashWindow();
                    }
                    else if (message.Body is ClientLoginKickNotification)
                    {
                        var kick = (ClientLoginKickNotification)message.Body;
                        if (kick.sessionToken == null)
                            return;

                        Warning Warn = new Warning
                        {
                            Header = { Content = "Kicked from server" },
                            MessageText = { Text = "This account has been logged in from another location" }
                        };
                        Warn.backtochampselect.Click += (MainWin as MainWindow).LogoutButton_Click;
                        Warn.AcceptButton.Click += QuitClient;
                        Warn.hide.Visibility = Visibility.Hidden;
                        Warn.backtochampselect.Content = "Logout(Work in progress)";
                        Warn.AcceptButton.Content = "Quit";
                        FullNotificationOverlayContainer.Content = Warn.Content;
                        FullNotificationOverlayContainer.Visibility = Visibility.Visible;
                    }
                    else if (message.Body is SimpleDialogMessage)
                    {
                        var leagueInfo = message.Body as SimpleDialogMessage;
                        if (leagueInfo.Type == "leagues")
                        {
                            var promote = LeaguePromote.LeaguesPromote(leagueInfo.Params.ToString());
                            var messageOver = new MessageOverlay();
                            messageOver.MessageTitle.Content = "Leagues updated";
                            messageOver.MessageTextBox.Text = promote.leagueItem.PlayerOrTeamName + " have been promoted to " + promote.leagueItem.Rank;
                            var response = new SimpleDialogMessageResponse
                            {
                                Command = "ack",
                                AccountId = leagueInfo.AccountId,
                                MessageId = leagueInfo.MessageId
                            };
                            messageOver.AcceptButton.Click += (o, e) => { RiotCalls.CallPersistenceMessaging(response); };
                        }
                    }
                }
            }));
        }
예제 #5
0
 internal static void OnMessageReceived(object sender, object message)
 {
     MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
     {
         if (message is StoreAccountBalanceNotification)
         {
             StoreAccountBalanceNotification newBalance = (StoreAccountBalanceNotification)message;
             InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp;
             LoginPacket.IpBalance = newBalance.Ip;
             LoginPacket.RpBalance = newBalance.Rp;
         }
         else if (message is GameNotification)
         {
             GameNotification notification = (GameNotification)message;
             MessageOverlay messageOver = new MessageOverlay();
             messageOver.MessageTitle.Content = notification.Type;
             switch (notification.Type)
             {
                 case "PLAYER_BANNED_FROM_GAME":
                     messageOver.MessageTitle.Content = "Banned from custom game";
                     messageOver.MessageTextBox.Text = "You have been banned from this custom game!";
                     break;
                 case "PLAYER_QUIT":
                     string[] Name = await PVPNet.GetSummonerNames(new double[1] { Convert.ToDouble((string)notification.MessageArgument) });
                     messageOver.MessageTitle.Content = "Player has left the queue";
                     messageOver.MessageTextBox.Text = Name[0] + " has left the queue";
                     break;
                 default:
                     messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine;
                     messageOver.MessageTextBox.Text += Convert.ToString(notification.MessageArgument);
                     break;
             }
             OverlayContainer.Content = messageOver.Content;
             OverlayContainer.Visibility = Visibility.Visible;
             QuitCurrentGame();
         }
         else if (message is EndOfGameStats)
         {
             EndOfGameStats stats = message as EndOfGameStats;
             EndOfGamePage EndOfGame = new EndOfGamePage(stats);
             OverlayContainer.Visibility = Visibility.Visible;
             OverlayContainer.Content = EndOfGame.Content;
         }
         else if (message is StoreFulfillmentNotification)
         {
             PlayerChampions = await PVPNet.GetAvailableChampions();
         }
         else if (message is GameDTO)
         {
             GameDTO Queue = message as GameDTO;
             if (!IsInGame && Queue.GameState != "TERMINATED")
             {
                 MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                 {
                     Client.OverlayContainer.Content = new QueuePopOverlay(Queue).Content;
                     Client.OverlayContainer.Visibility = Visibility.Visible;
                 }));
             }
         }
     }));
 }