-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start tracking when users are publishing
- Loading branch information
Showing
3 changed files
with
45 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Bunkum.HttpServer; | ||
using Bunkum.HttpServer.Services; | ||
using MongoDB.Bson; | ||
using NotEnoughLogs; | ||
|
||
namespace Refresh.GameServer.Services; | ||
|
||
public class PublishTrackingService : EndpointService | ||
{ | ||
public PublishTrackingService(LoggerContainer<BunkumContext> logger) : base(logger) {} | ||
|
||
private readonly HashSet<ObjectId> _usersPublishing = new(); | ||
|
||
/// <summary> | ||
/// Start tracking the user, eg. they started publishing | ||
/// </summary> | ||
/// <param name="id"></param> | ||
public void StartTracking(ObjectId id) | ||
{ | ||
//Unconditionally add the user to the set | ||
_ = this._usersPublishing.Add(id); | ||
} | ||
|
||
/// <summary> | ||
/// Stop tracking the user, eg. they stopped publishing | ||
/// </summary> | ||
/// <param name="id"></param> | ||
public void StopTracking(ObjectId id) | ||
{ | ||
//Unconditionally remove the user from the set | ||
_ = this._usersPublishing.Remove(id); | ||
} | ||
|
||
public bool IsPublishing(ObjectId id) => this._usersPublishing.Contains(id); | ||
} |