private void OnUserJoined(Session session, User newUser)
        {
            UserJoined.RaiseEvent(session, newUser);

            if (IsLocalUser(newUser))
            {
                CurrentUserJoined.RaiseEvent(session);
            }
        }
        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
        private void OnUserJoinedSession(Session session, User user)
        {
            if (!session.IsJoined())
            {
                return;
            }

            if (!CurrentUsers.Contains(user))
            {
                //Debug.LogFormat("User {0} joined current session.", user.GetName());
                CurrentUsers.RemoveAll(x => x.GetID() == user.GetID());                 // in case there was an old user with the same ID
                CurrentUsers.Add(user);
                UserJoined.RaiseEvent(user);
            }
        }
        private void OnUserJoinedSession(Session session, User user)
        {
            if (!session.IsJoined())
            {
                return;
            }

            if (!CurrentUsers.Contains(user))
            {
                // Remove any old users with the same ID
                for (int i = CurrentUsers.Count - 1; i >= 0; i--)
                {
                    if (CurrentUsers[i].GetID() == user.GetID())
                    {
                        CurrentUsers.RemoveAt(i);
                    }
                }

                CurrentUsers.Add(user);
                UserJoined.RaiseEvent(user);
                // Debug.LogFormat("User {0} joined current session.", user.GetName());
            }
        }