private Task handleUserLeft(MultiplayerRoomUser user, Action <MultiplayerRoomUser>?callback) { if (Room == null) { return(Task.CompletedTask); } Scheduler.Add(() => { if (Room == null) { return; } Room.Users.Remove(user); PlayingUserIds.Remove(user.UserID); Debug.Assert(APIRoom != null); APIRoom.RecentParticipants.RemoveAll(u => u.Id == user.UserID); APIRoom.ParticipantCount.Value--; callback?.Invoke(user); RoomUpdated?.Invoke(); }, false); return(Task.CompletedTask); }
async Task IMultiplayerClient.UserJoined(MultiplayerRoomUser user) { if (Room == null) { return; } await PopulateUser(user).ConfigureAwait(false); Scheduler.Add(() => { if (Room == null) { return; } // for sanity, ensure that there can be no duplicate users in the room user list. if (Room.Users.Any(existing => existing.UserID == user.UserID)) { return; } Room.Users.Add(user); addUserToAPIRoom(user); UserJoined?.Invoke(user); RoomUpdated?.Invoke(); }); }
async Task IMultiplayerClient.UserJoined(MultiplayerRoomUser user) { if (Room == null) { return; } await PopulateUser(user); Schedule(() => { if (Room == null) { return; } // for sanity, ensure that there can be no duplicate users in the room user list. if (Room.Users.Any(existing => existing.UserID == user.UserID)) { return; } Room.Users.Add(user); RoomChanged?.Invoke(); }); }
private void addUserToAPIRoom(MultiplayerRoomUser user) { Debug.Assert(APIRoom != null); APIRoom.RecentParticipants.Add(user.User ?? new APIUser { Id = user.UserID, Username = "******" }); APIRoom.ParticipantCount.Value++; }
Task IMultiplayerClient.UserKicked(MultiplayerRoomUser user) { if (LocalUser == null) { return(Task.CompletedTask); } if (user.Equals(LocalUser)) { LeaveRoom(); } return(handleUserLeft(user, UserKicked)); }
Task IMultiplayerClient.UserKicked(MultiplayerRoomUser user) { if (LocalUser == null) { return(Task.CompletedTask); } if (user.Equals(LocalUser)) { LeaveRoom(); } // TODO: also inform users of the kick operation. return(((IMultiplayerClient)this).UserLeft(user)); }
Task IMultiplayerClient.UserLeft(MultiplayerRoomUser user) { if (Room == null) { return(Task.CompletedTask); } Scheduler.Add(() => { if (Room == null) { return; } Room.Users.Remove(user); CurrentMatchPlayingUserIds.Remove(user.UserID); RoomUpdated?.Invoke(); }, false); return(Task.CompletedTask); }
Task IMultiplayerClient.UserLeft(MultiplayerRoomUser user) { if (Room == null) { return(Task.CompletedTask); } Schedule(() => { if (Room == null) { return; } Room.Users.Remove(user); PlayingUsers.Remove(user.UserID); RoomChanged?.Invoke(); }); return(Task.CompletedTask); }
private Task handleUserLeft(MultiplayerRoomUser user, Action <MultiplayerRoomUser>?callback) { if (Room == null) { return(Task.CompletedTask); } Scheduler.Add(() => { if (Room == null) { return; } Room.Users.Remove(user); PlayingUserIds.Remove(user.UserID); callback?.Invoke(user); RoomUpdated?.Invoke(); }, false); return(Task.CompletedTask); }
protected async Task PopulateUser(MultiplayerRoomUser multiplayerUser) => multiplayerUser.User ??= await userLookupCache.GetUserAsync(multiplayerUser.UserID).ConfigureAwait(false);
Task IMultiplayerClient.UserLeft(MultiplayerRoomUser user) => handleUserLeft(user, UserLeft);