Garbage collection setup that might be needed later
This commit is contained in:
@@ -99,7 +99,7 @@ public class Room
|
||||
return _connections.Select(connection => connection.Socket).ToList();
|
||||
}
|
||||
|
||||
private bool IsEmpty()
|
||||
public bool IsEmpty()
|
||||
{
|
||||
return _connections.Count == 0;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,16 @@ public class RoomManager : IRoomManager
|
||||
{
|
||||
return Rooms.ContainsKey(roomId);
|
||||
}
|
||||
|
||||
public void ClearGhostRooms()
|
||||
{
|
||||
var ghostRooms = Rooms.Where(room => room.Value.IsEmpty());
|
||||
foreach (var room in ghostRooms)
|
||||
{
|
||||
GC.Collect(GC.GetGeneration(room.Value));
|
||||
RemoveRoom(room.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IRoomManager
|
||||
@@ -40,4 +50,5 @@ public interface IRoomManager
|
||||
public List<string> GetAllRooms();
|
||||
public void RemoveRoom(string roomId);
|
||||
public bool RoomExists(string roomId);
|
||||
public void ClearGhostRooms();
|
||||
}
|
||||
Reference in New Issue
Block a user