Example #1
0
    public bool HandleMessage(MessageReceivedEventArgs args) {
      var game = args.Body as GameDTO;

      if (game != null) {
        switch (game.GameState) {
          case "JOINING_CHAMP_SELECT": //QUEUE POP
            if (!HasPopped) {
              OnQueuePop(game);
            }

            OnQueuePopUpdated(game);
            break;

          case "CHAMP_SELECT":
            OnEnteredChampSelect(game);
            break;

          case "TERMINATED":
            OnQueueCancelled();
            break;
        }

        return true;
      }

      return false;
    }
Example #2
0
    internal override bool HandleMessage(MessageReceivedEventArgs args) {
      GameDTO game = args.Body as GameDTO;
      PlayerCredentialsDto creds = args.Body as PlayerCredentialsDto;

      if (game != null) {
        GotGameData(game);
        return true;
      } else if (creds != null) {
        OnGameStart(creds);
        return true;
      }

      return false;
    }
Example #3
0
 public bool HandleMessage(MessageReceivedEventArgs args) {
   var game = args.Body as GameDTO;
   if (game != null) {
     if (game.GameState.Equals("TERMINATED_IN_ERROR")) {
       Session.Current.ChatManager.Status = ChatStatus.outOfGame;
       Close?.Invoke(this, new EventArgs());
       return true;
     } else if (game.GameState.Equals("TERMINATED")) {
       Session.Current.ChatManager.Status = ChatStatus.outOfGame;
       Close?.Invoke(this, new EventArgs());
       return true;
     }
   }
   return false;
 }
Example #4
0
        private void Update_OnMessageReceived(object sender, MessageReceivedEventArgs message)
        {
            if (message.Body.GetType() != typeof(GameDTO))
                return;

            if (((GameDTO)message.Body).GameState != "TERMINATED")
                return;

            Client.GameStatus = "outOfGame";
            Client.SetChatHover();
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                Client.ReturnButton.Visibility = Visibility.Hidden;
                Client.IsInGame = false;
                Client.RiotConnection.MessageReceived -= Update_OnMessageReceived;
                Client.SwitchPage(Client.MainPage);
                Client.ClearPage(typeof(InGame));
            }));
        }
 public bool HandleMessage(MessageReceivedEventArgs args) => false;
        private void PVPNet_OnMessageReceived(object sender, MessageReceivedEventArgs message)
        {
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                if (!(message.Body is BroadcastNotification))
                    return;

                //var notif = message as BroadcastNotification;
                //if (notif.BroadcastMessages == null)
                //    return;
                //
                //var Message = notif.BroadcastMessages[0];
                //if (Message != null && Message.Active)
                //    BroadcastMessage.Text = Message.Content;
                //else
                //    BroadcastMessage.Text = "";
            }));
        }
Example #7
0
 internal abstract bool HandleMessage(MessageReceivedEventArgs args);
Example #8
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;
             }
         }
     }));
 }
 private void GameLobby_OnMessageReceived(object sender, MessageReceivedEventArgs message)
 {
     Lobby_OnMessageReceived(sender, message.Body);
 }
 private void ChampSelect_OnMessageReceived(object sender, MessageReceivedEventArgs message)
 {
     Select_OnMessageReceived(sender, message.Body);
 }
Example #11
0
 static void RtmpConnection_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     
 }
 void OnAsyncMessageReceived(object sender, MessageReceivedEventArgs args)
 {
     AsyncMessageEventArgs rpcr = new AsyncMessageEventArgs(args.Message.Body);
     _extensionManager.FireAsyncMessageReceivedEvent(rpcr);
     //args.Result.Body = rpcr.Body;
     args.Message.Body = rpcr.Body;
 }
Example #13
0
 void OnAsyncMessageReceived(object sender, MessageReceivedEventArgs e)
 {
     if (AsyncMessageReceived != null)
         AsyncMessageReceived(this, e);
     _source.InvokeReceive(e.ClientId, e.Subtopic, e.Message.Body);
 }
        private void PVPNet_OnMessageReceived(object sender, MessageReceivedEventArgs message)
        {
            if (message.Body.GetType() == typeof(GameDTO))
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    var QueueDTO = message.Body as GameDTO;
                    if (QueueDTO != null && QueueDTO.GameState == "TERMINATED")
                    {
                        Client.OverlayContainer.Visibility = Visibility.Hidden;
                        Client.RiotConnection.MessageReceived -= PVPNet_OnMessageReceived;
                        Client.SendAccept(accepted);
                        Client.HasPopped = false;
                        return;
                    }
                    if (QueueDTO != null &&
                        (QueueDTO.GameState == "PRE_CHAMP_SELECT" || QueueDTO.GameState == "CHAMP_SELECT"))
                    {
                        Client.RiotConnection.MessageReceived -= PVPNet_OnMessageReceived;
                        string s = QueueDTO.GameState;
                        Client.ChampSelectDTO = QueueDTO;
                        Client.GameID = QueueDTO.Id;
                        Client.LastPageContent = Client.Container.Content;
                        Client.OverlayContainer.Visibility = Visibility.Hidden;
                        Client.GameStatus = "championSelect";
                        Client.SetChatHover();
                        Client.SwitchPage(page.Load(this));
                        Client.SendAccept(accepted);
                        Client.HasPopped = false;
                    }

                    int i = 0;
                    if (QueueDTO == null)
                        return;

                    var playerParticipantStatus = (string)QueueDTO.StatusOfParticipants;
                    if (ReverseString)
                    {
                        string firstHalf = playerParticipantStatus.Substring(0, playerParticipantStatus.Length / 2);
                        string secondHalf = playerParticipantStatus.Substring(playerParticipantStatus.Length / 2,
                            playerParticipantStatus.Length / 2);
                        playerParticipantStatus = secondHalf + firstHalf;
                    }
                    foreach (char c in playerParticipantStatus)
                    {
                        QueuePopPlayer player = null;
                        if (i < playerParticipantStatus.Length / 2) //Team 1
                        {
                            if (i <= Team1ListBox.Items.Count - 1)
                                player = (QueuePopPlayer)Team1ListBox.Items[i];
                        }
                        else if (i - 5 <= Team2ListBox.Items.Count - 1) //Team 2
                            player = (QueuePopPlayer)Team2ListBox.Items[i - (playerParticipantStatus.Length / 2)];

                        if (player != null)
                        {
                            switch (c)
                            {
                                case '1':
                                    player.ReadyImage.Source = Client.GetImage("/LegendaryClient;component/accepted.png");
                                    break;
                                case '2':
                                    player.ReadyImage.Source = Client.GetImage("/LegendaryClient;component/declined.png");
                                    break;
                            }
                        }

                        i++;
                    }
                }));
            }
        }
Example #15
0
 private void OnMessageReceived(object sender, MessageReceivedEventArgs args)
 {
     RiotAccount riotAccount = sender as RiotAccount;
     EndOfGameStats body = args.Body as EndOfGameStats;
     if (body != null)
     {
         Match match = MatchService.MatchTransformer.Transform(body, riotAccount.LastNonNullGame, riotAccount.RealmId);
         MatchService.GameRewards gameReward = new MatchService.GameRewards()
         {
             InfluencePoints = (int)body.IpEarned,
             Experience = (int)body.ExperienceEarned,
             RiotPoints = 0
         };
         match.AdditionalData = gameReward;
         this.lastMatches[match.RealmId] = match;
         MatchService.CacheMatch(match);
         this.NotifyMatchCompleted(match);
     }
     SimpleDialogMessage simpleDialogMessage = args.Body as SimpleDialogMessage;
     if (simpleDialogMessage != null && simpleDialogMessage.Type == "leagues")
     {
         Match item = this.lastMatches[riotAccount.RealmId];
         if (item == null)
         {
             return;
         }
         JObject jObjects = simpleDialogMessage.Params.OfType<string>().Select<string, JObject>(new Func<string, JObject>(JObject.Parse)).FirstOrDefault<JObject>((JObject x) => (long)x["gameId"] == item.MatchId);
         if (jObjects == null)
         {
             return;
         }
         MatchService.GameRewards additionalData = item.AdditionalData as MatchService.GameRewards;
         if (additionalData == null)
         {
             return;
         }
         additionalData.LeaguePoints = (int)jObjects["leaguePointsDelta"];
         this.NotifyMatchCompleted(item);
     }
 }
 private void OnMessageReceived(object sender, MessageReceivedEventArgs args)
 {
     try
     {
         RiotAccount riotAccount = sender as RiotAccount;
         if (riotAccount != null && riotAccount == JsApiService.RiotAccount && riotAccount.Game != null)
         {
             GameDTO body = args.Body as GameDTO;
             if (body == null)
             {
                 TradeContractDTO tradeContractDTO = args.Body as TradeContractDTO;
                 if (tradeContractDTO != null)
                 {
                     PlayerParticipant[] array = riotAccount.Game.AllPlayers.ToArray<PlayerParticipant>();
                     string summonerName = array.First<PlayerParticipant>((PlayerParticipant x) => x.SummonerInternalName == tradeContractDTO.RequesterInternalSummonerName).SummonerName;
                     string str = array.First<PlayerParticipant>((PlayerParticipant x) => x.SummonerInternalName == tradeContractDTO.RequesterInternalSummonerName).SummonerName;
                     string state = tradeContractDTO.State;
                     string str1 = state;
                     if (state != null)
                     {
                         if (str1 == "PENDING")
                         {
                             JsApiService.Push("game:current:trade:request", true);
                             JsApiService.Push("game:current:trade:data", new { Request = new { IsSelf = tradeContractDTO.RequesterInternalSummonerName == riotAccount.SummonerInternalName, SummonerName = summonerName, ChampionId = tradeContractDTO.RequesterChampionId }, Response = new { IsSelf = tradeContractDTO.ResponderInternalSummonerName == riotAccount.SummonerInternalName, SummonerName = str, ChampionId = tradeContractDTO.ResponderChampionId }, OtherSummonerName = (tradeContractDTO.RequesterInternalSummonerName == riotAccount.SummonerInternalName ? str : summonerName), OtherSummonerInternalName = tradeContractDTO.RequesterInternalSummonerName });
                         }
                         else if (str1 == "BUSY")
                         {
                             this.DismissTrade();
                             JsApiService.Push("game:current:trade:status", "busy");
                         }
                         else if (str1 == "DECLINED")
                         {
                             this.DismissTrade();
                             JsApiService.Push("game:current:trade:status", "declined");
                         }
                         else if (str1 == "INVALID" || str1 == "CANCELED")
                         {
                             this.DismissTrade();
                             JsApiService.Push("game:current:trade:request", false);
                         }
                     }
                 }
             }
             else
             {
                 PlayerChampionSelectionDTO playerChampionSelectionDTO = body.PlayerChampionSelections.FirstOrDefault<PlayerChampionSelectionDTO>((PlayerChampionSelectionDTO x) => x.SummonerInternalName == riotAccount.SummonerInternalName);
                 int num = (playerChampionSelectionDTO != null ? playerChampionSelectionDTO.ChampionId : 0);
                 if (num != this.oldChampionId)
                 {
                     this.DismissTrade();
                 }
                 this.oldChampionId = num;
                 GameTypeConfigDTO gameTypeConfigDTO = riotAccount.GameTypeConfigs.First<GameTypeConfigDTO>((GameTypeConfigDTO x) => x.Id == (double)body.GameTypeConfigId);
                 if (body.GameState != "POST_CHAMP_SELECT" || !gameTypeConfigDTO.AllowTrades)
                 {
                     JsApiService.Push("game:current:trade:targets", new object[0]);
                 }
                 if (gameTypeConfigDTO.AllowTrades)
                 {
                     string championSelectionsString = HeroSelectService.GetChampionSelectionsString(body);
                     if (championSelectionsString != this.oldChampionSelectionString)
                     {
                         this.UpdateTradersAsync(riotAccount);
                     }
                     this.oldChampionSelectionString = championSelectionsString;
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #17
0
    internal override bool HandleMessage(MessageReceivedEventArgs args) {
      var lcds = args.Body as LcdsServiceProxyResponse;

      if (lcds != null) {
        switch (lcds.methodName) {
          case "tbdGameDtoV1":
            GotGameData(lcds);
            break;
          case "removedFromServiceV1":
            OnLeftLobby();
            break;
        }
      }

      return base.HandleMessage(args);
    }
Example #18
0
        private void GotQueuePop(object sender, MessageReceivedEventArgs message)
        {
            if (!(message.Body is GameDTO))
                return;

            var queue = (GameDTO) message.Body;
            if (Client.HasPopped)
                return;
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                Client.HasPopped = true;
                Client.OverlayContainer.Content = new QueuePopOverlay(queue, this).Content;
                Client.OverlayContainer.Visibility = Visibility.Visible;
            }));
            Client.RiotConnection.MessageReceived -= GotQueuePop;
        }
Example #19
0
 private void RestartDodgePop(object sender, MessageReceivedEventArgs message)
 {
     if (message.Body is GameDTO)
     {
         var queue = (GameDTO)message.Body;
         if (queue.GameState == "TERMINATED")
         {
             Client.HasPopped = false;
             Client.RiotConnection.MessageReceived += GotQueuePop;
         }
     }
     else if (message.Body is PlayerCredentialsDto)
     {
         Client.RiotConnection.MessageReceived -= RestartDodgePop;
     }
 }
 private void OnMessageReceived(object sender, MessageReceivedEventArgs e)
 {
   try
   {
     RiotAccount account = sender as RiotAccount;
     if (account == null || account != JsApiService.RiotAccount || account.Game == null)
       return;
     GameDTO game = e.Body as GameDTO;
     if (game != null)
     {
       PlayerChampionSelectionDTO championSelectionDto = Enumerable.FirstOrDefault<PlayerChampionSelectionDTO>((IEnumerable<PlayerChampionSelectionDTO>) game.PlayerChampionSelections, (Func<PlayerChampionSelectionDTO, bool>) (x => x.SummonerInternalName == account.SummonerInternalName));
       int num = championSelectionDto != null ? championSelectionDto.ChampionId : 0;
       if (num != this.oldChampionId)
         this.DismissTrade();
       this.oldChampionId = num;
       GameTypeConfigDTO gameTypeConfigDto = Enumerable.First<GameTypeConfigDTO>((IEnumerable<GameTypeConfigDTO>) account.GameTypeConfigs, (Func<GameTypeConfigDTO, bool>) (x => x.Id == (double) game.GameTypeConfigId));
       if (game.GameState != "POST_CHAMP_SELECT" || !gameTypeConfigDto.AllowTrades)
         JsApiService.Push("game:current:trade:targets", (object) new object[0]);
       if (!gameTypeConfigDto.AllowTrades)
         return;
       string selectionsString = HeroSelectService.GetChampionSelectionsString(game);
       if (selectionsString != this.oldChampionSelectionString)
         this.UpdateTradersAsync(account);
       this.oldChampionSelectionString = selectionsString;
     }
     else
     {
       TradeContractDTO trade = e.Body as TradeContractDTO;
       if (trade == null)
         return;
       PlayerParticipant[] playerParticipantArray = Enumerable.ToArray<PlayerParticipant>(account.Game.AllPlayers);
       string str1 = Enumerable.First<PlayerParticipant>((IEnumerable<PlayerParticipant>) playerParticipantArray, (Func<PlayerParticipant, bool>) (x => x.SummonerInternalName == trade.RequesterInternalSummonerName)).SummonerName;
       string str2 = Enumerable.First<PlayerParticipant>((IEnumerable<PlayerParticipant>) playerParticipantArray, (Func<PlayerParticipant, bool>) (x => x.SummonerInternalName == trade.RequesterInternalSummonerName)).SummonerName;
       switch (trade.State)
       {
         case "PENDING":
           JsApiService.Push("game:current:trade:request", (object) true);
           JsApiService.Push("game:current:trade:data", (object) new
           {
             Request = new
             {
               IsSelf = (trade.RequesterInternalSummonerName == account.SummonerInternalName),
               SummonerName = str1,
               ChampionId = trade.RequesterChampionId
             },
             Response = new
             {
               IsSelf = (trade.ResponderInternalSummonerName == account.SummonerInternalName),
               SummonerName = str2,
               ChampionId = trade.ResponderChampionId
             },
             OtherSummonerName = (trade.RequesterInternalSummonerName == account.SummonerInternalName ? str2 : str1),
             OtherSummonerInternalName = trade.RequesterInternalSummonerName
           });
           break;
         case "BUSY":
           this.DismissTrade();
           JsApiService.Push("game:current:trade:status", (object) "busy");
           break;
         case "DECLINED":
           this.DismissTrade();
           JsApiService.Push("game:current:trade:status", (object) "declined");
           break;
         case "INVALID":
         case "CANCELED":
           this.DismissTrade();
           JsApiService.Push("game:current:trade:request", (object) false);
           break;
       }
     }
   }
   catch
   {
   }
 }
Example #21
0
    internal override bool HandleMessage(MessageReceivedEventArgs args) {
      var lobby = args.Body as LobbyStatus;
      var invite = args.Body as InvitePrivileges;

      if (lobby != null) {
        GotLobbyStatus(lobby);
        return true;
      } else if (invite != null) {
        canInvite = invite.canInvite;
        return true;
      }

      return false;
    }
        private void PVPNet_OnMessageReceived(object sender, MessageReceivedEventArgs message)
        {
            if (message.Body.GetType() == typeof(LcdsServiceProxyResponse))
            {
                var ProxyResponse = message.Body as LcdsServiceProxyResponse;
                HandleProxyResponse(ProxyResponse);
            }
            if (message.Body.GetType() == typeof(GameDTO))
            {
                var ChampDTO = message.Body as GameDTO;
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    if (ChampDTO.GameState == "START_REQUESTED")
                    {
                        // TODO: add fancy notification of game starting
                        QuitButton.IsEnabled = false;
                    }
                }));
            }
            else if (message.Body.GetType() == typeof(PlayerCredentialsDto))
            {
                #region Launching Game

                var dto = message.Body as PlayerCredentialsDto;
                Client.CurrentGame = dto;

                if (!HasLaunchedGame)
                {
                    HasLaunchedGame = true;
                    if (Settings.Default.AutoRecordGames)
                    {
                        Dispatcher.InvokeAsync(async () =>
                        {
                            PlatformGameLifecycleDTO n =
                                await
                                    RiotCalls.RetrieveInProgressSpectatorGameInfo(
                                        Client.LoginPacket.AllSummonerData.Summoner.Name);
                            if (n.GameName != null)
                            {
                                string IP = n.PlayerCredentials.ObserverServerIp + ":" +
                                            n.PlayerCredentials.ObserverServerPort;
                                string Key = n.PlayerCredentials.ObserverEncryptionKey;
                                var GameID = (int)n.PlayerCredentials.GameId;
                                new ReplayRecorder(IP, GameID, Client.Region.InternalName, Key);
                            }
                        });
                    }
                    Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                    {
                        Client.LaunchGame();
                        InGame();
                    }));
                }

                #endregion Launching Game
            }
        }
 private void OnFlexMessageReceived(object sender, MessageReceivedEventArgs args)
 {
     this.OnData(sender as RiotAccount, args.Body);
 }
 private void GotQueuePop(object sender, MessageReceivedEventArgs message)
 {
     if (!Client.HasPopped && message.Body is GameDTO && (message.Body as GameDTO).GameState == "JOINING_CHAMP_SELECT")
     {
         Client.HasPopped = true;
         var Queue = message.Body as GameDTO;
         Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
         {
             Client.OverlayContainer.Content = new QueuePopOverlay(Queue, this).Content;
             Client.OverlayContainer.Visibility = Visibility.Visible;
         }));
     }
     else if (message.Body is GameNotification && (message.Body as GameNotification).Type == "PLAYER_QUIT")
     {
         setStartButtonText("Start Game");
         inQueue = false;
         Client.GameStatus = "outOfGame";
         Client.SetChatHover();
         Dispatcher.Invoke(() =>
         {
             Client.inQueueTimer.Visibility = Visibility.Hidden;
             TeamListView.Opacity = 1D;
         });
     }
 }
Example #25
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); };
                        }
                    }
                }
            }));
        }
 void client_MessageReceived(object sender, MessageReceivedEventArgs e)
 {
     ;
 }
 private void Update_OnMessageReceived(object sender, MessageReceivedEventArgs message)
 {
     if (message.Body.GetType() == typeof(LobbyStatus))
     {
         var Lobby = message.Body as LobbyStatus;
         CurrentLobby = Lobby;
         RenderLobbyData();
     }
     else if (message.Body is GameDTO)
     {
         var QueueDTO = message.Body as GameDTO;
         Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
         {
             if (QueueDTO.GameState == "TERMINATED")
             {
                 Client.HasPopped = false;
                 Client.RiotConnection.MessageReceived += GotQueuePop;
             }
         }));
     }
     else if (message.Body is GameNotification)
     {
         Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
         {
             setStartButtonText("Start Game");
             inQueue = false;
             Client.inQueueTimer.Visibility = Visibility.Hidden;
         }));
     }
     else if (message.Body is SearchingForMatchNotification)
     {
         Dispatcher.BeginInvoke(DispatcherPriority.Input,
             new ThreadStart(() => { EnteredQueue(message.Body as SearchingForMatchNotification); }));
     }
     else if (message.Body is InvitePrivileges)
     {
         Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
         {
             var priv = message.Body as InvitePrivileges;
             if (priv.canInvite)
             {
                 var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd);
                 tr.Text = "You may invite players to this game." + Environment.NewLine;
                 tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow);
                 InviteButton.IsEnabled = true;
             }
             else
             {
                 var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd);
                 tr.Text = "You may no longer invite players to this game." + Environment.NewLine;
                 tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow);
                 InviteButton.IsEnabled = false;
             }
         }));
     }
     else if (message.Body is LcdsServiceProxyResponse)
     {
         parseLcdsMessage(message.Body as LcdsServiceProxyResponse); //Don't look there, its ugly!!! :)))
     }
 }
        private void OnMessageReceived(object sender, MessageReceivedEventArgs message)
        {
            if (message.Body.GetType() == typeof(GameDTO))
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    GameDTO QueueDTO = message.Body as GameDTO;
                    if (QueueDTO.GameState == "TERMINATED" || QueueDTO.GameState == "TERMINATED_IN_ERROR")
                    {
                        Client.OverlayContainer.Visibility = Visibility.Hidden;
                        Client.RtmpConnection.MessageReceived -= OnMessageReceived;
                        Client.IsInGame = false;
                        return;
                    }
                    else if (QueueDTO.GameState == "CHAMP_SELECT")
                    {
                        HasStartedChampSelect = true;
                        Client.RtmpConnection.MessageReceived -= OnMessageReceived;
                        string s = QueueDTO.GameState;
                        Client.ChampSelectDTO = QueueDTO;
                        Client.GameID = QueueDTO.Id;
                        Client.ChampSelectDTO = QueueDTO;
                        Client.LastPageContent = Client.Container.Content;
                        Client.OverlayContainer.Visibility = Visibility.Hidden;
                        Client.SwitchPage(new ChampSelectPage());
                    }

                    int i = 0;
                    string PlayerParticipantStatus = (string)QueueDTO.StatusOfParticipants;
                    if (ReverseString)
                    {
                        string FirstHalf = PlayerParticipantStatus.Substring(0, PlayerParticipantStatus.Length / 2);
                        string SecondHalf = PlayerParticipantStatus.Substring(PlayerParticipantStatus.Length / 2, PlayerParticipantStatus.Length / 2);
                        PlayerParticipantStatus = SecondHalf + FirstHalf;
                    }
                    foreach (char c in PlayerParticipantStatus)
                    {
                        if (c == '1') //If checked
                        {
                            QueuePopPlayer player = null;
                            if (i < (PlayerParticipantStatus.Length / 2)) //Team 1
                            {
                                player = (QueuePopPlayer)Team1ListBox.Items[i];
                            }
                            else //Team 2
                            {
                                player = (QueuePopPlayer)Team2ListBox.Items[i - (PlayerParticipantStatus.Length / 2)];
                            }
                            player.ReadyCheckBox.IsChecked = true;
                            player.ReadyCheckBox.Foreground = System.Windows.Media.Brushes.Green;
                        }
                        else if (c == '2')
                        {
                            QueuePopPlayer player = null;
                            if (i < (PlayerParticipantStatus.Length / 2)) //Team 1
                            {
                                player = (QueuePopPlayer)Team1ListBox.Items[i];
                            }
                            else //Team 2
                            {
                                player = (QueuePopPlayer)Team2ListBox.Items[i - (PlayerParticipantStatus.Length / 2)];
                            }
                            player.ReadyCheckBox.IsChecked = null;
                            player.ReadyCheckBox.Foreground = System.Windows.Media.Brushes.Red;
                        }
                        i++;
                    }
                }));
            }
        }