2020-12-04 14:34:31 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
|
|
using System;
|
2020-12-07 17:50:02 +08:00
|
|
|
using System.Collections.Generic;
|
2020-12-04 14:34:31 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Online.RealtimeMultiplayer
|
|
|
|
{
|
|
|
|
[Serializable]
|
|
|
|
public class MultiplayerRoom
|
|
|
|
{
|
2020-12-08 00:24:38 +08:00
|
|
|
private object writeLock = new object();
|
|
|
|
|
2020-12-04 14:34:31 +08:00
|
|
|
public long RoomID { get; set; }
|
|
|
|
|
|
|
|
public MultiplayerRoomState State { get; set; }
|
2020-12-07 17:50:02 +08:00
|
|
|
|
|
|
|
private List<MultiplayerRoomUser> users = new List<MultiplayerRoomUser>();
|
|
|
|
|
2020-12-08 00:24:38 +08:00
|
|
|
public IReadOnlyList<MultiplayerRoomUser> Users
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
lock (writeLock)
|
|
|
|
return users.ToArray();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Join(int user)
|
|
|
|
{
|
|
|
|
lock (writeLock)
|
|
|
|
users.Add(new MultiplayerRoomUser(user));
|
|
|
|
}
|
2020-12-07 17:50:02 +08:00
|
|
|
|
2020-12-08 00:24:38 +08:00
|
|
|
public void Leave(int user)
|
|
|
|
{
|
|
|
|
lock (writeLock)
|
|
|
|
users.RemoveAll(u => u.UserID == user);
|
|
|
|
}
|
2020-12-04 14:34:31 +08:00
|
|
|
}
|
|
|
|
}
|