IOnlineClientManager.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using JetBrains.Annotations;
  4. namespace Abp.RealTime
  5. {
  6. /// <summary>
  7. /// Used to manage online clients those are connected to the application.
  8. /// </summary>
  9. public interface IOnlineClientManager<T> : IOnlineClientManager
  10. {
  11. }
  12. public interface IOnlineClientManager
  13. {
  14. event EventHandler<OnlineClientEventArgs> ClientConnected;
  15. event EventHandler<OnlineClientEventArgs> ClientDisconnected;
  16. event EventHandler<OnlineUserEventArgs> UserConnected;
  17. event EventHandler<OnlineUserEventArgs> UserDisconnected;
  18. /// <summary>
  19. /// Adds a client.
  20. /// </summary>
  21. /// <param name="client">The client.</param>
  22. void Add(IOnlineClient client);
  23. /// <summary>
  24. /// Removes a client by connection id.
  25. /// </summary>
  26. /// <param name="connectionId">The connection id.</param>
  27. /// <returns>True, if a client is removed</returns>
  28. bool Remove(string connectionId);
  29. /// <summary>
  30. /// Tries to find a client by connection id.
  31. /// Returns null if not found.
  32. /// </summary>
  33. /// <param name="connectionId">connection id</param>
  34. IOnlineClient GetByConnectionIdOrNull(string connectionId);
  35. /// <summary>
  36. /// Gets all online clients.
  37. /// </summary>
  38. IReadOnlyList<IOnlineClient> GetAllClients();
  39. IReadOnlyList<IOnlineClient> GetAllByUserId([NotNull] IUserIdentifier user);
  40. }
  41. }