Beispiel #1
0
 public void AddRoomUser(string playerName, string connectionId, bool isHost = false)
 {
     RoomUsers.Add(new RoomUser()
     {
         Name = playerName, ConnectionId = connectionId, IsHost = isHost
     });
 }
        public static bool IsDuplicateUser(string username)
        {
            var Username = RoomUsers.FirstOrDefault(a => a.Equals(username));

            if (string.IsNullOrEmpty(Username))
            {
                return(false);
            }
            return(true);
        }
        // Call the Worker thread to load the list of rooms for the connected project service uri
        private void LoadRooms()
        {
            try
            {
                TeamRoomWindowCommand.Instance.LogMessage("Loading Rooms");

                RoomUsers.Clear();
                teamRoom = null;
                Rooms.Clear();
                cmbRoomList.Text = "Loading Team Rooms...";
                if (projectCollectionUri != null)
                {
                    RoomWorker.Instance.LoadRooms(projectCollectionUri);
                }
            }
            catch (Exception ex) {
                throw;
            }
        }
        // Set the background worker to poll for messages for the selected room.
        private void cmbRoomList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                // Clear messages and Room Users
                messages.Clear();
                RefreshMessages();

                RoomUsers.Clear();
                RefreshRoomUsers();

                int oldRoomId = teamRoom == null ? 0 : teamRoom.Id;

                if (cmbRoomList.SelectedValue == null || projectCollectionUri == null)
                {
                    return;
                }

                teamRoom = cmbRoomList.SelectedValue as Room;
                if (teamRoom != null)
                {
                    SignIntoRoom(oldRoomId, teamRoom.Id);

                    TfsMonitor.Instance.DoWork(projectCollectionUri, teamRoom.Id);
                    RoomWorker.Instance.PollRoomUsers(projectCollectionUri, teamRoom.Id, PollRoomUsers_NewUsers, PollRoomUsers_Complete);

                    var settings = new ExtensionSettings {
                        ProjectCollectionUri = projectCollectionUri, TeamRoomId = teamRoom.Id
                    };

                    TeamRoomWindowCommand.Instance.SaveUserSettings(settings);
                }
            }
            catch (Exception ex)
            {
                // Log errors
                TeamRoomWindowCommand.Instance.LogError(ex);
            }
        }
        private void LoadRoomUsers(TeamRoomUsers roomUsers)
        {
            if ((teamRoom != null && roomUsers.RoomId != teamRoom.Id) || roomUsers.ConnectionUri != projectCollectionUri)
            {
                return;
            }

            RoomUsers.Clear();

            if (roomUsers.Users != null)
            {
                foreach (var item in roomUsers.Users.Where(x => x.IsOnline))
                {
                    if (!UserWorker.Instance.ProfileImages.ContainsKey(item.UserRef.Id))
                    {
                        var profileImages = TfsServiceWrapper.GetUserProfileImages(new List <IdentityRef> {
                            item.UserRef
                        });
                        UserWorker.Instance.GetProfiles(profileImages);
                    }
                    RoomUsers.Add(item);
                }
            }
        }
        private void cmbCollectionList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                Messages.Clear();
                RefreshMessages();
                RoomUsers.Clear();
                RefreshRoomUsers();

                var projectCollection = cmbCollectionList.SelectedValue as RegisteredProjectCollection;
                if (projectCollection != null)
                {
                    projectCollectionUri = projectCollection.Uri;
                }
                LoadRooms();
                TeamRoomWindowCommand.Instance.SaveUserSettings(new ExtensionSettings {
                    TeamRoomId = teamRoom != null ? teamRoom.Id : 0, ProjectCollectionUri = projectCollection.Uri
                });
            }
            catch (Exception)
            {
                throw;
            }
        }
Beispiel #7
0
 public bool IsHost(string connectionId)
 {
     return(RoomUsers.FirstOrDefault(m => m.ConnectionId == connectionId).IsHost);
 }
Beispiel #8
0
 public void RemoveRoomUserByConnectionId(string connectionId)
 {
     RoomUsers.Remove(RoomUsers.FirstOrDefault(m => m.ConnectionId == connectionId));
 }
 public static void AddUserToRoom(string username)
 {
     RoomUsers.Add(username);
 }