示例#1
0
 private void JoinChatRoom()
 {
     _chatJid  = new Jid(string.Format("pu~{0}@lvl.pvp.net", Hasher.Hash(_room)));
     _chatroom = new MucManager(_connection);
     _chatroom.AcceptDefaultConfiguration(_chatJid);
     _chatroom.JoinRoom(_chatJid, _connection.Username);
     _connection.SendMyPresence();
     SendMessage("Benebot V3 Alpha 8^)");
 }
示例#2
0
 public void JoinRoom(Jid jid, string pass = null)
 {
     lobby.AcceptDefaultConfiguration(jid);
     if (pass == null)
     {
         lobby.JoinRoom(jid, Session.Current.Account.Name, false);
     }
     else
     {
         lobby.JoinRoom(jid, Session.Current.Account.Name, pass, false);
     }
 }
示例#3
0
        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);
        }
示例#4
0
        private void XmppOnOnLogin(object sender)
        {
            myPresence.Type = PresenceType.available;
            myPresence.Show = ShowType.chat;
            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);
            Me.SetStatus(UserStatus.Online);
            Xmpp.PresenceManager.Subscribe(Xmpp.MyJID);
            if (OnLoginComplete != null)
            {
                OnLoginComplete.Invoke(this, LoginResults.Success);
            }
        }
示例#5
0
        private Guid JoinRoom(Jid jid, string password)
        {
            muc.AcceptDefaultConfiguration(jid);
            if (password == null)
            {
                muc.JoinRoom(jid, session.Me.Name, false);
            }
            else
            {
                muc.JoinRoom(jid, session.Me.Name, password, false);
            }
            var id = Guid.NewGuid();

            roomsReverse[jid.User] = id;
            rooms[id] = jid;
            users[id] = new HashSet <string>();
            return(id);
        }
示例#6
0
        private void OnLogin(object sender)
        {
            robot.Log.Debug("XMPP login success");
            client.Status = "BadaBingBot!";
            client.Show   = ShowType.chat;
            client.SendMyPresence();
            AddIgnore(client.MyJID.ToString());

            foreach (var room in config.Rooms)
            {
                var nickname = room.Nickname ?? config.Username;
                var roomJid  = new Jid(room.Jid);
                AddIgnore(room.Jid + "/" + nickname);

                chatManager.JoinRoom(roomJid, nickname, room.Password, true);
                chatManager.AcceptDefaultConfiguration(roomJid);
            }
        }
示例#7
0
        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.");
            }
        }
示例#8
0
 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);
 }
示例#9
0
        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.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;
                    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;
                }
            }));
        }
示例#10
0
        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;
                }
            }));
        }