/// <summary> /// Join the specified session. /// </summary> /// <param name="session">Session to join.</param> /// <returns>True if the session is being joined or is already joined.</returns> public bool JoinSession(Session session) { // TODO Should prevent joining multiple sessions at the same time if (session != null) { return(session.IsJoined() || session.Join()); } return(false); }
private void OnUserLeftSession(Session session, User user) { if (!session.IsJoined()) { return; } if (CurrentUsers.RemoveAll(x => x.GetID() == user.GetID()) > 0) { //Debug.LogFormat("User {0} left current session.", user.GetName()); UserLeft.RaiseEvent(user); } }
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 OnUserLeftSession(Session session, User user) { if (!session.IsJoined()) { return; } for (int i = CurrentUsers.Count - 1; i >= 0; i--) { if (CurrentUsers[i].GetID() == user.GetID()) { CurrentUsers.RemoveAt(i); UserLeft.RaiseEvent(user); // Debug.LogFormat("User {0} left current session.", user.GetName()); } } }
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()); } }