IPresenceTracker.cs 1.1 KB

1234567891011121314151617181920212223
  1. namespace Application.Abstractions.Hub;
  2. /// <summary>
  3. /// SignalR AppHub 접속자 추적 (Redis 기반).
  4. /// 한 멤버가 여러 탭/디바이스 접속 가능 → connectionId refcount 패턴.
  5. /// </summary>
  6. public interface IPresenceTracker
  7. {
  8. /// <summary>새 SignalR connection 등록. 첫 connection이면 online set에 추가. 반환값: true = 0→1 전환(첫 접속).</summary>
  9. Task<bool> AddConnectionAsync(int memberID, string connectionId);
  10. /// <summary>SignalR disconnect 처리. 마지막 connection이면 online set에서 제거. 반환값: true = 1→0 전환(완전 종료).</summary>
  11. Task<bool> RemoveConnectionAsync(int memberID, string connectionId);
  12. /// <summary>특정 멤버 온라인 여부.</summary>
  13. Task<bool> IsOnlineAsync(int memberID);
  14. /// <summary>여러 멤버의 온라인 ID 집합 일괄 조회.</summary>
  15. Task<HashSet<int>> GetOnlineMembersAsync(IEnumerable<int> memberIDs);
  16. /// <summary>Web.Api 시작 시 stale presence 데이터(고아 connectionId, online set) 일괄 정리. 모든 SignalR 클라이언트는 재연결 시 OnConnected로 재등록됨.</summary>
  17. Task ClearAllAsync();
  18. }