using System; namespace WatchParty.Parties { public class PartyMember { public Guid UserId { get; set; } public string UserName { get; set; } /// /// The Emby session this member is watching from. Resolved at join time /// from the caller's active sessions - see /// docs/architecture.md#which-session-is-mine for the current, fairly /// blunt, v1 heuristic. /// public string SessionId { get; set; } public DateTime JoinedUtc { get; set; } /// Last position reported for this member, in ticks (100ns units, Emby convention). public long LastKnownPositionTicks { get; set; } public bool LastKnownIsPaused { get; set; } /// When LastKnownPositionTicks/LastKnownIsPaused were last updated. public DateTime LastUpdatedUtc { get; set; } /// When we last sent this member a corrective command, for cooldown purposes. public DateTime? LastResyncUtc { get; set; } /// /// Extrapolates where this member's playback should be *right now*, /// assuming unchanged play/pause state since LastUpdatedUtc. /// public long EstimatedPositionTicks(DateTime utcNow) { if (LastKnownIsPaused) { return LastKnownPositionTicks; } var elapsed = utcNow - LastUpdatedUtc; if (elapsed <= TimeSpan.Zero) { return LastKnownPositionTicks; } return LastKnownPositionTicks + elapsed.Ticks; } } }