Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. /// <summary>
  2. /// A class that provides <c>dynamic</c> access to connections, including the one that sent the current invocation.
  3. /// </summary>
  4. public class DynamicHubClients
  5. {
  6. private readonly IHubCallerClients _clients;
  7.  
  8. /// <summary>
  9. /// Initializes a new instance of the <see cref="DynamicHubClients"/> class.
  10. /// </summary>
  11. /// <param name="clients">A wrapped <see cref="IHubCallerClients"/> that is used to invoke methods.</param>
  12. public DynamicHubClients(IHubCallerClients clients)
  13. {
  14. _clients = clients;
  15. }
  16.  
  17. /// <summary>
  18. /// Gets an object that can be used to invoke methods on all clients connected to the hub.
  19. /// </summary>
  20. /// <returns>An object that can be used to invoke methods on the specified user.</returns>
  21. public dynamic All => new DynamicClientProxy(_clients.All);
  22.  
  23. /// <summary>
  24. /// Gets an object that can be used to invoke methods on all clients connected to the hub excluding the specified connections.
  25. /// </summary>
  26. /// <param name="excludedConnectionIds">A collection of connection IDs to exclude.</param>
  27. /// <returns>An object that can be used to invoke methods on the specified user.</returns>
  28. public dynamic AllExcept(IReadOnlyList<string> excludedConnectionIds) => new DynamicClientProxy(_clients.AllExcept(excludedConnectionIds));
  29.  
  30. /// <summary>
  31. /// Gets an object that can be used to invoke methods on the connection which triggered the current invocation.
  32. /// </summary>
  33. public dynamic Caller => new DynamicClientProxy(_clients.Caller);
  34.  
  35. /// <summary>
  36. /// Gets an object that can be used to invoke methods on the specified connection.
  37. /// </summary>
  38. /// <param name="connectionId">The connection ID.</param>
  39. /// <returns>An object that can be used to invoke methods.</returns>
  40. public dynamic Client(string connectionId) => new DynamicClientProxy(_clients.Client(connectionId));
  41.  
  42. /// <summary>
  43. /// Gets an object that can be used to invoke methods on the specified connections.
  44. /// </summary>
  45. /// <param name="connectionIds">The connection IDs.</param>
  46. /// <returns>An object that can be used to invoke methods.</returns>
  47. public dynamic Clients(IReadOnlyList<string> connectionIds) => new DynamicClientProxy(_clients.Clients(connectionIds));
  48.  
  49. /// <summary>
  50. /// Gets an object that can be used to invoke methods on all connections in the specified group.
  51. /// </summary>
  52. /// <param name="groupName">The group name.</param>
  53. /// <returns>An object that can be used to invoke methods.</returns>
  54. public dynamic Group(string groupName) => new DynamicClientProxy(_clients.Group(groupName));
  55.  
  56. /// <summary>
  57. /// Gets an object that can be used to invoke methods on all connections in all of the specified groups.
  58. /// </summary>
  59. /// <param name="groupNames">The group names.</param>
  60. /// <returns>An object that can be used to invoke methods on the specified user.</returns>
  61. public dynamic Groups(IReadOnlyList<string> groupNames) => new DynamicClientProxy(_clients.Groups(groupNames));
  62.  
  63. /// <summary>
  64. /// Gets an object that can be used to invoke methods on all connections in the specified group excluding the specified connections.
  65. /// </summary>
  66. /// <param name="groupName">The group name.</param>
  67. /// <param name="excludedConnectionIds">A collection of connection IDs to exclude.</param>
  68. /// <returns>An object that can be used to invoke methods.</returns>
  69. public dynamic GroupExcept(string groupName, IReadOnlyList<string> excludedConnectionIds) => new DynamicClientProxy(_clients.GroupExcept(groupName, excludedConnectionIds));
  70.  
  71. /// <summary>
  72. /// Gets an object that can be used to invoke methods on connections in a group other than the caller.
  73. /// </summary>
  74. /// <returns>An object that can be used to invoke methods.</returns>
  75. public dynamic OthersInGroup(string groupName) => new DynamicClientProxy(_clients.OthersInGroup(groupName));
  76.  
  77. /// <summary>
  78. /// Gets an object that can be used to invoke methods on connections other than the caller.
  79. /// </summary>
  80. public dynamic Others => new DynamicClientProxy(_clients.Others);
  81.  
  82. /// <summary>
  83. /// Gets an object that can be used to invoke methods on all connections associated with the specified user.
  84. /// </summary>
  85. /// <param name="userId">The user ID.</param>
  86. /// <returns>An object that can be used to invoke methods.</returns>
  87. public dynamic User(string userId) => new DynamicClientProxy(_clients.User(userId));
  88.  
  89. /// <summary>
  90. /// Gets an object that can be used to invoke methods on all connections associated with all of the specified users.
  91. /// </summary>
  92. /// <param name="userIds">The user IDs.</param>
  93. /// <returns>An object that can be used to invoke methods.</returns>
  94. public dynamic Users(IReadOnlyList<string> userIds) => new DynamicClientProxy(_clients.Users(userIds));
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement