NIMSDK-iOS
载入中...
搜索中...
未找到
NIMChatroomManagerProtocol.h
浏览该文件的文档.
1//
2// NIMChatroomManagerProtocol.h
3// NIMLib
4//
5// Created by Netease.
6// Copyright © 2015 Netease. All rights reserved.
7//
8
9#import <Foundation/Foundation.h>
10
11NS_ASSUME_NONNULL_BEGIN
12
13@class NIMMessage;
14@class NIMChatroom;
35
36
37/**
38 * 聊天室网络请求回调
39 *
40 * @param error 错误信息
41 */
42typedef void(^NIMChatroomHandler)(NSError * __nullable error);
43
44/**
45 * 聊天室成员请求回调
46 *
47 * @param error 错误信息
48 * @param member 更新后的聊天室成员信息
49 */
50typedef void(^NIMChatroomMemberHandler)(NSError * __nullable error,NIMChatroomMember * __nullable member);
51
52/**
53 * 进入聊天室请求回调
54 *
55 * @param error 错误信息
56 * @param chatroom 聊天室信息
57 * @param me 自己在聊天室内的信息
58 */
59typedef void(^NIMChatroomEnterHandler)(NSError * __nullable error,NIMChatroom * __nullable chatroom,NIMChatroomMember * __nullable me);
60
61
62/**
63 * 聊天室信息请求回调
64 *
65 * @param error 错误信息
66 * @param chatroom 聊天室信息
67 */
68typedef void(^NIMChatroomInfoHandler)(NSError * __nullable error,NIMChatroom * __nullable chatroom);
69
70/**
71 * 聊天室成员组网络数据回调
72 *
73 * @param error 错误信息
74 */
75typedef void(^NIMChatroomMembersHandler)(NSError * __nullable error, NSArray<NIMChatroomMember *> * __nullable members);
76
77/**
78 * 聊天室成员数量数量回调
79 *
80 * @param error 错误信息
81 */
82typedef void(^NIMChatroomMembersCountHandler)(NSError * __nullable error, uint64_t count);
83
84/**
85 * 聊天室队列数据回调
86 *
87 * @param error 错误信息
88 */
89typedef void(^NIMChatroomQueueInfoHandler)(NSError * __nullable error, NSArray<NSDictionary<NSString *, NSString *> *> * __nullable info);
90
91
92/**
93 * 聊天室队列移除元素回调
94 *
95 * @param error 错误信息
96 */
97typedef void(^NIMChatroomQueueRemoveHandler)(NSError * __nullable error, NSDictionary<NSString *, NSString *> * __nullable element);
98
99
100/**
101 聊天室队列批量更新元素回调
102
103 @param error 错误信息
104 @param elements 不存在的元素elementKey列表
105 */
106typedef void(^NIMChatroomQueueBatchUpdateHandler)(NSError * __nullable error, NSArray<NSString *> * __nullable elements);
107
108
109/**
110 * 拉取服务器聊天消息记录block
111 *
112 * @param error 错误,如果成功则error为nil
113 * @param messages 读取的消息列表
114 */
115typedef void(^NIMFetchChatroomHistoryBlock)(NSError * __nullable error,NSArray<NIMMessage *> * __nullable messages);
116
117
118/**
119 * 根据标签拉取服务器聊天消息记录的回调
120 *
121 * @param error 错误,如果成功则error为nil
122 * @param messages 读取的消息列表
123 */
124typedef void(^NIMGetMessagesByTagsHandler)(NSError * __nullable error,NSArray<NIMMessage *> * __nullable messages);
125
126/**
127 * 聊天室动态token block
128 */
129typedef NSString*(^NIMProvideChatroomDynamicTokenHandler)(NSString * __nullable roomId, NSString * __nullable account);
130
131
132
133/**
134 * 聊天室连接状态
135 */
136typedef NS_ENUM(NSInteger, NIMChatroomConnectionState) {
137 /**
138 * 正在进入
139 */
141 /**
142 * 进入聊天室成功
143 */
145 /**
146 * 进入聊天室失败
147 */
149 /**
150 * 和聊天室失去连接
151 */
153};
154
155/**
156 * 聊天室被踢原因
157 */
158typedef NS_ENUM(NSInteger, NIMChatroomKickReason) {
159 /**
160 * 聊天室已经解散
161 */
163 /**
164 * 被聊天室管理员踢出
165 */
167 /**
168 * 多端被踢
169 */
171 /**
172 * 被拉黑
173 */
175
176};
177
178
179/**
180 * 聊天室管理器回调
181 */
182@protocol NIMChatroomManagerDelegate <NSObject>
183
184@optional
185/**
186 * 被踢回调
187 *
188 * @param result 被踢的结果详情
189 */
190- (void)chatroomBeKicked:(NIMChatroomBeKickedResult *)result;
191
192
193/**
194 * 聊天室连接状态变化
195 *
196 * @param roomId 聊天室Id
197 * @param state 当前状态
198 */
199- (void)chatroom:(NSString *)roomId connectionStateChanged:(NIMChatroomConnectionState)state;
200
201/**
202 * 聊天室自动登录出错
203 *
204 * @param roomId 聊天室Id
205 * @param error 自动登录出错原因
206 */
207- (void)chatroom:(NSString *)roomId autoLoginFailed:(NSError *)error;
208
209/**
210 * 我的标签修改通知
211 * @param event 修改通知
212 */
213- (void)tagsUpdate:(NIMChatroomTagsUpdateEvent *)event;
214
215@end
216
217/**
218 * 聊天室管理器
219 */
220@protocol NIMChatroomManager <NSObject>
221
222/**
223 * 进入聊天室
224 *
225 * @param request 进入聊天室请求
226 * @param completion 进入完成后的回调
227 */
228- (void)enterChatroom:(NIMChatroomEnterRequest *)request
229 completion:(nullable NIMChatroomEnterHandler)completion;
230
231/**
232 * 离开聊天室
233 *
234 * @param roomId 聊天室ID
235 * @param completion 离开聊天室的回调
236 */
237- (void)exitChatroom:(NSString *)roomId
238 completion:(nullable NIMChatroomHandler)completion;
239
240/**
241 * 聊天室登录使用的模式
242 *
243 * @param roomId 聊天室ID
244 * @return 使用的登录模式
245 */
246- (NSInteger)chatroomAuthMode:(NSString *)roomId;
247
248/**
249 * 查询服务器保存的聊天室消息记录
250 *
251 * @param roomId 聊天室ID
252 * @param option 查询选项
253 * @param result 完成回调
254 */
255- (void)fetchMessageHistory:(NSString *)roomId
256 option:(NIMHistoryMessageSearchOption *)option
257 result:(nullable NIMFetchChatroomHistoryBlock)result;
258
259/**
260 * 通过标签查询消息
261 *
262 * @param param 查询参数
263 * @param completion 完成回调
264 */
265- (void)getMessagesByTags:(NIMGetMessagesByTagsParam *)param
266 completion:(nullable NIMGetMessagesByTagsHandler)completion;
267
268/**
269 * 获取聊天室信息
270 *
271 * @param roomId 聊天室ID
272 * @param completion 获取聊天室信息的回调
273 * @discussion 只有已进入聊天室才能够获取对应的聊天室信息
274 */
275- (void)fetchChatroomInfo:(NSString *)roomId
276 completion:(nullable NIMChatroomInfoHandler)completion;
277
278
279/**
280 * 修改聊天室信息
281 *
282 * @param request 聊天室修改请求
283 * @param completion 修改后完成的回调
284 */
285- (void)updateChatroomInfo:(NIMChatroomUpdateRequest *)request
286 completion:(nullable NIMChatroomHandler)completion;
287
288
289/**
290 * 修改自己在聊天室内的个人信息
291 *
292 * @param request 个人信息更新请求
293 * @param completion 修改完成后的回调
294 */
295- (void)updateMyChatroomMemberInfo:(NIMChatroomMemberInfoUpdateRequest *)request
296 completion:(nullable NIMChatroomHandler)completion;
297
298
299/**
300 * 获取聊天室成员
301 *
302 * @param request 获取成员请求
303 * @param completion 请求完成回调
304 */
305- (void)fetchChatroomMembers:(NIMChatroomMemberRequest *)request
306 completion:(nullable NIMChatroomMembersHandler)completion;
307
308
309/**
310 * 根据用户ID获取聊天室成员信息
311 *
312 * @param request 获取成员请求
313 * @param completion 请求完成回调
314 */
315- (void)fetchChatroomMembersByIds:(NIMChatroomMembersByIdsRequest *)request
316 completion:(nullable NIMChatroomMembersHandler)completion;
317
318
319/**
320 * 根据标签获取聊天室内该标签下的成员
321 *
322 * @param request 获取标签成员请求
323 * @param completion 请求完成回调
324 */
325- (void)fetchChatroomMembersByTag:(NIMChatroomFetchMembersByTagRequest *)request
326 completion:(nullable NIMChatroomMembersHandler)completion;
327
328
329/**
330 * 根据标签查询聊天室内该标签下的在线成员数量
331 *
332 * @param request 获取标签成员数量请求
333 * @param completion 请求完成回调
334 */
335- (void)queryChatroomMembersCountByTag:(NIMChatroomQueryMembersCountByTagRequest *)request
336 completion:(nullable NIMChatroomMembersCountHandler)completion;
337
338/**
339 * 更新坐标
340 * @param location 当前坐标和有效距离
341 * @param completion 请求完成回调
342 */
343-(void)updateLocation:(nonnull NIMChatroomLocation *)location
344 completion:(nullable NIMChatroomHandler)completion;
345
346/**
347 * 更新标签
348 * @param tags 标签
349 * @param completion 请求完成回调
350 */
351-(void)updateTags:(nonnull NIMChatroomTagsUpdate *)tags
352 completion:(nullable NIMChatroomHandler)completion;
353
354
355/**
356 * 标记为聊天室管理员
357 *
358 * @param request 更新请求
359 * @param completion 请求回调
360 */
361- (void)markMemberManager:(NIMChatroomMemberUpdateRequest *)request
362 completion:(nullable NIMChatroomHandler)completion;
363
364/**
365 * 标记为聊天室普通成员
366 *
367 * @param request 更新请求
368 * @param completion 请求回调
369 */
370- (void)markNormalMember:(NIMChatroomMemberUpdateRequest *)request
371 completion:(nullable NIMChatroomHandler)completion;
372
373/**
374 * 更新用户聊天室黑名单状态
375 *
376 * @param request 更新请求
377 * @param completion 请求回调
378 */
379- (void)updateMemberBlack:(NIMChatroomMemberUpdateRequest *)request
380 completion:(nullable NIMChatroomHandler)completion;
381
382
383/**
384 * 更新用户聊天室静言状态
385 *
386 * @param request 更新请求
387 * @param completion 请求回调
388 */
389- (void)updateMemberMute:(NIMChatroomMemberUpdateRequest *)request
390 completion:(nullable NIMChatroomHandler)completion;
391
392
393
394/**
395 * 更新用户聊天室临时禁言状态
396 *
397 * @param request 更新请求
398 * @param duration 临时禁言时长,单位为秒
399 * @param completion 请求回调
400 */
401- (void)updateMemberTempMute:(NIMChatroomMemberUpdateRequest *)request
402 duration:(unsigned long long)duration
403 completion:(nullable NIMChatroomHandler)completion;
404
405
406/**
407 * 针对标签更新聊天室临时禁言状态
408 *
409 * @param request 更新请求
410 * @param duration 临时禁言时长,单位为秒
411 * @param completion 请求回调
412 */
413- (void)tempMuteTag:(NIMChatroomTempMuteTagRequest *)request completion:(NIMChatroomHandler)completion;
414
415/**
416 * 将特定成员踢出聊天室
417 *
418 * @param request 踢出请求
419 * @param completion 请求回调
420 */
421- (void)kickMember:(NIMChatroomMemberKickRequest *)request
422 completion:(nullable NIMChatroomHandler)completion;
423
424
425/**
426 * 加入或者更新聊天室通用队列元素,权限由 NIMChatroom 的 queueModificationLevel 决定
427 *
428 * @param request 聊天室队列请求
429 * @param completion 请求回调
430 */
431- (void)updateChatroomQueueObject:(NIMChatroomQueueUpdateRequest *)request
432 completion:(nullable NIMChatroomHandler)completion;
433
434
435/**
436 * 移除聊天室队列元素,权限由 NIMChatroom 的 queueModificationLevel 决定
437 *
438 * @param request 拉取请求
439 * @param completion 请求回调
440 */
441- (void)removeChatroomQueueObject:(NIMChatroomQueueRemoveRequest *)request
442 completion:(nullable NIMChatroomQueueRemoveHandler)completion;
443
444
445/**
446 * 获取聊天室队列
447 *
448 * @param roomId 聊天室ID
449 * @param completion 请求回调
450 */
451- (void)fetchChatroomQueue:(NSString *)roomId
452 completion:(nullable NIMChatroomQueueInfoHandler)completion;
453
454
455/**
456 * 删除聊天室队列,权限由 NIMChatroom 的 queueModificationLevel 决定
457 *
458 * @param roomId 聊天室ID
459 * @param completion 请求回调
460 */
461- (void)dropChatroomQueue:(NSString *)roomId
462 completion:(nullable NIMChatroomHandler)completion;
463
464
465/**
466 * 批量更新聊天室通用队列元素,权限由 NIMChatroom 的 queueModificationLevel 决定
467 *
468 * @param request 聊天室队列批量请求
469 * @param completion 请求回调
470 */
471- (void)batchUpdateChatroomQueueObject:(NIMChatroomQueueBatchUpdateRequest *)request
472 completion:(nullable NIMChatroomQueueBatchUpdateHandler)completion;
473
474
475/**
476 * 添加通知对象
477 *
478 * @param delegate 通知对象
479 */
480- (void)addDelegate:(id<NIMChatroomManagerDelegate>)delegate;
481
482/**
483 * 移除通知对象
484 *
485 * @param delegate 通知对象
486 */
487- (void)removeDelegate:(id<NIMChatroomManagerDelegate>)delegate;
488
489@end
490
491
492NS_ASSUME_NONNULL_END
void(^ NIMChatroomMembersHandler)(NSError *__nullable error, NSArray< NIMChatroomMember * > *__nullable members)
Definition: NIMChatroomManagerProtocol.h:75
NSString *(^ NIMProvideChatroomDynamicTokenHandler)(NSString *__nullable roomId, NSString *__nullable account)
Definition: NIMChatroomManagerProtocol.h:129
void(^ NIMChatroomInfoHandler)(NSError *__nullable error, NIMChatroom *__nullable chatroom)
Definition: NIMChatroomManagerProtocol.h:68
void(^ NIMChatroomMemberHandler)(NSError *__nullable error, NIMChatroomMember *__nullable member)
Definition: NIMChatroomManagerProtocol.h:50
void(^ NIMFetchChatroomHistoryBlock)(NSError *__nullable error, NSArray< NIMMessage * > *__nullable messages)
Definition: NIMChatroomManagerProtocol.h:115
NIMChatroomKickReason
Definition: NIMChatroomManagerProtocol.h:158
@ NIMChatroomKickReasonByConflictLogin
Definition: NIMChatroomManagerProtocol.h:170
@ NIMChatroomKickReasonBlacklist
Definition: NIMChatroomManagerProtocol.h:174
@ NIMChatroomKickReasonByManager
Definition: NIMChatroomManagerProtocol.h:166
@ NIMChatroomKickReasonInvalidRoom
Definition: NIMChatroomManagerProtocol.h:162
void(^ NIMChatroomHandler)(NSError *__nullable error)
Definition: NIMChatroomManagerProtocol.h:42
void(^ NIMChatroomEnterHandler)(NSError *__nullable error, NIMChatroom *__nullable chatroom, NIMChatroomMember *__nullable me)
Definition: NIMChatroomManagerProtocol.h:59
void(^ NIMChatroomQueueRemoveHandler)(NSError *__nullable error, NSDictionary< NSString *, NSString * > *__nullable element)
Definition: NIMChatroomManagerProtocol.h:97
void(^ NIMChatroomQueueInfoHandler)(NSError *__nullable error, NSArray< NSDictionary< NSString *, NSString * > * > *__nullable info)
Definition: NIMChatroomManagerProtocol.h:89
void(^ NIMGetMessagesByTagsHandler)(NSError *__nullable error, NSArray< NIMMessage * > *__nullable messages)
Definition: NIMChatroomManagerProtocol.h:124
NIMChatroomConnectionState
Definition: NIMChatroomManagerProtocol.h:136
@ NIMChatroomConnectionStateEnterOK
Definition: NIMChatroomManagerProtocol.h:144
@ NIMChatroomConnectionStateLoseConnection
Definition: NIMChatroomManagerProtocol.h:152
@ NIMChatroomConnectionStateEntering
Definition: NIMChatroomManagerProtocol.h:140
@ NIMChatroomConnectionStateEnterFailed
Definition: NIMChatroomManagerProtocol.h:148
void(^ NIMChatroomMembersCountHandler)(NSError *__nullable error, uint64_t count)
Definition: NIMChatroomManagerProtocol.h:82
void(^ NIMChatroomQueueBatchUpdateHandler)(NSError *__nullable error, NSArray< NSString * > *__nullable elements)
Definition: NIMChatroomManagerProtocol.h:106
Definition: NIMChatroomBeKickedResult.h:16
Definition: NIMChatroomEnterRequest.h:91
Definition: NIMChatroomTagRequest.h:53
Definition: NIMChatroom.h:32
Definition: NIMChatroomTagRequest.h:96
Definition: NIMChatroomMember.h:47
Definition: NIMChatroomMemberRequest.h:143
Definition: NIMChatroomMemberRequest.h:181
Definition: NIMChatroomMemberRequest.h:61
Definition: NIMChatroomMemberRequest.h:114
Definition: NIMChatroomMemberRequest.h:92
Definition: NIMChatroomTagRequest.h:82
Definition: NIMChatroomQueueRequest.h:71
Definition: NIMChatroomQueueRequest.h:51
Definition: NIMChatroomQueueRequest.h:16
Definition: NIMChatroomTagsUpdateEvent.h:13
Definition: NIMChatroomTagRequest.h:120
Definition: NIMChatroomTagRequest.h:14
Definition: NIMChatroomUpdateRequest.h:46
Definition: NIMGetMessagesByTagsParam.h:10
Definition: NIMMessageSearchOption.h:111
Definition: NIMMessage.h:91