JMSGChatRoom.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. /*
  2. * | | | | \ \ / / | | | | / _______|
  3. * | |____| | \ \/ / | |____| | / /
  4. * | |____| | \ / | |____| | | | _____
  5. * | | | | / \ | | | | | | |____ |
  6. * | | | | / /\ \ | | | | \ \______| |
  7. * | | | | /_/ \_\ | | | | \_________|
  8. *
  9. * Copyright (c) 2011 ~ 2015 Shenzhen HXHG. All rights reserved.
  10. */
  11. #import <Foundation/Foundation.h>
  12. #import <JMessage/JMSGConstants.h>
  13. @class JMSGUser,JMSGMemberSilenceInfo;
  14. /*!
  15. * 聊天室
  16. *
  17. * #### 主要特点
  18. *
  19. * 聊天室的消息没有推送通知和离线保存,也没有常驻成员的概念,只要进入聊天室即可接收消息,开始聊天,
  20. 一旦退出聊天室,不再会接收到任何消息、通知和提醒。
  21. *
  22. * #### 发送消息
  23. *
  24. * 聊天室消息的发送与单聊、群聊是一样的,通用的发送接口
  25. *
  26. * #### 接收消息
  27. *
  28. * 聊天室消息的接收与单聊、群聊做了区分,聊天室消息的接收将通过 JMSGConversationDelegate 类里的 onReceiveChatRoomConversation:messages: 方法通知到上层
  29. *
  30. */
  31. @interface JMSGChatRoom : NSObject
  32. JMSG_ASSUME_NONNULL_BEGIN
  33. /*!
  34. * @abstract 分页获取聊天室详情
  35. *
  36. * @param appKey 选填,为 nil 则获取当前应用下的聊天室
  37. * @param start 分页获取的下标,第一页从 index = 0 开始
  38. * @param count 一页的数量,每页最大值是 50
  39. * @param handler 结果回调. 正常返回时 resultObject 类型是 NSArray<JMSGChatRoom>
  40. *
  41. * @discussion 该接口总是向服务器端发起请求.
  42. */
  43. + (void)getChatRoomListWithAppKey:(NSString *JMSG_NULLABLE)appKey
  44. start:(NSInteger)start
  45. count:(NSInteger)count
  46. completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  47. /*!
  48. * @abstract 获取当前用户已加入的聊天室列表
  49. *
  50. * @param handler 结果回调. 正常返回时 resultObject 类型是 NSArray<JMSGChatRoom>
  51. *
  52. * @discussion 该接口总是向服务器端发起请求.
  53. */
  54. + (void)getMyChatRoomListCompletionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  55. /*!
  56. * @abstract 获取聊天室详情
  57. *
  58. * @param roomIds 待获取详情的聊天室 ID 数组
  59. * @param handler 结果回调. 正常返回时 resultObject 类型是 NSArray<JMSGChatRoom>
  60. *
  61. * @discussion 该接口总是向服务器端发起请求.
  62. */
  63. + (void)getChatRoomInfosWithRoomIds:(NSArray *JMSG_NONNULL)roomIds
  64. completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  65. /*!
  66. * @abstract 加入聊天室
  67. *
  68. * @param roomId 聊天室 id
  69. * @param handler 结果回调. error = nil 表示加入成功,resultObject 为 JMSGConversation 类型
  70. *
  71. * @discussion 成功进入聊天室之后,会将聊天室中最近若干条聊天记录同步下来并以 onReceiveChatRoomConversation: 事件的形式通知到上层,进入聊天室会自动获取最近50条消息。
  72. */
  73. + (void)enterChatRoomWithRoomId:(NSString *JMSG_NONNULL)roomId
  74. completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  75. /*!
  76. * @abstract 退出聊天室
  77. *
  78. * @param roomId 聊天室 id
  79. * @param handler 结果回调. error = nil 表示加入成功.
  80. *
  81. * @discussion 退出聊天室后获取不到任何消息和通知.
  82. */
  83. + (void)leaveChatRoomWithRoomId:(NSString *JMSG_NONNULL)roomId
  84. completionHandler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  85. ///----------------------------------------------------
  86. /// @name Group basic fields 群组基本属性
  87. ///----------------------------------------------------
  88. /*!
  89. * @abstract 聊天室 id
  90. */
  91. @property(nonatomic, strong, readonly) NSString *JMSG_NONNULL roomID;
  92. /*!
  93. * @abstract 名称
  94. */
  95. @property(nonatomic, strong, readonly) NSString *JMSG_NONNULL name;
  96. /*!
  97. * @abstract 聊天室所属应用 AppKey
  98. */
  99. @property(nonatomic, strong, readonly) NSString *JMSG_NONNULL appkey;
  100. /*!
  101. * @abstract 描述信息
  102. */
  103. @property(nonatomic, strong, readonly) NSString *JMSG_NULLABLE desc;
  104. /*!
  105. * @abstract 聊天室人数
  106. */
  107. @property(nonatomic, assign, readonly) NSInteger totalMemberCount;
  108. /*!
  109. * @abstract 聊天室最大人数限制
  110. */
  111. @property(nonatomic, strong, readonly) NSString *JMSG_NULLABLE maxMemberCount;
  112. /*!
  113. * @abstract 聊天室的创建时间
  114. */
  115. @property(nonatomic, strong, readonly) NSNumber *ctime;
  116. /*!
  117. * @abstract 聊天室创建者
  118. *
  119. * @param handler 结果回调. error = nil 表示获取成功, resultObject 为 JMSGUser 类型.
  120. */
  121. - (void)getChatRoomOwnerInfo:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  122. /*!
  123. * @abstract 聊天室的黑名单列表
  124. *
  125. * @param handler 结果回调. resultObject 是 NSArray 类型,元素是 JMSGUser
  126. *
  127. * @since 3.8.0
  128. */
  129. - (void)chatRoomBlacklist:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  130. /*!
  131. * @abstract 添加黑名单
  132. *
  133. * @param usernames 用户名列表
  134. * @param appKey 用户 appKey,usernames 中的所有用户必须在同一个 AppKey 下,不填则默认为本应用 appKey
  135. * @param handler 结果回调。error 为 nil 表示成功.
  136. *
  137. * @since 3.8.0
  138. */
  139. - (void)addBlacklistWithUsernames:(NSArray <__kindof NSString *>*)usernames
  140. appKey:(NSString *JMSG_NULLABLE)appKey
  141. handler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  142. /*!
  143. * @abstract 删除黑名单
  144. *
  145. * @param usernames 用户名列表
  146. * @param appKey 用户 appKey,usernames 中的所有用户必须在同一个 AppKey 下,不填则默认为本应用 appKey
  147. * @param handler 结果回调。error 为 nil 表示成功.
  148. *
  149. * @since 3.8.0
  150. */
  151. - (void)deleteBlacklistWithUsernames:(NSArray <__kindof NSString *>*)usernames
  152. appKey:(NSString *JMSG_NULLABLE)appKey
  153. handler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  154. /*!
  155. * @abstract 管理员列表
  156. *
  157. * @param handler 结果回调. resultObject 是 NSArray 类型,元素是 JMSGUser
  158. *
  159. * @discussion 注意:返回列表中不包含房主.
  160. *
  161. * @since 3.8.0
  162. */
  163. - (void)chatRoomAdminList:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  164. /*!
  165. * @abstract 添加管理员
  166. *
  167. * @param usernames 用户名列表
  168. * @param appkey 用户 AppKey,不填则默认为本应用 AppKey
  169. * @param handler 结果回调。error 为 nil 表示成功.
  170. *
  171. * @discussion 注意:非 VIP 应用最多设置 15 个管理员,不包括群主本身
  172. *
  173. * @since 3.8.0
  174. */
  175. - (void)addAdminWithUsernames:(NSArray <__kindof NSString *>*)usernames
  176. appKey:(NSString *JMSG_NULLABLE)appkey
  177. handler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  178. /*!
  179. * @abstract 删除管理员
  180. *
  181. * @param usernames 用户名列表
  182. * @param appkey 用户 AppKey,不填则默认为本应用 AppKey
  183. * @param handler 结果回调。error 为 nil 表示成功.
  184. *
  185. * @since 3.8.0
  186. */
  187. - (void)deleteAdminWithUsernames:(NSArray <__kindof NSString *>*)usernames
  188. appKey:(NSString *JMSG_NULLABLE)appkey
  189. handler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  190. /*!
  191. * @abstract 设置成员禁言(可设置禁言时间)
  192. *
  193. * @param silenceTime 禁言时间戳,单位:毫秒,必须不小于5分钟,不大于1年
  194. * @param usernames 用户的 username 数组,一次最多500人
  195. * @param appkey 用户的 appKey,若传入空则默认使用本应用appKey,同一次设置的 usernames 必须在同一个 AppKey 下
  196. * @param handler 结果回调,error = nil 时,表示成功
  197. *
  198. * @discussion 只有房主和管理员可设置;设置成功的话上层会收到相应下发事件。
  199. *
  200. * @since 3.8.1
  201. */
  202. - (void)addChatRoomSilenceWithTime:(SInt64)silenceTime
  203. usernames:(NSArray *JMSG_NONNULL)usernames
  204. appKey:(NSString *JMSG_NULLABLE)appkey
  205. handler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  206. /*!
  207. * @abstract 取消成员禁言
  208. *
  209. * @param usernames 用户的 username 数组,一次最多500人
  210. * @param appkey 用户的 appKey,若传入空则默认使用本应用appKey,同一次设置的 usernames 必须在同一个 AppKey 下
  211. * @param handler 结果回调,error = nil 时,表示成功
  212. *
  213. * @discussion 只有房主和管理员可设置;取消成功的话上层会收到相应下发事件。
  214. *
  215. * @since 3.8.1
  216. */
  217. - (void)deleteChatRoomSilenceWithUsernames:(NSArray *JMSG_NONNULL)usernames
  218. appKey:(NSString *JMSG_NULLABLE)appkey
  219. handler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  220. /*!
  221. * @abstract 获取禁言状态
  222. *
  223. * @param username 用户名
  224. * @param appKey 用户所在应用 AppKey,不填这默认本应用
  225. * @param handler 结果回调,resultObject 是 JMSGMemberSilenceInfo 类型
  226. * 若 error == nil && resultObject != nil,该成员已被禁言
  227. * 若 error == nil && resultObject == nil,该成员未被禁言
  228. * 若 error != nil ,请求失败,
  229. *
  230. * @discussion 详细信息可查看 JMSGMemberSilenceInfo 类
  231. *
  232. * @since 3.8.1
  233. */
  234. - (void)getChatRoomMemberSilenceWithUsername:(NSString *JMSG_NONNULL)username
  235. appKey:(NSString *JMSG_NULLABLE)appKey
  236. handler:(JMSGCompletionHandler JMSG_NULLABLE)handler;
  237. /*!
  238. * @abstract 禁言列表
  239. *
  240. * @param start 开始位置
  241. * @param count 需要获取的个数,必须大于 0
  242. * @param handler 结果回调
  243. *
  244. * @since 3.8.1
  245. */
  246. - (void)getChatRoomSilencesWithStart:(SInt64)start
  247. count:(SInt64)count
  248. handler:(void(^)(NSArray <__kindof JMSGMemberSilenceInfo *>*JMSG_NULLABLE list,SInt64 total,NSError *JMSG_NULLABLE error))handler;
  249. /*!
  250. * @abstract 聊天室的展示名
  251. *
  252. * @discussion 如果 chatroom.name 为空, 则此接口会返回 chatroom.roomID.
  253. */
  254. - (NSString *)displayName;
  255. JMSG_ASSUME_NONNULL_END
  256. @end