Ejemplo n.º 1
0
        //static void xmpp_OnReadXml(object sender, string xml)
        //{
        //    Console.Write("--------xml--------");
        //    Console.Write(xml);
        //    Console.Write(sender);
        //    Console.Write("--------xml--------");
        //   // throw new NotImplementedException();
        //}


        /*
         *
         * Create room
         *
         */
        private static void CreateRoom()
        {
            MucManager muc     = new MucManager(xmpp);
            Jid        RoomJid = new Jid("[email protected]");

            muc.CreateReservedRoom(RoomJid, new IqCB(OnCreateRoom));
            muc.JoinRoom(RoomJid, "[email protected]");
            muc.JoinRoom(RoomJid, "[email protected]");
            muc.JoinRoom(RoomJid, "[email protected]");
            muc.JoinRoom(RoomJid, "[email protected]");
        }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// The xmpp on on registered.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        private void XmppOnOnRegistered(object sender)
        {
            this.myPresence.Type = PresenceType.available;
            this.myPresence.Show = ShowType.chat;
            this.MucManager      = new MucManager(this.xmpp);
            var room = new Jid("lobby@conference." + this.Config.ChatHost);

            //this.MucManager.AcceptDefaultConfiguration(room);

            MucManager.JoinRoom(room, Username, Password, false);
            this.Me = new User(this.xmpp.MyJID);
            this.Me.SetStatus(UserStatus.Online);
            this.xmpp.PresenceManager.Subscribe(this.xmpp.MyJID);

            var v = new Vcard();
            var e = new Email {
                UserId = this.email, Type = EmailType.INTERNET, Value = this.email
            };

            v.AddChild(e);
            v.JabberId = new Jid(this.Username + "@" + this.Config.ChatHost);
            var vc = new VcardIq(IqType.set, v);

            vc.To = this.Config.ChatHost;
            vc.GenerateId();
            this.xmpp.Send(vc);
            if (this.OnRegisterComplete != null)
            {
                this.OnRegisterComplete.Invoke(this, RegisterResults.Success);
            }
        }
Ejemplo n.º 4
0
 private void MinimizeButton_Click(object sender, RoutedEventArgs e)
 {
     Client.XmppConnection.OnMessage  -= XmppConnection_OnMessage;
     Client.XmppConnection.OnPresence -= XmppConnection_OnPresence;
     newRoom.JoinRoom(new Jid(ChatId), Client.LoginPacket.AllSummonerData.Summoner.Name);
     Client.ClearMainGrid(typeof(GroupChatItem));
 }
Ejemplo n.º 5
0
 public FormConferention(string _roomJid, string _roomName, bool _savingHistory, bool _persistRoom, string _roomDesc = "", List <string> users = null)
 {
     InitializeComponent();
     roomJid       = new Jid(_roomJid);
     roomName      = _roomName;
     this.Text     = _roomName;
     roomDesc      = _roomDesc;
     mainJid       = Settings.jid;
     nickname      = Settings.nickname;
     xmpp          = Settings.xmpp;
     muc           = new MucManager(xmpp);
     savingHistory = _savingHistory ? "1" : "0";
     persistRoom   = _persistRoom ? "1" : "0";
     //muc.AcceptDefaultConfiguration(roomJid, new IqCB(OnGetFieldsResult));
     muc.CreateReservedRoom(roomJid);
     muc.GrantOwnershipPrivileges(roomJid, new Jid(mainJid));
     muc.JoinRoom(roomJid, nickname);
     initMucConfig();
     xmpp.MesagageGrabber.Add(roomJid, new BareJidComparer(), new MessageCB(MessageCallback), null);
     xmpp.PresenceGrabber.Add(roomJid, new BareJidComparer(), new PresenceCB(PresenceCallback), null);
     muc.Invite(users.ConvertAll <Jid>(
                    delegate(string jid)
     {
         return(new Jid(jid));
     }
                    ).ToArray(), roomJid, "Вы приглашены в конференцию Конф.");
 }
Ejemplo n.º 6
0
        private void XmppOnRosterEnd(object sender)
        {
            // Joins the lobby chat once the connection is ready
            Trace();
            Jid mucFullRoom = new Jid($"lobby@conference.{Server}");

            _muc.JoinRoom(mucFullRoom, Username);
        }
Ejemplo n.º 7
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^)");
 }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
Archivo: Chat.cs Proyecto: uwat79/OCTGN
        /// <summary>
        /// Fires when the XMPP Client receives a message.
        /// </summary>
        /// <param name="sender">
        /// The Sender
        /// </param>
        /// <param name="msg">
        /// The Message
        /// </param>
        private void XmppOnMessage(object sender, Message msg)
        {
            switch (msg.Type)
            {
            case MessageType.normal:
                if (msg.From.Server == "conference." + this.client.Config.ChatHost)
                {
                    string rname = msg.From.User;
                    var    m     = new MucManager(this.xmpp);
                    m.JoinRoom(msg.From, msg.From.User);
                    ChatRoom theRoom = this.GetRoom(new User(msg.From), true);
                    this.xmpp.RosterManager.AddRosterItem(msg.From, msg.From.User);
                }

                break;

            case MessageType.error:
            {
                if (msg.From.User.ToLowerInvariant().Contains("gameserv"))
                {
                    return;
                }
                ChatRoom nc = this.GetRoom(new User(msg.From.Bare), true);
                nc.OnMessage(this, msg);
                break;
            }

            case MessageType.chat:
            {
                switch (msg.Chatstate)
                {
                case Chatstate.None:

                    // TODO Group chat whispers in the form of {roomname}@conference.server.octgn.info/{username} need to be handled here.
                    ChatRoom nc = this.GetRoom(new User(msg.From.Bare));
                    nc.OnMessage(sender, msg);
                    break;
                }

                break;
            }

            case MessageType.groupchat:
            {
                ChatRoom nc = this.GetRoom(new User(msg.From.Bare), true);
                nc.OnMessage(this, msg);
                break;
            }

            case MessageType.headline:
                break;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Joins the specified room.
        /// </summary>
        /// <param name="room">The room.</param>
        /// <returns></returns>
        public bool Join(Room room)
        {
            var manager = new MucManager(connection);

            var jid = new Jid(room.JabberId, "conf.hipchat.com", string.Empty);

            manager.JoinRoom(jid, current.Name);

            Out.WriteLine("{1:HH:mm:ss} Joined room: {0}.", room.Name, DateTime.Now);

            return(true);
        }
Ejemplo n.º 11
0
        void xmpp_OnLogin(object sender)
        {
            MucManager mucManager = new MucManager(_client);

            string[] rooms = _config.Rooms.Split(',');

            foreach (string room in rooms)
            {
                Jid jid = new Jid(room + "@" + _config.ConferenceServer);
                mucManager.JoinRoom(jid, _config.RoomNick);
            }
        }
Ejemplo n.º 12
0
 public FormConferention(string _roomJid)
 {
     InitializeComponent();
     roomJid  = new Jid(_roomJid);
     xmpp     = Settings.xmpp;
     mainJid  = Settings.jid;
     nickname = Settings.nickname;
     muc      = new MucManager(xmpp);
     muc.JoinRoom(roomJid, nickname);
     xmpp.MesagageGrabber.Add(roomJid, new BareJidComparer(), new MessageCB(MessageCallback), null);
     xmpp.PresenceGrabber.Add(roomJid, new BareJidComparer(), new PresenceCB(PresenceCallback), null);
 }
Ejemplo n.º 13
0
        private void OnLogin(object sender)
        {
            var mucManager = new MucManager(_client);

            var rooms = Robot.Settings.Get("HipChatRooms").Split(',');

            var roomJids = rooms.Select(room => new Jid(room + "@" + _conferenceServer));

            foreach (var jid in roomJids)
            {
                mucManager.JoinRoom(jid, Robot.Settings.Get("HipChatRoomNick"));
                JoinedRoomJids.Add(jid);
            }
        }
Ejemplo n.º 14
0
        private void OnClientLogin(object sender)
        {
            var mucManager = new MucManager(_client);

            foreach (string room in _rooms.Union(_logRooms).Distinct())
            {
                var jid = new Jid(room + "@" + _confhost);
                mucManager.JoinRoom(jid, _roomNick);
                Rooms.Add(room);
                Logger.Info(string.Format("Joined Room '{0}'", room));
            }
            foreach (string logRoom in _logRooms)
            {
                LogRooms.Add(logRoom);
            }
        }
Ejemplo n.º 15
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);
        }
Ejemplo n.º 16
0
        private void OnClientLogin(object sender)
        {
            var mucManager = new MucManager(_client);

            var rooms = _api.GetAllRooms();

            foreach (var room in rooms.Items)
            {
                var roomInfo = _api.GetRoom(room.Id);

                var jid = new Jid(roomInfo.XmppJid);
                mucManager.JoinRoom(jid, _botUser.Name);
                Rooms.Add(room.Name);
                LogRooms.Add(room.Name);
                Logger.Info(string.Format("Joined Room '{0}'", room.Name));
            }
        }
Ejemplo n.º 17
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);
            }
        }
Ejemplo n.º 18
0
        private void OnClientLogin(object sender)
        {
            var mucManager = new MucManager(_client);

            var rooms = _api.GetAllRooms();

            foreach (var room in rooms.Items.Where(r => _roomList.Count == 0 || r.Name != null && _roomList.Contains(r.Name.ToUpper())))
            {
                var roomInfo = _api.GetRoom(room.Id);

                _roomMap.Add(roomInfo.XmppJid, room.Id);

                var jid = new Jid(roomInfo.XmppJid);
                mucManager.JoinRoom(jid, _botUser.Name);
                Rooms.Add(room.Name);
                LogRooms.Add(room.Name);
                Logger.Info(string.Format("Joined Room '{0}'", room.Name));
            }
        }
Ejemplo n.º 19
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.");
            }
        }
Ejemplo n.º 20
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);
 }
Ejemplo n.º 21
0
 //Handles incoming messages
 static void MessageCallBack(object sender,
                             agsXMPP.protocol.client.Message msg,
                             object data)
 {
     if (msg.Body != null)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("{0}>> {1}", msg.From.User, msg.Body);
         Console.ForegroundColor = ConsoleColor.Green;
     }
     else
     {
         try
         {
             Console.WriteLine(msg.FirstChild.GetAttributeJid("jid"));
             MucManager _manager = new MucManager(xmpp);
             _manager.JoinRoom(msg.FirstChild.GetAttributeJid("jid"), "test");
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
         }
     }
 }
Ejemplo n.º 22
0
        public override Task Run()
        {
            _loginTcs = new TaskCompletionSource <bool>();
            Task <bool> connect = _loginTcs.Task;

            if (_xmppConnection != null)
            {
                _xmppConnection.Close();
                _xmppConnection = null;
            }
            _xmppConnection = new XmppClientConnection
            {
                Server                   = _host,
                ConnectServer            = _connectHost,
                AutoResolveConnectServer = true,
                Username                 = _username,
                Password                 = _password
            };
            if (_port > 0)
            {
                _xmppConnection.Port = _port;
            }

            _xmppConnection.KeepAlive = true;

            _xmppConnection.OnLogin      += OnLogin;
            _xmppConnection.OnError      += OnError;
            _xmppConnection.OnMessage    += OnMessage;
            _xmppConnection.OnPresence   += XmppConnectionOnOnPresence;
            _xmppConnection.OnRosterItem += OnClientRosterItem;
            _xmppConnection.OnXmppConnectionStateChanged += OnXmppConnectionStateChanged;

            Task.Factory.StartNew(() =>
            {
                _xmppConnection.Open();
                Thread.Sleep(CONNECT_TIMEOUT);
                _loginTcs.TrySetResult(false);
            });

            if (!connect.Result)
            {
                throw new TimeoutException("XMPP adapter timed out while trying to login");
            }
            else
            {
                MucManager muc = new MucManager(_xmppConnection);
                foreach (var room in _rooms)
                {
                    try
                    {
                        muc.JoinRoom(string.Format("{0}@{1}", room, _confServer), _username, _password, true);
                        Logger.Info(string.Format("Successfully joined room {0}", room));
                        Rooms.Add(string.Format("{0}@{1}", room, _confServer));
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Failed to join room - " + ex.Message);
                    }
                }

                foreach (var logroom in _logRooms)
                {
                    try
                    {
                        muc.JoinRoom(string.Format("{0}@{1}", logroom, _confServer), _username, _password, true);
                        Logger.Info(string.Format("Successfully joined room {0}", logroom));
                        LogRooms.Add(string.Format("{0}@{1}", logroom, _confServer));
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Failed to join room - " + ex.Message);
                    }
                }
            }

            return(_loginTcs.Task);
        }
Ejemplo n.º 23
0
        private void XmppOnOnMessage(object sender, Message msg)
        {
            switch (msg.Type)
            {
            case MessageType.normal:
                if (msg.From.Server == "conference." + Skylabs.Lobby.Client.Host)
                {
                    var        rname = msg.From.User;
                    MucManager m     = new MucManager(_xmpp);
                    m.JoinRoom(msg.From, msg.From.User);
                    var theRoom = GetRoom(new NewUser(msg.From), true);
                    _xmpp.RosterManager.AddRosterItem(msg.From, msg.From.User);
                    if (OnCreateRoom != null)
                    {
                        OnCreateRoom.Invoke(this, theRoom);
                    }
                }
                break;

            case MessageType.error:
            {
                var nc = GetRoom(new NewUser(msg.From.Bare), true);
                nc.OnMessage(this, msg);
                break;
            }

            case MessageType.chat:
            {
                switch (msg.Chatstate)
                {
                case Chatstate.None:
                    //TODO Group chat whispers in the form of {roomname}@conference.server.octgn.info/{username} need to be handled here.
                    var nc = GetRoom(new NewUser(msg.From.Bare));
                    nc.OnMessage(sender, msg);
                    break;

                case Chatstate.active:

                    break;

                case Chatstate.inactive:
                    break;

                case Chatstate.composing:
                    break;

                case Chatstate.gone:
                    break;

                case Chatstate.paused:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                break;
            }

            case MessageType.groupchat:
            {
                var nc = GetRoom(new NewUser(msg.From.Bare), true);
                nc.OnMessage(this, msg);
                break;
            }

            case MessageType.headline:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 24
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;
                }
            }));
        }
Ejemplo n.º 25
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;
                }
            }));
        }
Ejemplo n.º 26
0
 public void Join(string roomJid)
 {
     _muc.JoinRoom(roomJid, _connection.Username);
 }
Ejemplo n.º 27
0
        static void Lobby_OnRoomJoin(object sender, LobbyControl.RoomJoinEventArgs e)
        {
            MucManager.JoinRoom(new Jid(e.HipchatRoom.RoomId), Name);

            Window.CreateRoom(e.HipchatRoom.Name);
        }