GetUserCount() public method

public GetUserCount ( ) : int
return int
Example #1
0
 public SessionData(Session s)
 {
     SessionName = s.GetName().ToString();
     SessionUserCount = s.GetUserCount().ToString();
     SessionType = s.GetSessionType().ToString();
     _users = new List<User>();
     for (var i = 0; i < s.GetUserCount(); i++)
     {
         _users.Add(s.GetUser(i));
     }
     UpdateUserNames();
 }
Example #2
0
        private void OnCurrentUserJoinedSession(Session joinedSession)
        {
            //Debug.LogFormat("Joining session {0}.", joinedSession.GetName());

            // If joining a new session, any user in the previous session (if any) have left
            ClearCurrentSession();

            // Send a join event for every user currently in the session we joined
            for (int i = 0; i < joinedSession.GetUserCount(); i++)
            {
                User user = joinedSession.GetUser(i);
                CurrentUsers.Add(user);
                UserJoined.RaiseEvent(user);;
            }
        }
Example #3
0
        void Update()
        {
            // Get an instance of the SessionManager if one does not exist.
            if (sessionManager == null && SharingStage.Instance != null && SharingStage.Instance.Manager != null)
            {
                this.sessionManager = SharingStage.Instance.Manager.GetSessionManager();
            }

            // Only poll every second.
            if (Time.frameCount % pollingFrequency == 0 && this.sessionManager != null && sessionManager.GetSessionCount() > 0)
            {
                Session currentSession = this.sessionManager.GetCurrentSession();
                if (currentSession != null)
                {
                    int userCount = currentSession.GetUserCount();

                    // If we have fewer users in the current session than are
                    // tracked locally then one or more users have exited.
                    // We need to figure out which ones.
                    if (userCount < userIds.Count)
                    {
                        // Gather all of the new users into a new array.
                        List <long> updatedUserIds = new List <long>();

                        for (int index = 0; index < userCount; index++)
                        {
                            User user   = currentSession.GetUser(index);
                            long userId = user.GetID();
                            updatedUserIds.Add(userId);
                            Debug.Log(index + ": id: " + user.GetID() + " or: " + userId);

                            // It's an edge case, but if a user joins and a user exits at the same
                            // time, we need to handle that.
                            if (userIds.Contains(userId) == false)
                            {
                                SendJoinEvent(user);
                            }
                        }

                        // Now check to see which IDs are in the old userIds list, but not in the new updatedUserIds list.
                        for (int index = 0; index < userIds.Count; index++)
                        {
                            if (updatedUserIds.Contains(userIds[index]) == false)
                            {
                                SendLeaveEvent(userIds[index]);
                            }
                        }

                        userIds = updatedUserIds;
                    }
                    else // Same or more users in the session.
                    {
                        for (int index = 0; index < userCount; index++)
                        {
                            User user   = currentSession.GetUser(index);
                            long userId = user.GetID();
                            if (userIds.Contains(userId) == false)
                            {
                                userIds.Add(userId);
                                SendJoinEvent(user);
                            }
                        }
                    }
                }
            }
        }