NIM PC Cross Platform SDK
nim_chatroom_cpp.h
Go to the documentation of this file.
1
7#ifndef _NIM_CHATROOM_SDK_CPP_H_
8#define _NIM_CHATROOM_SDK_CPP_H_
9
10#include <functional>
11#include <list>
12#include <string>
15#include "nim_chatroom_def.h"
16
21namespace nim_chatroom {
25class NIM_CHATROOM_SDK_CPPWRAPPER_DLL_API ChatRoom {
26public:
27 typedef std::function<void(const std::function<void()>&)> SDKClosure;
29 typedef std::function<
30 void(int64_t room_id, const NIMChatRoomEnterStep step, int error_code, const ChatRoomInfo& info, const ChatRoomMemberInfo& my_info)>
33 typedef std::function<void(int64_t room_id, int error_code, NIMChatRoomExitReason exit_reason)> ExitCallback;
35 typedef std::function<void(int64_t room_id, int error_code, const NIMChatRoomExitReasonInfo& exit_info)> ExitCallback_2;
37 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomMessage& result)> SendMsgAckCallback;
39 typedef std::function<void(int64_t room_id, const ChatRoomMessage& result)> ReceiveMsgCallback;
41 typedef std::function<void(int64_t room_id, const std::list<ChatRoomMessage>& result)> ReceiveMsgsCallback;
43 typedef std::function<void(int64_t room_id, const ChatRoomNotification& notification)> NotificationCallback;
45 typedef std::function<void(int64_t room_id, int error_code, const std::list<ChatRoomMemberInfo>& infos)> GetMembersCallback;
47 typedef std::function<void(int64_t room_id, int error_code, uint64_t)> GetMembersCountByTagCallback;
49 typedef std::function<void(int64_t room_id, int error_code, const std::list<ChatRoomMessage>& msgs)> GetMsgHistoryCallback;
51 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomMemberInfo& info)> SetMemberAttributeCallback;
53 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomInfo& info)> GetChatRoomInfoCallback;
55 typedef std::function<void(int64_t room_id, int error_code)> KickMemberCallback;
57 typedef std::function<void(int64_t room_id, const NIMChatRoomLinkCondition condition)> LinkConditionCallback;
59 typedef std::function<void(int64_t room_id, const std::string& new_tag)> TagsChangedCallback;
61 typedef std::function<void(std::string& token)> CustomTokenCallback;
75 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomQueueElement& element)> QueuePollCallback;
77 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomQueue& queue)> QueueListCallback;
83 typedef std::function<void(int rescode, const RobotInfos& infos)> RobotQueryCallback;
85 typedef std::function<void(int64_t room_id, int error_code, const std::list<std::string>& not_in_queue)> QueueBatchUpdateCallback;
87 typedef std::function<void(const std::string& text)> SDKLogCallback;
88
89public:
96 static void RegEnterCb(const EnterCallback& cb, const std::string& json_extension = "");
97
104 static void RegExitCb(const ExitCallback& cb, const std::string& json_extension = "");
105
112 static void RegExitCb_2(const ExitCallback_2& cb, const std::string& json_extension = "");
113
120 static void RegSendMsgAckCb(const SendMsgAckCallback& cb, const std::string& json_extension = "");
121
128 static void RegReceiveMsgCb(const ReceiveMsgCallback& cb, const std::string& json_extension = "");
129
136 static void RegReceiveMsgsCb(const ReceiveMsgsCallback& cb, const std::string& json_extension = "");
137
144 static void RegNotificationCb(const NotificationCallback& cb, const std::string& json_extension = "");
145
152 static void RegLinkConditionCb(const LinkConditionCallback& cb, const std::string& json_extension = "");
153
154 static void RegTagsChangedCb(const TagsChangedCallback& cb, const std::string& json_extension = "");
155
162 static void RegCustomTokenCb(const CustomTokenCallback& cb, const std::string& json_extension = "");
163
169 static void RegSDKLogCallback(const SDKLogCallback& callback);
170
177 static bool Init(const std::string& app_install_dir, const std::string& json_extension = "");
178
179#ifdef CPPWRAPPER_DLL
185 static void SetCallbackFunction(const ChatRoom::SDKClosure& callback);
186#endif
187
193 static void Cleanup(const std::string& json_extension = "");
194
201 static bool IndependentEnter(const int64_t room_id, const ChatRoomIndependentEnterInfo& info);
202
210 static bool IndependentEnter2(const int64_t room_id, const ChatRoomIndependentEnterInfo& info, const NIMChatRoomConfigGetter config_getter);
211
221 static bool AnonymousEnter(const int64_t room_id,
222 const ChatRoomAnoymityEnterInfo& anonymity_info,
223 const ChatRoomEnterInfo& info,
224 const std::string& json_extension = "");
225
235 static bool AnonymousEnter2(const int64_t room_id,
236 const ChatRoomAnoymityEnterInfo& anonymity_info,
237 const ChatRoomEnterInfo& info,
238 const NIMChatRoomConfigGetter config_getter);
239
249 static bool Enter(const int64_t room_id,
250 const std::string& request_login_data,
251 const ChatRoomEnterInfo& info = ChatRoomEnterInfo(),
252 const std::string& json_extension = "");
253
260 static void Exit(const int64_t room_id, const std::string& json_extension = "");
261
268 static NIMChatRoomLoginState GetLoginState(const int64_t room_id, const std::string& json_extension = "");
269
276 static void SetMsgsBatchReport(bool set_batch, const std::string& json_extension = "");
277
285 static void SendMsg(const int64_t room_id, const std::string& json_msg, const std::string& json_extension = "");
286
294 static void SendMsg(const int64_t room_id, const ChatRoomMessage& message, const std::string& json_extension = "");
295
310 static std::string CreateRoomMessage(const NIMChatRoomMsgType msg_type,
311 const std::string& client_msg_id,
312 const std::string& attach,
313 const std::string& msg_body,
314 const ChatRoomMessageSetting& msg_setting,
315 int64_t timetag = 0,
316 int32_t msg_sub_type = 0,
317 const std::string& target_tags = "");
318
328 static void GetMembersOnlineAsync(const int64_t room_id,
329 const ChatRoomGetMembersParameters& parameters,
330 const GetMembersCallback& callback,
331 const std::string& json_extension = "");
332
341 static void GetMembersByTagOnlineAsync(const int64_t room_id,
342 const ChatRoomGetMembersByTagParameters& parameters,
343 const GetMembersCallback& callback,
344 const std::string& json_extension = "");
345
354 static void GetMembersCountByTagOnlineAsync(const int64_t room_id,
355 const std::string& target_tag,
356 const GetMembersCountByTagCallback& callback,
357 const std::string& json_extension);
358
368 static void GetMessageHistoryOnlineAsync(const int64_t room_id,
369 const ChatRoomGetMsgHistoryParameters& parameters,
370 const GetMsgHistoryCallback& callback,
371 const std::string& json_extension = "");
372
382 static void GetMessageHistoryByTagsOnlineAsync(const int64_t room_id,
384 const GetMsgHistoryCallback& callback,
385 const std::string& json_extension = "");
386
396 static void SetMemberAttributeOnlineAsync(const int64_t room_id,
397 const ChatRoomSetMemberAttributeParameters& parameters,
398 const SetMemberAttributeCallback& callback,
399 const std::string& json_extension = "");
400
408 static void GetInfoAsync(const int64_t room_id, const GetChatRoomInfoCallback& callback, const std::string& json_extension = "");
409
419 static void GetMemberInfoByIDsAsync(const int64_t room_id,
420 const std::list<std::string>& ids,
421 const GetMembersCallback& callback,
422 const std::string& json_extension = "");
423
434 static void KickMemberAsync(const int64_t room_id,
435 const std::string& id,
436 const std::string& notify_ext,
437 const KickMemberCallback& callback,
438 const std::string& json_extension = "");
439
449 static void SetProxy(NIMChatRoomProxyType type, const std::string& host, int port, const std::string& user, const std::string& password);
450
463 static void TempMuteMemberAsync(const int64_t room_id,
464 const std::string& accid,
465 const int64_t duration,
466 bool need_notify,
467 const std::string& notify_ext,
468 const TempMuteMemberCallback& callback,
469 const std::string& json_extension = "");
470
483 static void TempMuteMemberByTagAsync(const int64_t room_id,
484 const std::string& target_tag,
485 const int64_t duration,
486 bool need_notify,
487 const std::string& notify_ext,
488 const TempMuteMemberCallback& callback,
489 const std::string& notify_tags = "",
490 const std::string& json_extension = "");
491
504 static void UpdateRoomInfoAsync(const int64_t room_id,
505 const ChatRoomInfo& info,
506 bool need_notify,
507 const std::string& notify_ext,
508 const UpdateRoomInfoCallback& callback,
509 const std::string& json_extension = "");
510
523 static void UpdateMyRoomRoleAsync(const int64_t room_id,
524 const ChatRoomMemberInfo& info,
525 bool need_notify,
526 const std::string& notify_ext,
527 const UpdateMyRoomRoleCallback& callback,
528 const std::string& json_extension = "");
529
539 static void QueueOfferAsync(const int64_t room_id,
540 const ChatRoomQueueElement& element,
541 const QueueOfferCallback& callback,
542 const std::string& json_extension = "{\"transient\":true}");
543
554 static void QueueOfferAsyncEx(const int64_t room_id,
555 const ChatRoomQueueElement& element,
556 const ChatRoomQueueOfferOption& option,
557 const QueueOfferCallback& callback);
558
568 static void QueuePollAsync(const int64_t room_id,
569 const std::string& element_key,
570 const QueuePollCallback& callback,
571 const std::string& json_extension = "");
572
580 static void QueueListAsync(const int64_t room_id, const QueueListCallback& callback, const std::string& json_extension = "");
581
589 static void QueueHeaderAsync(const int64_t room_id, const QueueHeaderCallback& callback, const std::string& json_extension = "");
590
598 static void QueueDropAsync(const int64_t room_id, const QueueDropCallback& callback, const std::string& json_extension = "");
599
604 static void UnregChatroomCb();
605
612 static RobotInfos QueryAllRobotInfosBlock(const int64_t room_id, const std::string& json_extension = "");
613
621 static RobotInfo QueryRobotInfoByAccidBlock(const int64_t room_id, const std::string& accid, const std::string& json_extension = "");
622
632 static void GetRobotInfoAsync(const int64_t room_id,
633 const int64_t timetag,
634 const RobotQueryCallback& callback,
635 const std::string& json_extension = "");
636
646 static void QueueBatchUpdateAsync(const int64_t room_id,
647 const ChatRoomBatchMembers& batch_elements,
648 bool need_notify,
649 const std::string& notify_ext,
650 const QueueBatchUpdateCallback& callback,
651 const std::string& json_extension = "");
652
662 static bool UpdateLocation(const int64_t room_id,
663 NIMChatRoomLocation location,
664 const UpdateLocationCallback& callback,
665 const std::string& json_extension = "");
666
676 static bool UpdateTags(const int64_t room_id,
677 ChatRoomUpdateTagsInfo tags_info,
678 const UpdateTagsCallback& callback,
679 const std::string& json_extension = "");
680};
681
682} // namespace nim_chatroom
683
684#endif //_NIM_CHATROOM_SDK_CPP_H_
聊天室
Definition: nim_chatroom_cpp.h:25
KickMemberCallback UpdateMyRoomRoleCallback
更新我的信息回调
Definition: nim_chatroom_cpp.h:67
KickMemberCallback QueueDropCallback
删除麦序队列元素回调
Definition: nim_chatroom_cpp.h:79
std::function< void(int64_t room_id, const std::string &new_tag)> TagsChangedCallback
自己的聊天室 tags 信息变更回调
Definition: nim_chatroom_cpp.h:59
std::function< void(int64_t room_id, const NIMChatRoomEnterStep step, int error_code, const ChatRoomInfo &info, const ChatRoomMemberInfo &my_info)> EnterCallback
登录回调, 如果错误码为kResRoomLocalNeedRequestAgain,聊天室重连机制结束,则需要向IM服务器重新请求进入该聊天室权限
Definition: nim_chatroom_cpp.h:31
std::function< void(int64_t room_id, const ChatRoomMessage &result)> ReceiveMsgCallback
接收消息回调
Definition: nim_chatroom_cpp.h:39
std::function< void(int64_t room_id, int error_code, NIMChatRoomExitReason exit_reason)> ExitCallback
登出、被踢回调
Definition: nim_chatroom_cpp.h:33
std::function< void(const std::string &text)> SDKLogCallback
SDK系统日志回调模板
Definition: nim_chatroom_cpp.h:87
std::function< void(int64_t room_id, int error_code, const ChatRoomInfo &info)> GetChatRoomInfoCallback
获取当前聊天室信息回调
Definition: nim_chatroom_cpp.h:53
std::function< void(int64_t room_id, int error_code, const ChatRoomQueue &queue)> QueueListCallback
排序列出麦序队列所有元素回调
Definition: nim_chatroom_cpp.h:77
QueuePollCallback QueueHeaderCallback
查看麦序队列头元素回调
Definition: nim_chatroom_cpp.h:81
std::function< void(int64_t room_id, int error_code, const NIMChatRoomExitReasonInfo &exit_info)> ExitCallback_2
登出、被踢回调
Definition: nim_chatroom_cpp.h:35
std::function< void(int rescode, const RobotInfos &infos)> RobotQueryCallback
获取机器人信息事件通知回调模板
Definition: nim_chatroom_cpp.h:83
std::function< void(int64_t room_id, int error_code, const ChatRoomQueueElement &element)> QueuePollCallback
取出麦序队列元素回调
Definition: nim_chatroom_cpp.h:75
SetMemberAttributeCallback TempMuteMemberCallback
临时禁言/解禁回调
Definition: nim_chatroom_cpp.h:63
std::function< void(int64_t room_id, int error_code, const std::list< ChatRoomMemberInfo > &infos)> GetMembersCallback
在线查询成员列表回调
Definition: nim_chatroom_cpp.h:45
KickMemberCallback UpdateTagsCallback
更新聊天室标签回调
Definition: nim_chatroom_cpp.h:71
std::function< void(int64_t room_id, int error_code, const std::list< std::string > &not_in_queue)> QueueBatchUpdateCallback
队列批量更新回调
Definition: nim_chatroom_cpp.h:85
std::function< void(int64_t room_id, int error_code, const std::list< ChatRoomMessage > &msgs)> GetMsgHistoryCallback
在线查询消息历史回调
Definition: nim_chatroom_cpp.h:49
std::function< void(int64_t room_id, const ChatRoomNotification &notification)> NotificationCallback
通知回调
Definition: nim_chatroom_cpp.h:43
std::function< void(int64_t room_id, const std::list< ChatRoomMessage > &result)> ReceiveMsgsCallback
接收批量消息回调
Definition: nim_chatroom_cpp.h:41
KickMemberCallback UpdateRoomInfoCallback
更新聊天室信息回调
Definition: nim_chatroom_cpp.h:65
KickMemberCallback UpdateLocationCallback
更新聊天室中用户的位置信息回调
Definition: nim_chatroom_cpp.h:69
std::function< void(int64_t room_id, int error_code)> KickMemberCallback
踢掉指定成员回调
Definition: nim_chatroom_cpp.h:55
std::function< void(int64_t room_id, const NIMChatRoomLinkCondition condition)> LinkConditionCallback
服务连接情况回调
Definition: nim_chatroom_cpp.h:57
std::function< void(std::string &token)> CustomTokenCallback
获取自定义token回调
Definition: nim_chatroom_cpp.h:61
std::function< void(int64_t room_id, int error_code, const ChatRoomMessage &result)> SendMsgAckCallback
发送消息回执
Definition: nim_chatroom_cpp.h:37
std::function< void(int64_t room_id, int error_code, const ChatRoomMemberInfo &info)> SetMemberAttributeCallback
设置成员身份标识回调
Definition: nim_chatroom_cpp.h:51
KickMemberCallback QueueOfferCallback
新加(更新)麦序队列元素回调
Definition: nim_chatroom_cpp.h:73
std::function< void(int64_t room_id, int error_code, uint64_t)> GetMembersCountByTagCallback
在线查询成员列表回调
Definition: nim_chatroom_cpp.h:47
聊天室
Definition: nim_chatroom_def_include.h:17
std::list< ChatRoomQueueElement > ChatRoomQueue
聊天室麦序队列
Definition: nim_chatroom_helper.h:1271
std::list< RobotInfo > RobotInfos
机器人信息
Definition: nim_chatroom_helper.h:1362
聊天室 接口相关的常量函数等定义头文件
NIMChatRoomEnterStep
Definition: nim_chatroom_def.h:854
NIMChatRoomLoginState
Definition: nim_chatroom_def.h:639
NIMChatRoomLinkCondition
Definition: nim_chatroom_def.h:847
NIMChatRoomMsgType
Definition: nim_chatroom_def.h:516
NIMChatRoomExitReason
Definition: nim_chatroom_def.h:578
NIMChatRoomProxyType
Definition: nim_chatroom_def.h:863
聊天室SDK辅助方法
Definition: nim_chatroom_def.h:16
Definition: nim_chatroom_helper.h:250
聊天室批量更新成员
Definition: nim_chatroom_helper.h:1382
聊天室登录信息
Definition: nim_chatroom_helper.h:31
根据 tag 获取聊天室成员参数
Definition: nim_chatroom_helper.h:914
获取聊天室成员参数
Definition: nim_chatroom_helper.h:887
Definition: nim_chatroom_helper.h:1000
获取聊天室消息历史参数
Definition: nim_chatroom_helper.h:941
Definition: nim_chatroom_helper.h:131
聊天室信息
Definition: nim_chatroom_helper.h:336
聊天室成员信息
Definition: nim_chatroom_helper.h:1103
聊天室消息
Definition: nim_chatroom_helper.h:745
聊天室消息属性设置
Definition: nim_chatroom_helper.h:650
聊天室通知
Definition: nim_chatroom_helper.h:422
聊天室麦序队列元素
Definition: nim_chatroom_helper.h:1251
聊天室麦序添加、更新选项
Definition: nim_chatroom_helper.h:572
设置聊天室成员身份标识参数
Definition: nim_chatroom_helper.h:1070
聊天室更新标签
Definition: nim_chatroom_helper.h:1259
聊天室退出时的信息
Definition: nim_chatroom_helper.h:1274
机器人信息
Definition: nim_chatroom_helper.h:1313