public EndOfGamePage(EndOfGameStats statistics)
 {
     InitializeComponent();
     RenderStats(statistics);
     Client.SwitchPage(Client.MainPage);
     Client.runonce = false;
     Client.ChampId = -1;
     RoomJid = Client.GetChatroomJid(statistics.RoomName, statistics.RoomPassword, false);
     
     newRoom = new MucManager(Client.XmppConnection);
     Client.XmppConnection.OnMessage += XmppConnection_OnMessage;
     Client.XmppConnection.OnPresence += XmppConnection_OnPresence;
     Client.RiotConnection.MessageReceived += RiotConnection_MessageReceived;
     newRoom.AcceptDefaultConfiguration(new Jid(RoomJid));
     newRoom.JoinRoom(new Jid(RoomJid), Client.LoginPacket.AllSummonerData.Summoner.Name);
 }
 public GroupChatItem(string id, string title)
 {
     InitializeComponent();
     ChatId = id;
     PlayerLabelName.Content = title;
     GroupTitle = title;
     if (ChatId == null)
         return;
     try
     {
         newRoom = new MucManager(Client.XmppConnection);
     }
     catch
     {
         return;
     }
     Client.XmppConnection.OnPresence += XmppConnection_OnPresence;
     Client.XmppConnection.OnMessage += XmppConnection_OnMessage;
     newRoom.AcceptDefaultConfiguration(new Jid(ChatId));
     roomName = ChatId;
     newRoom.JoinRoom(new Jid(ChatId), Client.LoginPacket.AllSummonerData.Summoner.Name);
 }
Exemple #3
0
        private void XmppOnOnLogin(object sender)
        {
            myPresence.Type = PresenceType.available;
            MucManager = new MucManager(Xmpp);
			Jid room = new Jid("lobby@conference." + Host);
            MucManager.AcceptDefaultConfiguration(room);
            MucManager.JoinRoom(room,Username,Password,false);
            Me = new NewUser(Xmpp.MyJID);

            if(OnLoginComplete != null)
                OnLoginComplete.Invoke(this,LoginResults.Success);
        }
        private void Lobby_OnMessageReceived(object sender, object message)
        {
            if (message == null)
                return;

            if (message.GetType() != typeof(GameDTO))
                return;

            var dto = message as GameDTO;
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
            {
                if (!HasConnectedToChat)
                {
                    //Run once
                    BaseMap map = BaseMap.GetMap(dto.MapId);
                    MapLabel.Content = map.DisplayName;
                    ModeLabel.Content = Client.TitleCaseString(dto.GameMode);
                    GameTypeConfigDTO configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId);
                    TypeLabel.Content = GetGameMode(configType.Id);
                    SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2;

                    HasConnectedToChat = true;

                    string obfuscatedName = Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt64(dto.Id), ChatPrefixes.Arranging_Practice);
                    string Jid = Client.GetChatroomJid(obfuscatedName, dto.RoomPassword, false);
                    newRoom = new MucManager(Client.XmppConnection);
                    Client.XmppConnection.OnMessage +=XmppConnection_OnMessage;
                    Client.XmppConnection.OnPresence += XmppConnection_OnPresence;
                    roomJid = new Jid(Jid);
                    newRoom.AcceptDefaultConfiguration(roomJid);
                    newRoom.JoinRoom(roomJid, Client.LoginPacket.AllSummonerData.Summoner.Name);
                }
                switch (dto.GameState)
                {
                    case "TEAM_SELECT":
                        {
                            bool isSpectator = false;
                            OptomisticLock = dto.OptimisticLock;
                            LaunchedTeamSelect = false;
                            BlueTeamListView.Items.Clear();
                            PurpleTeamListView.Items.Clear();
                            SpectatorListView.Items.Clear();

                            foreach (Participant playerTeam in dto.TeamOne)
                            {
                                if (playerTeam is PlayerParticipant)
                                {
                                    var lobbyPlayer = new CustomLobbyPlayer();
                                    var player = playerTeam as PlayerParticipant;
                                    lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId);
                                    Client.isOwnerOfGame = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId;
                                    StartGameButton.IsEnabled = Client.isOwnerOfGame;
                                    AddBotBlueTeam.IsEnabled = Client.isOwnerOfGame;
                                    AddBotPurpleTeam.IsEnabled = Client.isOwnerOfGame;

                                    BlueTeamListView.Items.Add(lobbyPlayer);

                                    if (Client.Whitelist.Count <= 0)
                                        continue;

                                    if (!Client.Whitelist.Contains(player.SummonerName.ToLower()))
                                        await RiotCalls.BanUserFromGame(Client.GameID, player.AccountId);
                                }
                                else if (playerTeam is BotParticipant)
                                {
                                    var botParticipant = playerTeam as BotParticipant;
                                    var botPlayer = new BotControl();
                                    botPlayer = RenderBot(botParticipant);
                                    BlueTeamListView.Items.Add(botPlayer);
                                }
                            }
                            foreach (Participant playerTeam in dto.TeamTwo)
                            {
                                if (playerTeam is PlayerParticipant)
                                {
                                    var lobbyPlayer = new CustomLobbyPlayer();
                                    var player = playerTeam as PlayerParticipant;
                                    lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId);
                                    Client.isOwnerOfGame = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId;
                                    StartGameButton.IsEnabled = Client.isOwnerOfGame;
                                    AddBotBlueTeam.IsEnabled = Client.isOwnerOfGame;
                                    AddBotPurpleTeam.IsEnabled = Client.isOwnerOfGame;

                                    PurpleTeamListView.Items.Add(lobbyPlayer);

                                    if (Client.Whitelist.Count <= 0)
                                        continue;

                                    if (!Client.Whitelist.Contains(player.SummonerName.ToLower()))
                                        await RiotCalls.BanUserFromGame(Client.GameID, player.AccountId);
                                }
                                else if (playerTeam is BotParticipant)
                                {
                                    var botParticipant = playerTeam as BotParticipant;
                                    var botPlayer = new BotControl();
                                    botPlayer = RenderBot(botParticipant);
                                    PurpleTeamListView.Items.Add(botPlayer);
                                }
                            }
                            foreach (GameObserver observer in dto.Observers)
                            {
                                if (observer.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId)
                                    isSpectator = true;

                                var spectatorItem = new CustomLobbyObserver();

                                spectatorItem = RenderObserver(observer);
                                SpectatorListView.Items.Add(spectatorItem);
                            }
                            if (isSpectator)
                            {
                                AddBotPurpleTeam.Visibility = Visibility.Hidden;
                                AddBotBlueTeam.Visibility = Visibility.Hidden;
                                JoinBlueTeamFromSpectator.Visibility = Visibility.Visible;
                                JoinPurpleTeamFromSpectator.Visibility = Visibility.Visible;
                            }
                            else
                            {
                                AddBotPurpleTeam.Visibility = Visibility.Visible;
                                AddBotBlueTeam.Visibility = Visibility.Visible;
                                JoinBlueTeamFromSpectator.Visibility = Visibility.Hidden;
                                JoinPurpleTeamFromSpectator.Visibility = Visibility.Hidden;
                            }
                        }
                        break;
                    case "PRE_CHAMP_SELECT":
                    case "CHAMP_SELECT":
                        if (!LaunchedTeamSelect)
                        {
                            Client.ChampSelectDTO = dto;
                            Client.LastPageContent = Client.Container.Content;
                            Client.SwitchPage(new ChampSelectPage(dto.RoomName, dto.RoomPassword).Load(this));
                            Client.GameStatus = "championSelect";
                            Client.SetChatHover();
                            LaunchedTeamSelect = true;
                        }
                        break;
                }
            }));
        }
 public ChampSelectPage(string RoomName, string RoomPassword)
 {
     InitializeComponent();
     var Jid = Client.GetChatroomJid(RoomName.Replace("@sec", ""), RoomPassword, false);
     jid = new Jid(Jid);
     Chatroom = new MucManager(Client.XmppConnection);
     Client.XmppConnection.OnMessage += XmppConnection_OnMessage;
     Client.XmppConnection.OnPresence += XmppConnection_OnPresence;
     Chatroom.AcceptDefaultConfiguration(jid);
     Chatroom.JoinRoom(jid, Client.LoginPacket.AllSummonerData.Summoner.Name, RoomPassword);
 }
Exemple #6
0
 private static void XmppOnOnLogin(object sender)
 {
     Trace.WriteLine("[Bot]Login:"******"*****@*****.**");
     muc.AcceptDefaultConfiguration(room);
     muc.JoinRoom(room, Xmpp.Username, Xmpp.Password, false);
 }
        private void Lobby_OnMessageReceived(object sender, object message)
        {
            if (message.GetType() != typeof(GameDTO))
                return;

            var dto = message as GameDTO;
            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () =>
            {
                if (!HasConnectedToChat)
                {
                    //Run once
                    BaseMap map = BaseMap.GetMap(dto.MapId);
                    MapLabel.Content = map.DisplayName;
                    ModeLabel.Content = Client.TitleCaseString(dto.GameMode);
                    GameTypeConfigDTO configType =
                        Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId);
                    TypeLabel.Content = GetGameMode(configType.Id);
                    SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2;

                    HasConnectedToChat = true;
                    string obfuscatedName =
                        Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt32(dto.Id),
                            ChatPrefixes.Arranging_Practice);
                    string Jid = Client.GetChatroomJid(obfuscatedName, dto.RoomPassword, false);
                    newRoom = new MucManager(Client.XmppConnection);
                    Client.XmppConnection.OnMessage += XmppConnection_OnMessage;
                    Client.XmppConnection.OnPresence += XmppConnection_OnPresence;
                    jid = new Jid(dto.RoomName);
                    newRoom.AcceptDefaultConfiguration(jid);
                    newRoom.JoinRoom(jid, Client.LoginPacket.AllSummonerData.Summoner.Name, dto.RoomPassword);
                }
                switch (dto.GameState)
                {
                    case "TEAM_SELECT":
                        {
                            OptomisticLock = dto.OptimisticLock;
                            LaunchedTeamSelect = false;
                            BlueTeamListView.Items.Clear();
                            PurpleTeamListView.Items.Clear();

                            var allParticipants = new List<Participant>(dto.TeamOne.ToArray());
                            allParticipants.AddRange(dto.TeamTwo);

                            int i = 0;
                            bool purpleSide = false;

                            foreach (Participant playerTeam in allParticipants)
                            {
                                i++;
                                var lobbyPlayer = new CustomLobbyPlayer();
                                //var botPlayer = new BotControl();
                                if (playerTeam is PlayerParticipant)
                                {
                                    var player = playerTeam as PlayerParticipant;
                                    lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId);
                                    ///BotParticipant botParticipant = playerTeam as BotParticipant;
                                    //botPlayer = RenderBot(botParticipant);
                                    IsOwner = dto.OwnerSummary.SummonerId ==
                                              Client.LoginPacket.AllSummonerData.Summoner.SumId;
                                    StartGameButton.IsEnabled = IsOwner;

                                    if (Client.Whitelist.Count > 0)
                                        if (!Client.Whitelist.Contains(player.SummonerName.ToLower()))
                                            await RiotCalls.BanUserFromGame(Client.GameID, player.AccountId);
                                }

                                if (i > dto.TeamOne.Count)
                                {
                                    i = 0;
                                    purpleSide = true;
                                }

                                if (!purpleSide)
                                    BlueTeamListView.Items.Add(lobbyPlayer);
                                else
                                    PurpleTeamListView.Items.Add(lobbyPlayer);
                            }
                        }
                        break;
                    case "PRE_CHAMP_SELECT":
                    case "CHAMP_SELECT":
                        if (!LaunchedTeamSelect)
                        {
                            Client.ChampSelectDTO = dto;
                            Client.LastPageContent = Client.Container.Content;
                            Client.SwitchPage(new ChampSelectPage(dto.RoomName, dto.RoomPassword).Load(this));
                            LaunchedTeamSelect = true;
                        }
                        break;
                }
            }));
        }
Exemple #8
0
 private void XmppOnOnLogin(object sender)
 {
     MucManager = new MucManager(Xmpp);
     Jid room = new Jid("*****@*****.**");
     MucManager.AcceptDefaultConfiguration(room);
     MucManager.JoinRoom(room,Username,Password,false);
     Me = new NewUser(Xmpp.MyJID);
     if(OnLoginComplete != null)
         OnLoginComplete.Invoke(this,LoginResults.Success);
 }
Exemple #9
0
 private void OnLoginEvent(object sender)
 {
     Logger.Info("Connected to {0}!", Connection.Server);
     Connection.SendMyPresence();
     MucManager mucManager = new MucManager(Connection);
     Room = new Jid(Config["conference"] as String);
     mucManager.AcceptDefaultConfiguration(Room);
     mucManager.JoinRoom(Room, Config["nickname"] as String);
     Presence p = new Presence(ShowType.chat, "Online");
     p.Type = PresenceType.available;
     Connection.Send(p);
     Task.Factory.StartNew(() => {
             Thread.Sleep(1000);
             Logger.Info("Start accepting messages...");
             Connection.OnMessage += new MessageHandler(OnMessage);
         });
 }
        public async void LoadStats()
        {
            i = 10;
            PingTimer = new Timer(1000);
            PingTimer.Elapsed += PingElapsed;
            PingTimer.Enabled = true;
            PingElapsed(1, null);
            InviteButton.IsEnabled = false;
            StartGameButton.IsEnabled = false;

            if (CurrentLobby == null)
            {
                CurrentLobby = await RiotCalls.AcceptInvite(Invite);
            }
            if (CurrentLobby.InvitationID != null)
            {
                string ObfuscatedName =
                    Client.GetObfuscatedChatroomName(CurrentLobby.InvitationID.ToLower(),
                        ChatPrefixes.Arranging_Game);
                string Jid = Client.GetChatroomJid(ObfuscatedName, CurrentLobby.ChatKey, false);
                newRoom = new MucManager(Client.XmppConnection);
                jid = new Jid(Jid);
                Client.XmppConnection.OnMessage += XmppConnection_OnMessage;
                Client.XmppConnection.OnPresence += XmppConnection_OnPresence;
                newRoom.AcceptDefaultConfiguration(jid);
                newRoom.JoinRoom(jid, Client.LoginPacket.AllSummonerData.Summoner.Name, CurrentLobby.ChatKey);
                RenderLobbyData();
            }
            else
            {
                Client.GameStatus = "outOfGame";
                Client.SetChatHover();
                Client.SwitchPage(Client.MainPage);
                Client.ClearPage(typeof(TeamQueuePage));
                Client.Log("Failed to join room.");
            }
        }
 /// <summary>
 ///     Use this to connect to chat
 /// </summary>
 /// <param name="ChatJid"></param>
 /// <param name="Pass"></param>
 private void ConnectToChat(string ChatJid, string Pass)
 {
     string Jid = Client.GetChatroomJid(ChatJid, Pass, false);
     newRoom = new MucManager(Client.XmppConnection);
     Client.XmppConnection.OnMessage += XmppConnection_OnMessage;
     Client.XmppConnection.OnPresence += XmppConnection_OnPresence;
     jid = new Jid(ChatJid);
     newRoom.AcceptDefaultConfiguration(jid);
     newRoom.JoinRoom(jid, Client.LoginPacket.AllSummonerData.Summoner.Name, Pass);
     connectedToChat = true;
 }