NIM SDK API  8.5.0
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 
20 namespace nim_chatroom {
24 class NIM_CHATROOM_SDK_CPPWRAPPER_DLL_API ChatRoom {
25 public:
26  typedef std::function<void(const std::function<void()>&)> SDKClosure;
27  typedef std::function<
28  void(int64_t room_id, const NIMChatRoomEnterStep step, int error_code, const ChatRoomInfo& info, const ChatRoomMemberInfo& my_info)>
30  typedef std::function<void(int64_t room_id, int error_code, NIMChatRoomExitReason exit_reason)> ExitCallback;
31  typedef std::function<void(int64_t room_id, int error_code, const NIMChatRoomExitReasonInfo& exit_info)> ExitCallback_2;
32  typedef std::function<void(int64_t room_id, int error_code, const ChatRoomMessage& result)> SendMsgAckCallback;
33  typedef std::function<void(int64_t room_id, const ChatRoomMessage& result)> ReceiveMsgCallback;
34  typedef std::function<void(int64_t room_id, const std::list<ChatRoomMessage>& result)> ReceiveMsgsCallback;
35  typedef std::function<void(int64_t room_id, const ChatRoomNotification& notification)> NotificationCallback;
36  typedef std::function<void(int64_t room_id, int error_code, const std::list<ChatRoomMemberInfo>& infos)>
38  typedef std::function<void(int64_t room_id, int error_code, uint64_t)> GetMembersCountByTagCallback;
39  typedef std::function<void(int64_t room_id, int error_code, const std::list<ChatRoomMessage>& msgs)>
41  typedef std::function<void(int64_t room_id, int error_code, const ChatRoomMemberInfo& info)>
43  typedef std::function<void(int64_t room_id, int error_code, const ChatRoomInfo& info)> GetChatRoomInfoCallback;
44  typedef std::function<void(int64_t room_id, int error_code)> KickMemberCallback;
45  typedef std::function<void(int64_t room_id, const NIMChatRoomLinkCondition condition)> LinkConditionCallback;
50  typedef std::function<void(int64_t room_id, int error_code, const ChatRoomQueueElement& element)> QueuePollCallback;
51  typedef std::function<void(int64_t room_id, int error_code, const ChatRoomQueue& queue)> QueueListCallback;
54  typedef std::function<void(int rescode, const RobotInfos& infos)> RobotQueryCallback;
55  typedef std::function<void(int64_t room_id, int error_code, const std::list<std::string>& not_in_queue)>
58 public:
65  static void RegEnterCb(const EnterCallback& cb, const std::string& json_extension = "");
66 
73  static void RegExitCb(const ExitCallback& cb, const std::string& json_extension = "");
74 
81  static void RegExitCb_2(const ExitCallback_2& cb, const std::string& json_extension = "");
82 
89  static void RegSendMsgAckCb(const SendMsgAckCallback& cb, const std::string& json_extension = "");
90 
97  static void RegReceiveMsgCb(const ReceiveMsgCallback& cb, const std::string& json_extension = "");
98 
105  static void RegReceiveMsgsCb(const ReceiveMsgsCallback& cb, const std::string& json_extension = "");
106 
113  static void RegNotificationCb(const NotificationCallback& cb, const std::string& json_extension = "");
114 
121  static void RegLinkConditionCb(const LinkConditionCallback& cb, const std::string& json_extension = "");
122 
129  static bool Init(const std::string& app_install_dir, const std::string& json_extension = "");
130 
131 #ifdef CPPWRAPPER_DLL
132 
137  static void SetCallbackFunction(const ChatRoom::SDKClosure& callback);
138 #endif
139 
145  static void Cleanup(const std::string& json_extension = "");
146 
153  static bool IndependentEnter(const int64_t room_id, const ChatRoomIndependentEnterInfo& info);
154 
162  static bool IndependentEnter2(const int64_t room_id, const ChatRoomIndependentEnterInfo& info, const NIMChatRoomConfigGetter config_getter);
163 
173  static bool AnonymousEnter(const int64_t room_id,
174  const ChatRoomAnoymityEnterInfo& anonymity_info,
175  const ChatRoomEnterInfo& info,
176  const std::string& json_extension = "");
177 
187  static bool AnonymousEnter2(const int64_t room_id,
188  const ChatRoomAnoymityEnterInfo& anonymity_info,
189  const ChatRoomEnterInfo& info,
190  const NIMChatRoomConfigGetter config_getter);
191 
201  static bool Enter(const int64_t room_id,
202  const std::string& request_login_data,
203  const ChatRoomEnterInfo& info = ChatRoomEnterInfo(),
204  const std::string& json_extension = "");
205 
212  static void Exit(const int64_t room_id, const std::string& json_extension = "");
213 
220  static NIMChatRoomLoginState GetLoginState(const int64_t room_id, const std::string& json_extension = "");
221 
228  static void SetMsgsBatchReport(bool set_batch, const std::string& json_extension = "");
229 
237  static void SendMsg(const int64_t room_id, const std::string& json_msg, const std::string& json_extension = "");
238 
253  static std::string CreateRoomMessage(const NIMChatRoomMsgType msg_type,
254  const std::string& client_msg_id,
255  const std::string& attach,
256  const std::string& msg_body,
257  const ChatRoomMessageSetting& msg_setting,
258  int64_t timetag = 0,
259  int32_t msg_sub_type = 0,
260  const std::string& target_tags = "");
261 
271  static void GetMembersOnlineAsync(const int64_t room_id,
272  const ChatRoomGetMembersParameters& parameters,
273  const GetMembersCallback& callback,
274  const std::string& json_extension = "");
275 
284  static void GetMembersByTagOnlineAsync(const int64_t room_id,
285  const ChatRoomGetMembersByTagParameters& parameters,
286  const GetMembersCallback& callback,
287  const std::string& json_extension = "");
288 
297  static void GetMembersCountByTagOnlineAsync(const int64_t room_id,
298  const std::string& target_tag,
299  const GetMembersCountByTagCallback& callback,
300  const std::string& json_extension);
301 
311  static void GetMessageHistoryOnlineAsync(const int64_t room_id,
312  const ChatRoomGetMsgHistoryParameters& parameters,
313  const GetMsgHistoryCallback& callback,
314  const std::string& json_extension = "");
315 
325  static void SetMemberAttributeOnlineAsync(const int64_t room_id,
326  const ChatRoomSetMemberAttributeParameters& parameters,
327  const SetMemberAttributeCallback& callback,
328  const std::string& json_extension = "");
329 
337  static void GetInfoAsync(const int64_t room_id, const GetChatRoomInfoCallback& callback, const std::string& json_extension = "");
338 
348  static void GetMemberInfoByIDsAsync(const int64_t room_id,
349  const std::list<std::string>& ids,
350  const GetMembersCallback& callback,
351  const std::string& json_extension = "");
352 
363  static void KickMemberAsync(const int64_t room_id,
364  const std::string& id,
365  const std::string& notify_ext,
366  const KickMemberCallback& callback,
367  const std::string& json_extension = "");
368 
378  static void SetProxy(NIMChatRoomProxyType type, const std::string& host, int port, const std::string& user, const std::string& password);
379 
392  static void TempMuteMemberAsync(const int64_t room_id,
393  const std::string& accid,
394  const int64_t duration,
395  bool need_notify,
396  const std::string& notify_ext,
397  const TempMuteMemberCallback& callback,
398  const std::string& json_extension = "");
399 
412  static void TempMuteMemberByTagAsync(const int64_t room_id,
413  const std::string& target_tag,
414  const int64_t duration,
415  bool need_notify,
416  const std::string& notify_ext,
417  const TempMuteMemberCallback& callback,
418  const std::string& notify_tags = "",
419  const std::string& json_extension = "");
420 
432  static void UpdateRoomInfoAsync(const int64_t room_id,
433  const ChatRoomInfo& info,
434  bool need_notify,
435  const std::string& notify_ext,
436  const UpdateRoomInfoCallback& callback,
437  const std::string& json_extension = "");
438 
450  static void UpdateMyRoomRoleAsync(const int64_t room_id,
451  const ChatRoomMemberInfo& info,
452  bool need_notify,
453  const std::string& notify_ext,
454  const UpdateMyRoomRoleCallback& callback,
455  const std::string& json_extension = "");
456 
466  static void QueueOfferAsync(const int64_t room_id,
467  const ChatRoomQueueElement& element,
468  const QueueOfferCallback& callback,
469  const std::string& json_extension = "{\"transient\":true}");
470 
480  static void QueuePollAsync(const int64_t room_id,
481  const std::string& element_key,
482  const QueuePollCallback& callback,
483  const std::string& json_extension = "");
484 
492  static void QueueListAsync(const int64_t room_id, const QueueListCallback& callback, const std::string& json_extension = "");
493 
501  static void QueueHeaderAsync(const int64_t room_id, const QueueHeaderCallback& callback, const std::string& json_extension = "");
502 
510  static void QueueDropAsync(const int64_t room_id, const QueueDropCallback& callback, const std::string& json_extension = "");
511 
516  static void UnregChatroomCb();
517 
524  static RobotInfos QueryAllRobotInfosBlock(const int64_t room_id, const std::string& json_extension = "");
525 
533  static RobotInfo QueryRobotInfoByAccidBlock(const int64_t room_id, const std::string& accid, const std::string& json_extension = "");
534 
544  static void GetRobotInfoAsync(const int64_t room_id,
545  const int64_t timetag,
546  const RobotQueryCallback& callback,
547  const std::string& json_extension = "");
548 
558  static void QueueBatchUpdateAsync(const int64_t room_id,
559  const ChatRoomBatchMembers& batch_elements,
560  bool need_notify,
561  const std::string& notify_ext,
562  const QueueBatchUpdateCallback& callback,
563  const std::string& json_extension = "");
564 };
565 
566 } // namespace nim_chatroom
567 
568 #endif //_NIM_CHATROOM_SDK_CPP_H_
nim_chatroom::ChatRoom::QueueBatchUpdateCallback
std::function< void(int64_t room_id, int error_code, const std::list< std::string > &not_in_queue)> QueueBatchUpdateCallback
Definition: nim_chatroom_cpp.h:56
nim_chatroom::ChatRoom::QueueOfferCallback
KickMemberCallback QueueOfferCallback
Definition: nim_chatroom_cpp.h:49
nim_chatroom_sdk_cpp_wrapper.h
定义导出宏
nim_chatroom
聊天室
nim_chatroom::ChatRoom::QueueDropCallback
KickMemberCallback QueueDropCallback
Definition: nim_chatroom_cpp.h:52
nim_chatroom::RobotInfo
机器人信息
Definition: nim_chatroom_helper.h:770
nim_chatroom::ChatRoom::GetMsgHistoryCallback
std::function< void(int64_t room_id, int error_code, const std::list< ChatRoomMessage > &msgs)> GetMsgHistoryCallback
Definition: nim_chatroom_cpp.h:40
nim_chatroom::ChatRoomGetMsgHistoryParameters
获取聊天室消息历史参数
Definition: nim_chatroom_helper.h:541
nim_chatroom::ChatRoomGetMembersByTagParameters
根据 tag 获取聊天室成员参数
Definition: nim_chatroom_helper.h:517
nim_chatroom::ChatRoomMessageSetting
聊天室消息属性设置
Definition: nim_chatroom_helper.h:346
nim_chatroom::ChatRoom::ExitCallback_2
std::function< void(int64_t room_id, int error_code, const NIMChatRoomExitReasonInfo &exit_info)> ExitCallback_2
Definition: nim_chatroom_cpp.h:31
nim_chatroom::ChatRoom::UpdateRoomInfoCallback
KickMemberCallback UpdateRoomInfoCallback
Definition: nim_chatroom_cpp.h:47
nim_chatroom::NIMChatRoomExitReasonInfo
聊天室退出时的信息
Definition: nim_chatroom_helper.h:733
nim_chatroom::ChatRoom::ReceiveMsgsCallback
std::function< void(int64_t room_id, const std::list< ChatRoomMessage > &result)> ReceiveMsgsCallback
Definition: nim_chatroom_cpp.h:34
nim_chatroom::ChatRoomQueueElement
聊天室麦序队列元素
Definition: nim_chatroom_helper.h:724
nim_chatroom::ChatRoom::GetChatRoomInfoCallback
std::function< void(int64_t room_id, int error_code, const ChatRoomInfo &info)> GetChatRoomInfoCallback
Definition: nim_chatroom_cpp.h:43
nim_chatroom::ChatRoom::QueuePollCallback
std::function< void(int64_t room_id, int error_code, const ChatRoomQueueElement &element)> QueuePollCallback
Definition: nim_chatroom_cpp.h:50
nim_chatroom::ChatRoomMessage
聊天室消息
Definition: nim_chatroom_helper.h:408
nim_chatroom::ChatRoom::ExitCallback
std::function< void(int64_t room_id, int error_code, NIMChatRoomExitReason exit_reason)> ExitCallback
Definition: nim_chatroom_cpp.h:30
nim_chatroom::ChatRoom::EnterCallback
std::function< void(int64_t room_id, const NIMChatRoomEnterStep step, int error_code, const ChatRoomInfo &info, const ChatRoomMemberInfo &my_info)> EnterCallback
Definition: nim_chatroom_cpp.h:29
nim_chatroom::ChatRoom::KickMemberCallback
std::function< void(int64_t room_id, int error_code)> KickMemberCallback
Definition: nim_chatroom_cpp.h:44
nim_chatroom::ChatRoomBatchMembers
聊天室批量更新成员
Definition: nim_chatroom_helper.h:839
nim_http::Init
void Init(const std::wstring &dll_path=L"")
Definition: nim_tools_http_cpp.h:65
nim_chatroom::ChatRoomInfo
聊天室信息
Definition: nim_chatroom_helper.h:165
nim_chatroom::ChatRoom::QueueHeaderCallback
QueuePollCallback QueueHeaderCallback
Definition: nim_chatroom_cpp.h:53
nim_chatroom::ChatRoom::RobotQueryCallback
std::function< void(int rescode, const RobotInfos &infos)> RobotQueryCallback
Definition: nim_chatroom_cpp.h:54
nim_chatroom::ChatRoomSetMemberAttributeParameters
设置聊天室成员身份标识参数
Definition: nim_chatroom_helper.h:595
nim_chatroom::ChatRoomNotification
聊天室通知
Definition: nim_chatroom_helper.h:222
nim_chatroom::ChatRoomMemberInfo
聊天室成员信息
Definition: nim_chatroom_helper.h:623
nim_chatroom::ChatRoom::SendMsgAckCallback
std::function< void(int64_t room_id, int error_code, const ChatRoomMessage &result)> SendMsgAckCallback
Definition: nim_chatroom_cpp.h:32
nim_chatroom::ChatRoomEnterInfo
聊天室登录信息
Definition: nim_chatroom_helper.h:31
nim_chatroom::ChatRoomGetMembersParameters
获取聊天室成员参数
Definition: nim_chatroom_helper.h:493
nim_chatroom_helper.h
聊天室SDK辅助方法
nim_chatroom::ChatRoom::UpdateMyRoomRoleCallback
KickMemberCallback UpdateMyRoomRoleCallback
Definition: nim_chatroom_cpp.h:48
nim_chatroom::ChatRoom::GetMembersCallback
std::function< void(int64_t room_id, int error_code, const std::list< ChatRoomMemberInfo > &infos)> GetMembersCallback
Definition: nim_chatroom_cpp.h:37
nim_chatroom::ChatRoom::ReceiveMsgCallback
std::function< void(int64_t room_id, const ChatRoomMessage &result)> ReceiveMsgCallback
Definition: nim_chatroom_cpp.h:33
nim_chatroom::ChatRoom::LinkConditionCallback
std::function< void(int64_t room_id, const NIMChatRoomLinkCondition condition)> LinkConditionCallback
Definition: nim_chatroom_cpp.h:45
nim_chatroom::ChatRoomQueue
std::list< ChatRoomQueueElement > ChatRoomQueue
聊天室麦序队列
Definition: nim_chatroom_helper.h:730
nim_chatroom::ChatRoom::TempMuteMemberCallback
SetMemberAttributeCallback TempMuteMemberCallback
Definition: nim_chatroom_cpp.h:46
nim_chatroom::ChatRoom::NotificationCallback
std::function< void(int64_t room_id, const ChatRoomNotification &notification)> NotificationCallback
Definition: nim_chatroom_cpp.h:35
nim_chatroom::ChatRoom
聊天室
Definition: nim_chatroom_cpp.h:24
nim_chatroom::ChatRoomIndependentEnterInfo
Definition: nim_chatroom_helper.h:90
nim_chatroom::ChatRoom::GetMembersCountByTagCallback
std::function< void(int64_t room_id, int error_code, uint64_t)> GetMembersCountByTagCallback
Definition: nim_chatroom_cpp.h:38
nim_chatroom::ChatRoomAnoymityEnterInfo
Definition: nim_chatroom_helper.h:125
nim_chatroom::ChatRoom::QueueListCallback
std::function< void(int64_t room_id, int error_code, const ChatRoomQueue &queue)> QueueListCallback
Definition: nim_chatroom_cpp.h:51
nim_chatroom::ChatRoom::SetMemberAttributeCallback
std::function< void(int64_t room_id, int error_code, const ChatRoomMemberInfo &info)> SetMemberAttributeCallback
Definition: nim_chatroom_cpp.h:42