IEMThreadManager.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. //
  2. // IEMThreadManager.h
  3. // HyphenateChat
  4. //
  5. // Created by 朱继超 on 2022/3/1.
  6. // Copyright © 2022 easemob.com. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "EMThreadManagerDelegate.h"
  10. #import "EMChatThread.h"
  11. #import "EMCursorResult.h"
  12. @class EMChatMessage;
  13. NS_ASSUME_NONNULL_BEGIN
  14. @protocol IEMThreadManager <NSObject>
  15. @required
  16. #pragma mark - Delegate
  17. /*!
  18. * \~chinese
  19. * 添加回调代理
  20. *
  21. * @param aDelegate 要添加的子区正常的增删改查的代理
  22. * @param aQueue 代理执行的队列,如果是nil,则在主线程
  23. *
  24. * \~english
  25. * Add delegate
  26. *
  27. * @param aDelegate Delegate is kindof protocol EMThreadManagerDelegate
  28. * @param aQueue (optional) The queue of calling delegate methods. Pass in nil to run on main thread.
  29. */
  30. - (void)addDelegate:(id<EMThreadManagerDelegate>)aDelegate
  31. delegateQueue:(_Nullable dispatch_queue_t)aQueue;
  32. /*!
  33. * \~chinese
  34. * 移除回调代理
  35. *
  36. * @param aDelegate 要移除的代理
  37. *
  38. * \~english
  39. * Remove delegate
  40. *
  41. * @param aDelegate Delegate is kindof protocol EMThreadManagerDelegate
  42. */
  43. - (void)removeDelegate:(id<EMThreadManagerDelegate>)aDelegate;
  44. #pragma mark - Get Thread
  45. /*!
  46. * \~chinese
  47. * 获取thread详情
  48. *
  49. * @param threadId 要获取的子区的id
  50. * @param aCompletionBlock 返回回调,包含一个EMChatThread对象跟一个EMError的错误对象
  51. * \~english
  52. * Get the thread detail
  53. * @param threadId The id of the subarea to get
  54. * @param aCompletionBlock Returns the callback, containing an EMChatThread object and an EMError error object
  55. */
  56. - (void)getChatThreadFromSever:(NSString *)threadId completion:(void (^)(EMChatThread *_Nullable thread, EMError * _Nullable aError))aCompletionBlock;
  57. /*!
  58. * \~chinese
  59. * 从服务器获取用户已加入的子区
  60. *
  61. * @param aCursor cursor 上一次取数的位置游标
  62. * @param pageSize 单次请求数量(单次请求限制最大50)
  63. * @param aCompletionBlock 返回回调,包含一个EMCursorResult对象跟一个EMError的错误对象
  64. * \~english
  65. * Get the subzones the user has joined from the server
  66. * @param aCursor cursor The position cursor of the last fetch
  67. * @param pageSize Number of single requests limit 50
  68. * @param aCompletionBlock Returns the callback, containing an EMCursorResult object and an EMError error object
  69. */
  70. - (void)getJoinedChatThreadsFromServerWithCursor:(NSString *)aCursor
  71. pageSize:(NSInteger)aPageSize
  72. completion:(void (^)(EMCursorResult<EMChatThread*>* _Nullable result, EMError * _Nullable aError))aCompletionBlock;
  73. /*!
  74. * \~chinese
  75. * 从服务器获取一个群组下的子区
  76. *
  77. * @param parentId 子区的上一级所属会话id
  78. * @param aCursor cursor 上一次取数的位置游标
  79. * @param pageSize 单次请求数量(最大不超过50)
  80. * @param aCompletionBlock 返回回调,包含一个EMCursorResult对象跟一个EMError的错误对象
  81. * \~english
  82. * Get the subareas under a group from the server
  83. * @param parentId The session id of the upper level of the sub-area
  84. * @param aCursor The position cursor of the last fetch
  85. * @param pageSize Number of single requests limit 50
  86. * @param aCompletionBlock Returns the callback, containing an EMCursorResult object and an EMError error object
  87. */
  88. - (void)getChatThreadsFromServerWithParentId:(NSString *)parentId cursor:(NSString *)aCursor pageSize:(NSInteger)aPageSize completion:(void (^)(EMCursorResult<EMChatThread*> * _Nullable result, EMError * _Nullable aError))aCompletionBlock;
  89. /*!
  90. * \~chinese
  91. * 从服务器获取一个群组下我加入的子区
  92. *
  93. * @param parentId 子区的上一级所属会话id
  94. * @param aCursor cursor 上一次取数的位置游标
  95. * @param pageSize 单次请求数量(最大不超过50)
  96. * @param aCompletionBlock 返回回调,包含一个EMCursorResult对象跟一个EMError的错误对象
  97. * \~english
  98. * Get the mine subareas under a group from the server
  99. * @param parentId The session id of the upper level of the sub-area
  100. * @param aCursor The position cursor of the last fetch
  101. * @param pageSize Number of single requests limit 50
  102. * @param aCompletionBlock Returns the callback, containing an EMCursorResult object and an EMError error object
  103. */
  104. - (void)getJoinedChatThreadsFromServerWithParentId:(NSString *)parentId cursor:(NSString *)aCursor pageSize:(NSInteger)aPageSize completion:(void (^)(EMCursorResult<EMChatThread*> * _Nullable result, EMError * _Nullable aError))aCompletionBlock;
  105. /*!
  106. * \~chinese
  107. * 从服务器获取一个子区的成员列表
  108. *
  109. * @param threadId 要获取成员的子区的id
  110. * @param aCursor cursor 上一次取数的位置游标
  111. * @param pageSize 单次请求数量
  112. * @param aCompletionBlock 返回回调,包含一个EMCursorResult对象跟一个EMError的错误对象
  113. * \~english
  114. * Get a list of members in a subsection
  115. * @param threadId The id of the subarea to get members
  116. * @param aCursor cursor The position cursor of the last fetch
  117. * @param pageSize Number of single requests limit 50
  118. * @param aCompletionBlock Returns the callback, containing an EMCursorResult object and an EMError error object
  119. */
  120. - (void)getChatThreadMemberListFromServerWithId:(NSString *)threadId cursor:(NSString *)aCursor pageSize:(NSInteger)pageSize completion:(void (^)(EMCursorResult<NSString*> * _Nullable aResult, EMError * _Nullable aError))aCompletionBlock;
  121. /*!
  122. * \~chinese
  123. * 从服务器批量获取子区的最后一条消息
  124. *
  125. * @param threadIds 要获取的子区的id数组(单次请求不超过20个id)
  126. * @param aCompletionBlock 返回回调,包含一个字典key是子区id,value是EMChatMessage对象
  127. * \~english
  128. * Get the thread detail
  129. * @param threadIds The ids of the subarea to get(No more than 20 ids for a single request)
  130. * @param aCompletionBlock Return the callback, including a dictionary key is the sub-area id, value is the EMChatMessage object
  131. */
  132. - (void)getLastMessageFromSeverWithChatThreads:(NSArray <NSString *>*)threadIds completion:(void (^)(NSDictionary<NSString*,EMChatMessage*>* _Nullable messageMap, EMError * _Nullable aError))aCompletionBlock;
  133. /*!
  134. * \~chinese
  135. * 移除子区成员(仅群管理可用)
  136. *
  137. * @param aUser 要移除用户的环信id
  138. * @param threadId 要操作的子区id
  139. * @param aCompletionBlock 返回回调,成功或者失败
  140. * \~english
  141. * Remove sub-zone members (only available for group management)
  142. * @param aUser To remove the user's ease id
  143. * @param threadId subarea id to operate
  144. * @param aCompletionBlock return callback, success or failure
  145. */
  146. - (void)removeMemberFromChatThread:(NSString *)aUser
  147. threadId:(NSString *)athreadId
  148. completion:(void (^)(EMError * _Nullable aError))aCompletionBlock;
  149. /*!
  150. * \~chinese
  151. * 更新子区名称(仅群管理或创建者可用)
  152. *
  153. * @param subject 你想要修改的名称(限制64个字符)
  154. * @param threadId 要操作的子区id
  155. * @param aCompletionBlock 返回回调,成功或者失败
  156. * \~english
  157. * Update subzone name (only available for group managers or creators)
  158. * @param name the name you want to change(limit 64 character)
  159. * @param threadId subarea id to operate
  160. * @param aCompletionBlock return callback, success or failure
  161. */
  162. - (void)updateChatThreadName:(NSString *)name
  163. threadId:(NSString *)athreadId
  164. completion:(void (^)(EMError * _Nullable aError))aCompletionBlock;
  165. /*!
  166. * \~chinese
  167. * Create a subsection
  168. *
  169. * @param threadName 要创建的子区的名称(限制64个字符)
  170. * @param messageId 操作创建子区那一条消息id
  171. * @param parentId 操作创建子区那一条消息所在的会话id也就是那条消息的to
  172. * @param completion 返回回调,包含一个EMChatThread对象跟一个EMError的错误对象
  173. * \~english
  174. * Create a subsection
  175. * @param threadName The id of the subarea to get(limit 64 character)
  176. * @param messageId The message id of the operation to create the sub-area
  177. * @param parentId The session id where the message of the operation creates the sub-area is also the to of that message
  178. * @param completion Returns the callback, containing an EMChatThread object and an EMError error object
  179. */
  180. - (void)createChatThread:(NSString *)threadName messageId:(NSString *)messageId parentId:(NSString *)parentId completion:(void (^)(EMChatThread *_Nullable thread,EMError * _Nullable aError))aCompletionBlock;
  181. /*!
  182. * \~chinese
  183. * 加入一个子区
  184. *
  185. * @param threadId 要加入的子区的id
  186. * @param aCompletionBlock 返回回调,成功或者失败
  187. * \~english
  188. * join a subsection
  189. * @param threadId The id of the subzone to join
  190. * @param aCompletionBlock return callback, success or failure
  191. */
  192. - (void)joinChatThread:(NSString *)threadId completion:(void (^)(EMChatThread *_Nullable thread,EMError * _Nullable aError))aCompletionBlock;
  193. /*!
  194. * \~chinese
  195. * 离开一个子区
  196. *
  197. * @param threadId 要离开的子区的id
  198. * @param aCompletionBlock 返回回调,成功或者失败
  199. * \~english
  200. * leave a subsection
  201. * @param threadId The id of the subzone to leave
  202. * @param aCompletionBlock return callback, success or failure
  203. */
  204. - (void)leaveChatThread:(NSString *)athreadId completion:(void (^)(EMError * _Nullable aError))aCompletionBlock;
  205. /*!
  206. * \~chinese
  207. * 销毁一个子区(群管理员及其以上级别可调用)
  208. *
  209. * @param threadId 要销毁的子区的id
  210. * @param aCompletionBlock 返回回调,成功或者失败
  211. * \~english
  212. * destroy a subsection
  213. * @param threadId The id of the subzone to destroy
  214. * @param aCompletionBlock return callback, success or failure
  215. */
  216. - (void)destroyChatThread:(NSString *)athreadId completion:(void (^)(EMError * _Nullable aError))aCompletionBlock;
  217. @end
  218. NS_ASSUME_NONNULL_END