mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Fix intermittent multiplayer tests
This commit is contained in:
parent
79d9aa7383
commit
e6ee360511
@ -359,22 +359,25 @@ namespace osu.Game.Online.Multiplayer
|
||||
if (Room == null)
|
||||
return;
|
||||
|
||||
await PopulateUser(user).ConfigureAwait(false);
|
||||
|
||||
Scheduler.Add(() =>
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
if (Room == null)
|
||||
return;
|
||||
await PopulateUser(user).ConfigureAwait(false);
|
||||
|
||||
// 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;
|
||||
Scheduler.Add(() =>
|
||||
{
|
||||
if (Room == null)
|
||||
return;
|
||||
|
||||
Room.Users.Add(user);
|
||||
// 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;
|
||||
|
||||
UserJoined?.Invoke(user);
|
||||
RoomUpdated?.Invoke();
|
||||
}, false);
|
||||
Room.Users.Add(user);
|
||||
|
||||
UserJoined?.Invoke(user);
|
||||
RoomUpdated?.Invoke();
|
||||
});
|
||||
}).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
Task IMultiplayerClient.UserLeft(MultiplayerRoomUser user) =>
|
||||
|
@ -53,7 +53,8 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
public MultiplayerRoomUser AddUser(User user, bool markAsPlaying = false)
|
||||
{
|
||||
var roomUser = new MultiplayerRoomUser(user.Id) { User = user };
|
||||
((IMultiplayerClient)this).UserJoined(roomUser);
|
||||
|
||||
addUser(roomUser);
|
||||
|
||||
if (markAsPlaying)
|
||||
PlayingUserIds.Add(user.Id);
|
||||
@ -61,7 +62,15 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
return roomUser;
|
||||
}
|
||||
|
||||
public void AddNullUser() => ((IMultiplayerClient)this).UserJoined(new MultiplayerRoomUser(TestUserLookupCache.NULL_USER_ID));
|
||||
public void AddNullUser() => addUser(new MultiplayerRoomUser(TestUserLookupCache.NULL_USER_ID));
|
||||
|
||||
private void addUser(MultiplayerRoomUser user)
|
||||
{
|
||||
((IMultiplayerClient)this).UserJoined(user).Wait();
|
||||
|
||||
// We want the user to be immediately available for testing, so force a scheduler update.
|
||||
Scheduler.Update();
|
||||
}
|
||||
|
||||
public void RemoveUser(User user)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user