Update wire protocol to version 7 and enhance presence management features
- Bumped the wire protocol version to 7, reflecting significant changes in the communication structure. - Introduced a new presence message type for real-time occupancy updates, including node activity and individual presence states. - Updated the API to include a directory endpoint for fetching short id→name mappings, improving client-side name resolution. - Revised the map snapshot structure to be static, with people and current lessons now handled through the presence stream. - Enhanced client-side handling of presence updates, including UI adjustments to display live occupancy and activity. - Updated documentation to reflect the new protocol features and changes in presence management. - Added tests to validate the new presence functionalities and ensure robust handling of real-time data.
This commit is contained in:
@@ -138,6 +138,18 @@ public sealed class School : IDisposable
|
||||
|
||||
public bool IsCampusEmpty() => PresenceSystem.IsEmpty(this);
|
||||
|
||||
public SkipEmptyPeek PeekSkipEmpty()
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||
if (Catalog is null || !IsCampusEmpty() || SchoolDay.InWorkWindow(Catalog, Clock.Time, SchoolWeekDays))
|
||||
{
|
||||
return SkipEmptyPeek.Refused;
|
||||
}
|
||||
|
||||
var next = SchoolDay.NextWorkMorning(Catalog, Clock.Time, SchoolWeekDays, MaxSkipDays);
|
||||
return next is null ? SkipEmptyPeek.Refused : new SkipEmptyPeek(true, next.Value);
|
||||
}
|
||||
|
||||
public SkipEmptyResult TrySkipEmpty()
|
||||
{
|
||||
ObjectDisposedException.ThrowIf(_disposed, this);
|
||||
@@ -295,6 +307,11 @@ public enum SkipEmptyError
|
||||
NoMorning,
|
||||
}
|
||||
|
||||
public readonly record struct SkipEmptyPeek(bool Allowed, DateTime? Time)
|
||||
{
|
||||
public static SkipEmptyPeek Refused { get; } = new(false, null);
|
||||
}
|
||||
|
||||
public readonly record struct SkipEmptyResult(SkipEmptyError Error, DateTime? Time, bool PeopleChanged)
|
||||
{
|
||||
public bool Succeeded => Error == SkipEmptyError.None;
|
||||
|
||||
Reference in New Issue
Block a user