IEMPresenceManager.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. //
  2. // IEMPresenceManager.h
  3. // HyphenateChat
  4. //
  5. // Created by lixiaoming on 2022/1/14.
  6. // Copyright © 2022 easemob.com. All rights reserved.
  7. //
  8. /*!
  9. * \~chinese
  10. * @header IEMPresenceManager.h
  11. * @abstract 在线状态管理类,负责发布自定义在线状态、管理在线状态订阅、查询指定用户的在线状态以及添加和移除回调代理。
  12. * @author Hyphenate
  13. * @version 3.00
  14. *
  15. * \~english
  16. * @header IEMPresenceManager.h
  17. * @abstract The presence management class, responsible for publishing a custom presence state, managing presence subscriptions, querying the current presence state of a user, and adding and removing a delegate.
  18. * @author Hyphenate
  19. * @version 3.00
  20. */
  21. #import <Foundation/Foundation.h>
  22. #import "EMPresenceManagerDelegate.h"
  23. #import "EMError.h"
  24. /*!
  25. * \~chinese
  26. * 在线状态管理协议,提供在线状态管理功能。
  27. *
  28. * \~english
  29. * The presence management protocol that defines how to manage presence states.
  30. */
  31. @protocol IEMPresenceManager <NSObject>
  32. /*!
  33. * \~chinese
  34. * 发布自定义在线状态。
  35. *
  36. * @param aDescription 在线状态详细信息,建议不超过64字节。
  37. * @param aCompletion 该方法完成调用的回调。如果该方法调用失败,会包含调用失败的原因。
  38. *
  39. * \~english
  40. * Publishes a custom presence state.
  41. *
  42. * @param aDescription The extension information of the presence state. It can be set as nil.
  43. * @param aCompletion The completion block, which contains the error message if this method fails.
  44. */
  45. - (void) publishPresenceWithDescription:(NSString*_Nullable )aDescription
  46. completion:(void(^_Nullable )(EMError*_Nullable error))aCompletion;
  47. /*!
  48. * \~chinese
  49. * 订阅指定用户的在线状态。订阅成功后,在线状态变更时订阅者会收到回调通知。
  50. *
  51. * @param members 要订阅Presence的用户 ID 数组,数组长度不能超过100。
  52. * @param expiry 订阅持续时间,单位为秒,最大不超过30*24*3600。
  53. * @param aCompletion 该方法完成调用的回调。如果该方法调用成功,会返回订阅用户的当前状态,调用失败,会包含调用失败的原因。
  54. *
  55. * \~english
  56. * Subscribes to a user's presence states. If the subscription succeeds, the subscriber will receive the callback when the user's presence state changes.
  57. *
  58. * @param members The array of IDs of users whose presence states you want to subscribe to.
  59. @param expiry The expiration time of the presence subscription.
  60. * @param aCompletion The completion block, which contains the error message if the method fails.
  61. */
  62. - (void) subscribe:(NSArray<NSString*>*_Nonnull)members
  63. expiry:(NSInteger)expiry
  64. completion:(void(^_Nullable )(NSArray<EMPresence*>*_Nullable presences,EMError*_Nullable error))aCompletion;
  65. /*!
  66. * \~chinese
  67. * 取消订阅指定用户的在线状态。
  68. *
  69. * @param members 要取消订阅Presence的用户 ID 数组,数组长度不能超过100。
  70. * @param aCompletion 该方法完成调用的回调。如果该方法调用失败,会包含调用失败的原因。
  71. *
  72. * \~english
  73. * Unsubscribes from a user's presence states.
  74. *
  75. * @param members The array of IDs of users whose presence states you want to unsubscribe from.
  76. * @param aCompletion The completion block, which contains the error message if the method fails.
  77. */
  78. - (void) unsubscribe:(NSArray<NSString*>*_Nonnull) members
  79. completion:(void(^_Nullable )(EMError*_Nullable error))aCompletion;
  80. /*!
  81. * \~chinese
  82. * 分页查询当前用户订阅了哪些用户的在线状态。
  83. *
  84. * @param pageNum 当前页码,从 1 开始。
  85. * @param pageSize 每页的订阅用户的数量,最大不能超过500。
  86. * @param aCompletion 完成回调,返回订阅的在线状态所属的用户 ID。若当前未订阅任何用户的在线状态,返回空值。
  87. *
  88. * \~english
  89. * Uses pagination to get a list of users whose presence states you have subscribed to.
  90. *
  91. * @param pageNum The current page number, starting from 1.
  92. * @param pageSize The number of subscribed users on each page.
  93. * @param aCompletion The completion block, which contains IDs of users whose presence states you have subscribed to. Returns nil if you subscribe to no user's presence state.
  94. */
  95. - (void) fetchSubscribedMembersWithPageNum:(NSUInteger)pageNum
  96. pageSize:(NSUInteger)pageSize
  97. Completion:(void(^_Nullable )(NSArray<NSString*>*_Nullable members,EMError*_Nullable error))aCompletion;
  98. /*!
  99. * \~chinese
  100. * 查询指定用户的当前在线状态。
  101. *
  102. * @param members 用户 ID 数组,指定要查询哪些用户的在线状态。
  103. * @param aCompletion 完成回调,返回用户的在线状态。
  104. *
  105. * \~english
  106. * Gets the current presence state of users.
  107. *
  108. * @param members The array of IDs of users whose current presence state you want to check.
  109. * @param aCompletion The completion block, which contains the users whose presence state you have subscribed to.
  110. */
  111. - (void) fetchPresenceStatus:(NSArray<NSString*>*_Nonnull )members
  112. completion:(void(^_Nullable )(NSArray<EMPresence*>* _Nullable presences,EMError*_Nullable error))aCompletion;
  113. /*!
  114. * \~chinese
  115. * 添加回调代理。
  116. *
  117. * @param aDelegate 要添加的代理。
  118. * @param aQueue 执行代理方法的队列。若要在主线程上运行应用,需将该参数设置为空。
  119. *
  120. * \~english
  121. * Adds a delegate.
  122. *
  123. * @param aDelegate The delegate to be added.
  124. * @param aQueue (optional) The queue of calling delegate methods. If you want to run the app on the main thread, set this parameter as nil.
  125. */
  126. - (void) addDelegate:(id<EMPresenceManagerDelegate> _Nonnull)aDelegate
  127. delegateQueue:(dispatch_queue_t _Nullable )aQueue;
  128. /*!
  129. * \~chinese
  130. * 移除回调代理。
  131. *
  132. * @param aDelegate 要移除的代理。
  133. *
  134. * \~english
  135. * Removes a delegate.
  136. *
  137. * @param aDelegate The delegate to be removed.
  138. */
  139. - (void) removeDelegate:(id<EMPresenceManagerDelegate> _Nonnull)aDelegate;
  140. @end
  141. /* IEMPresenceManager_h */