NIM PC Cross Platform SDK
载入中...
搜索中...
未找到
nim_chatroom_cpp.h
浏览该文件的文档.
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
20namespace nim_chatroom {
25public:
26 typedef std::function<void(const std::function<void()>&)> SDKClosure;
28 typedef std::function<
29 void(int64_t room_id, const NIMChatRoomEnterStep step, int error_code, const ChatRoomInfo& info, const ChatRoomMemberInfo& my_info)>
32 typedef std::function<void(int64_t room_id, int error_code, NIMChatRoomExitReason exit_reason)> ExitCallback;
34 typedef std::function<void(int64_t room_id, int error_code, const NIMChatRoomExitReasonInfo& exit_info)> ExitCallback_2;
36 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomMessage& result)> SendMsgAckCallback;
38 typedef std::function<void(int64_t room_id, const ChatRoomMessage& result)> ReceiveMsgCallback;
40 typedef std::function<void(int64_t room_id, const std::list<ChatRoomMessage>& result)> ReceiveMsgsCallback;
42 typedef std::function<void(int64_t room_id, const ChatRoomNotification& notification)> NotificationCallback;
44 typedef std::function<void(int64_t room_id, int error_code, const std::list<ChatRoomMemberInfo>& infos)> GetMembersCallback;
46 typedef std::function<void(int64_t room_id, int error_code, uint64_t)> GetMembersCountByTagCallback;
48 typedef std::function<void(int64_t room_id, int error_code, const std::list<ChatRoomMessage>& msgs)> GetMsgHistoryCallback;
50 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomMemberInfo& info)> SetMemberAttributeCallback;
52 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomInfo& info)> GetChatRoomInfoCallback;
54 typedef std::function<void(int64_t room_id, int error_code)> KickMemberCallback;
56 typedef std::function<void(int64_t room_id, const NIMChatRoomLinkCondition condition)> LinkConditionCallback;
58 typedef std::function<void(int64_t room_id, const std::string& new_tag)> TagsChangedCallback;
60 typedef std::function<void(std::string& token)> CustomTokenCallback;
62 typedef std::function<void(const std::string& appkey, const std::string& account, std::string& token)> RequestTokenCallback;
64 typedef std::function<void(const std::string& appkey, const std::string& account, std::string& token)> RequestExtensionCallback;
78 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomQueueElement& element)> QueuePollCallback;
80 typedef std::function<void(int64_t room_id, int error_code, const ChatRoomQueue& queue)> QueueListCallback;
86 typedef std::function<void(int rescode, const RobotInfos& infos)> RobotQueryCallback;
88 typedef std::function<void(int64_t room_id, int error_code, const std::list<std::string>& not_in_queue)> QueueBatchUpdateCallback;
90 typedef std::function<void(const std::string& text)> SDKLogCallback;
91
92public:
99 static void RegEnterCb(const EnterCallback& cb, const std::string& json_extension = "");
100
107 static void RegExitCb(const ExitCallback& cb, const std::string& json_extension = "");
108
115 static void RegExitCb_2(const ExitCallback_2& cb, const std::string& json_extension = "");
116
123 static void RegSendMsgAckCb(const SendMsgAckCallback& cb, const std::string& json_extension = "");
124
131 static void RegReceiveMsgCb(const ReceiveMsgCallback& cb, const std::string& json_extension = "");
132
139 static void RegReceiveMsgsCb(const ReceiveMsgsCallback& cb, const std::string& json_extension = "");
140
147 static void RegNotificationCb(const NotificationCallback& cb, const std::string& json_extension = "");
148
155 static void RegLinkConditionCb(const LinkConditionCallback& cb, const std::string& json_extension = "");
156
157 static void RegTagsChangedCb(const TagsChangedCallback& cb, const std::string& json_extension = "");
158
165 static void RegCustomTokenCb(const CustomTokenCallback& cb, const std::string& json_extension = "");
166
173 static void RegRequestLoginTokenCb(const RequestTokenCallback& cb, const std::string& json_extension = "");
174
184 static void RegRequestLoginExtensionCb(const RequestExtensionCallback& cb, const std::string& json_extension = "");
185
191 static void RegSDKLogCallback(const SDKLogCallback& callback);
192
199 static bool Init(const std::string& app_install_dir, const std::string& json_extension = "");
200
201#ifdef CPPWRAPPER_DLL
207 static void SetCallbackFunction(const ChatRoom::SDKClosure& callback);
208#endif
209
215 static void Cleanup(const std::string& json_extension = "");
216
223 static bool IndependentEnter(const int64_t room_id, const ChatRoomIndependentEnterInfo& info);
224
245 static bool IndependentEnter2(const int64_t room_id, const ChatRoomIndependentEnterInfo& info, const NIMChatRoomConfigGetter config_getter);
246
256 static bool AnonymousEnter(const int64_t room_id,
257 const ChatRoomAnoymityEnterInfo& anonymity_info,
258 const ChatRoomEnterInfo& info,
259 const std::string& json_extension = "");
260
270 static bool AnonymousEnter2(const int64_t room_id,
271 const ChatRoomAnoymityEnterInfo& anonymity_info,
272 const ChatRoomEnterInfo& info,
273 const NIMChatRoomConfigGetter config_getter);
274
284 static bool Enter(const int64_t room_id,
285 const std::string& request_login_data,
286 const ChatRoomEnterInfo& info = ChatRoomEnterInfo(),
287 const std::string& json_extension = "");
288
295 static void Exit(const int64_t room_id, const std::string& json_extension = "");
296
303 static NIMChatRoomLoginState GetLoginState(const int64_t room_id, const std::string& json_extension = "");
304
311 static void SetMsgsBatchReport(bool set_batch, const std::string& json_extension = "");
312
320 static void SendMsg(const int64_t room_id, const std::string& json_msg, const std::string& json_extension = "");
321
329 static void SendMsg(const int64_t room_id, const ChatRoomMessage& message, const std::string& json_extension = "");
330
345 static std::string CreateRoomMessage(const NIMChatRoomMsgType msg_type,
346 const std::string& client_msg_id,
347 const std::string& attach,
348 const std::string& msg_body,
349 const ChatRoomMessageSetting& msg_setting,
350 int64_t timetag = 0,
351 int32_t msg_sub_type = 0,
352 const std::string& target_tags = "");
353
363 static void GetMembersOnlineAsync(const int64_t room_id,
364 const ChatRoomGetMembersParameters& parameters,
365 const GetMembersCallback& callback,
366 const std::string& json_extension = "");
367
376 static void GetMembersByTagOnlineAsync(const int64_t room_id,
377 const ChatRoomGetMembersByTagParameters& parameters,
378 const GetMembersCallback& callback,
379 const std::string& json_extension = "");
380
389 static void GetMembersCountByTagOnlineAsync(const int64_t room_id,
390 const std::string& target_tag,
391 const GetMembersCountByTagCallback& callback,
392 const std::string& json_extension);
393
403 static void GetMessageHistoryOnlineAsync(const int64_t room_id,
404 const ChatRoomGetMsgHistoryParameters& parameters,
405 const GetMsgHistoryCallback& callback,
406 const std::string& json_extension = "");
407
417 static void GetMessageHistoryByTagsOnlineAsync(const int64_t room_id,
419 const GetMsgHistoryCallback& callback,
420 const std::string& json_extension = "");
421
431 static void SetMemberAttributeOnlineAsync(const int64_t room_id,
432 const ChatRoomSetMemberAttributeParameters& parameters,
433 const SetMemberAttributeCallback& callback,
434 const std::string& json_extension = "");
435
443 static void GetInfoAsync(const int64_t room_id, const GetChatRoomInfoCallback& callback, const std::string& json_extension = "");
444
454 static void GetMemberInfoByIDsAsync(const int64_t room_id,
455 const std::list<std::string>& ids,
456 const GetMembersCallback& callback,
457 const std::string& json_extension = "");
458
469 static void KickMemberAsync(const int64_t room_id,
470 const std::string& id,
471 const std::string& notify_ext,
472 const KickMemberCallback& callback,
473 const std::string& json_extension = "");
474
484 static void SetProxy(NIMChatRoomProxyType type, const std::string& host, int port, const std::string& user, const std::string& password);
485
498 static void TempMuteMemberAsync(const int64_t room_id,
499 const std::string& accid,
500 const int64_t duration,
501 bool need_notify,
502 const std::string& notify_ext,
503 const TempMuteMemberCallback& callback,
504 const std::string& json_extension = "");
505
518 static void TempMuteMemberByTagAsync(const int64_t room_id,
519 const std::string& target_tag,
520 const int64_t duration,
521 bool need_notify,
522 const std::string& notify_ext,
523 const TempMuteMemberCallback& callback,
524 const std::string& notify_tags = "",
525 const std::string& json_extension = "");
526
539 static void UpdateRoomInfoAsync(const int64_t room_id,
540 const ChatRoomInfo& info,
541 bool need_notify,
542 const std::string& notify_ext,
543 const UpdateRoomInfoCallback& callback,
544 const std::string& json_extension = "");
545
558 static void UpdateMyRoomRoleAsync(const int64_t room_id,
559 const ChatRoomMemberInfo& info,
560 bool need_notify,
561 const std::string& notify_ext,
562 const UpdateMyRoomRoleCallback& callback,
563 const std::string& json_extension = "");
564
574 static void QueueOfferAsync(const int64_t room_id,
575 const ChatRoomQueueElement& element,
576 const QueueOfferCallback& callback,
577 const std::string& json_extension = "{\"transient\":true}");
578
589 static void QueueOfferAsyncEx(const int64_t room_id,
590 const ChatRoomQueueElement& element,
591 const ChatRoomQueueOfferOption& option,
592 const QueueOfferCallback& callback);
593
603 static void QueuePollAsync(const int64_t room_id,
604 const std::string& element_key,
605 const QueuePollCallback& callback,
606 const std::string& json_extension = "");
607
615 static void QueueListAsync(const int64_t room_id, const QueueListCallback& callback, const std::string& json_extension = "");
616
624 static void QueueHeaderAsync(const int64_t room_id, const QueueHeaderCallback& callback, const std::string& json_extension = "");
625
633 static void QueueDropAsync(const int64_t room_id, const QueueDropCallback& callback, const std::string& json_extension = "");
634
639 static void UnregChatroomCb();
640
647 static RobotInfos QueryAllRobotInfosBlock(const int64_t room_id, const std::string& json_extension = "");
648
656 static RobotInfo QueryRobotInfoByAccidBlock(const int64_t room_id, const std::string& accid, const std::string& json_extension = "");
657
667 static void GetRobotInfoAsync(const int64_t room_id,
668 const int64_t timetag,
669 const RobotQueryCallback& callback,
670 const std::string& json_extension = "");
671
681 static void QueueBatchUpdateAsync(const int64_t room_id,
682 const ChatRoomBatchMembers& batch_elements,
683 bool need_notify,
684 const std::string& notify_ext,
685 const QueueBatchUpdateCallback& callback,
686 const std::string& json_extension = "");
687
697 static bool UpdateLocation(const int64_t room_id,
698 NIMChatRoomLocation location,
699 const UpdateLocationCallback& callback,
700 const std::string& json_extension = "");
701
711 static bool UpdateTags(const int64_t room_id,
712 ChatRoomUpdateTagsInfo tags_info,
713 const UpdateTagsCallback& callback,
714 const std::string& json_extension = "");
715};
716
717} // namespace nim_chatroom
718
719#endif //_NIM_CHATROOM_SDK_CPP_H_
聊天室
Definition: nim_chatroom_cpp.h:24
KickMemberCallback UpdateMyRoomRoleCallback
更新我的信息回调
Definition: nim_chatroom_cpp.h:70
std::function< void(const std::string &appkey, const std::string &account, std::string &token)> RequestExtensionCallback
登录时请求第三方鉴权扩展信息回调
Definition: nim_chatroom_cpp.h:64
KickMemberCallback QueueDropCallback
删除麦序队列元素回调
Definition: nim_chatroom_cpp.h:82
std::function< void(int64_t room_id, const std::string &new_tag)> TagsChangedCallback
自己的聊天室 tags 信息变更回调
Definition: nim_chatroom_cpp.h:58
std::function< void(const std::string &appkey, const std::string &account, std::string &token)> RequestTokenCallback
获取自定义token回调
Definition: nim_chatroom_cpp.h:62
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:30
std::function< void(int64_t room_id, const ChatRoomMessage &result)> ReceiveMsgCallback
接收消息回调
Definition: nim_chatroom_cpp.h:38
std::function< void(int64_t room_id, int error_code, NIMChatRoomExitReason exit_reason)> ExitCallback
登出、被踢回调
Definition: nim_chatroom_cpp.h:32
std::function< void(const std::string &text)> SDKLogCallback
SDK系统日志回调模板
Definition: nim_chatroom_cpp.h:90
std::function< void(int64_t room_id, int error_code, const ChatRoomInfo &info)> GetChatRoomInfoCallback
获取当前聊天室信息回调
Definition: nim_chatroom_cpp.h:52
std::function< void(int64_t room_id, int error_code, const ChatRoomQueue &queue)> QueueListCallback
排序列出麦序队列所有元素回调
Definition: nim_chatroom_cpp.h:80
QueuePollCallback QueueHeaderCallback
查看麦序队列头元素回调
Definition: nim_chatroom_cpp.h:84
std::function< void(int64_t room_id, int error_code, const NIMChatRoomExitReasonInfo &exit_info)> ExitCallback_2
登出、被踢回调
Definition: nim_chatroom_cpp.h:34
std::function< void(int rescode, const RobotInfos &infos)> RobotQueryCallback
获取机器人信息事件通知回调模板
Definition: nim_chatroom_cpp.h:86
std::function< void(int64_t room_id, int error_code, const ChatRoomQueueElement &element)> QueuePollCallback
取出麦序队列元素回调
Definition: nim_chatroom_cpp.h:78
SetMemberAttributeCallback TempMuteMemberCallback
临时禁言/解禁回调
Definition: nim_chatroom_cpp.h:66
std::function< void(int64_t room_id, int error_code, const std::list< ChatRoomMemberInfo > &infos)> GetMembersCallback
在线查询成员列表回调
Definition: nim_chatroom_cpp.h:44
KickMemberCallback UpdateTagsCallback
更新聊天室标签回调
Definition: nim_chatroom_cpp.h:74
std::function< void(int64_t room_id, int error_code, const std::list< std::string > &not_in_queue)> QueueBatchUpdateCallback
队列批量更新回调
Definition: nim_chatroom_cpp.h:88
std::function< void(int64_t room_id, int error_code, const std::list< ChatRoomMessage > &msgs)> GetMsgHistoryCallback
在线查询消息历史回调
Definition: nim_chatroom_cpp.h:48
std::function< void(int64_t room_id, const ChatRoomNotification &notification)> NotificationCallback
通知回调
Definition: nim_chatroom_cpp.h:42
std::function< void(int64_t room_id, const std::list< ChatRoomMessage > &result)> ReceiveMsgsCallback
接收批量消息回调
Definition: nim_chatroom_cpp.h:40
KickMemberCallback UpdateRoomInfoCallback
更新聊天室信息回调
Definition: nim_chatroom_cpp.h:68
KickMemberCallback UpdateLocationCallback
更新聊天室中用户的位置信息回调
Definition: nim_chatroom_cpp.h:72
std::function< void(int64_t room_id, int error_code)> KickMemberCallback
踢掉指定成员回调
Definition: nim_chatroom_cpp.h:54
std::function< void(int64_t room_id, const NIMChatRoomLinkCondition condition)> LinkConditionCallback
服务连接情况回调
Definition: nim_chatroom_cpp.h:56
std::function< void(std::string &token)> CustomTokenCallback
获取自定义token回调
Definition: nim_chatroom_cpp.h:60
std::function< void(int64_t room_id, int error_code, const ChatRoomMessage &result)> SendMsgAckCallback
发送消息回执
Definition: nim_chatroom_cpp.h:36
std::function< void(int64_t room_id, int error_code, const ChatRoomMemberInfo &info)> SetMemberAttributeCallback
设置成员身份标识回调
Definition: nim_chatroom_cpp.h:50
KickMemberCallback QueueOfferCallback
新加(更新)麦序队列元素回调
Definition: nim_chatroom_cpp.h:76
std::function< void(const std::function< void()> &)> SDKClosure
Definition: nim_chatroom_cpp.h:26
std::function< void(int64_t room_id, int error_code, uint64_t)> GetMembersCountByTagCallback
在线查询成员列表回调
Definition: nim_chatroom_cpp.h:46
聊天室
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:898
NIMChatRoomLoginState
Definition: nim_chatroom_def.h:683
const char * NIMChatRoomConfigGetter
Definition: nim_chatroom_def.h:962
NIMChatRoomLinkCondition
Definition: nim_chatroom_def.h:891
NIMChatRoomMsgType
Definition: nim_chatroom_def.h:551
NIMChatRoomExitReason
Definition: nim_chatroom_def.h:614
NIMChatRoomProxyType
Definition: nim_chatroom_def.h:907
聊天室SDK辅助方法
#define NIM_CHATROOM_SDK_CPPWRAPPER_DLL_API
Definition: nim_chatroom_sdk_cpp_wrapper.h:38
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