JMSGChatRoom.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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;
  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. * @discussion 如果 chatroom.name 为空, 则此接口会返回 chatroom.roomID.
  126. */
  127. - (NSString *)displayName;
  128. JMSG_ASSUME_NONNULL_END
  129. @end