NIM SDK API  9.0.0
nim_cpp_rts.h
Go to the documentation of this file.
1 
7 #ifndef _NIM_SDK_CPP_RTS_H_
8 #define _NIM_SDK_CPP_RTS_H_
9 
10 #include <functional>
11 #include <string>
13 #include "nim_define_include.h"
14 #include "nim_wrapper_util/nim_json_util.h"
15 #include "public_defines.h"
16 
21 namespace nim {
22 
24 NIM_SDK_CPPWRAPPER_DLL_API struct RtsStartInfo {
27  bool data_record_;
29  std::string apns_;
30  std::string custom_info_;
31  bool push_enable_;
32  bool need_badge_;
33  bool need_nick_;
34  std::string payload_;
35  std::string sound_;
36  bool keepcalling_;
37  bool webrtc_;
38  std::string session_id_;
40  RtsStartInfo() {
41  custom_video_ = false;
42  custom_audio_ = false;
43  data_record_ = false;
44  audio_record_ = false;
45  push_enable_ = true;
46  need_badge_ = true;
47  need_nick_ = true;
48  keepcalling_ = true;
49  webrtc_ = false;
50  }
51  std::string GetJsonStr() {
52  std::string json;
53  nim_cpp_wrapper_util::Json::Value values_temp;
54  values_temp[nim::kNIMRtsVChatCustomAudio] = custom_audio_ ? 1 : 0;
55  values_temp[nim::kNIMRtsVChatCustomVideo] = custom_video_ ? 1 : 0;
56  values_temp[nim::kNIMRtsDataRecord] = data_record_ ? 1 : 0;
57  values_temp[nim::kNIMRtsAudioRecord] = audio_record_ ? 1 : 0;
58  values_temp[nim::kNIMRtsApnsText] = apns_;
59  values_temp[nim::kNIMRtsCreateCustomInfo] = custom_info_;
60  values_temp[nim::kNIMRtsPushEnable] = push_enable_ ? 1 : 0;
61  values_temp[nim::kNIMRtsNeedBadge] = need_badge_ ? 1 : 0;
62  values_temp[nim::kNIMRtsNeedFromNick] = need_nick_ ? 1 : 0;
63  values_temp[nim::kNIMRtsApnsPayload] = payload_;
64  values_temp[nim::kNIMRtsSound] = sound_;
65  values_temp[nim::kNIMRtsKeepCalling] = keepcalling_ ? 1 : 0;
66  values_temp[nim::kNIMRtsWebRtc] = webrtc_ ? 1 : 0;
67  values_temp[nim::kNIMRtsSessionId] = session_id_;
68  nim_cpp_wrapper_util::Json::FastWriter fs;
69  json = fs.write(values_temp);
70  return json;
71  }
72 };
73 
77 class NIM_SDK_CPPWRAPPER_DLL_API Rts {
78 public:
79  typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, int channel_type, const std::string& uid)>
80  StartChannelCallback;
81  typedef std::function<void(const std::string& session_id, int channel_type, const std::string& uid, const std::string& custom_info)>
82  StartNotifyCallback;
83  typedef std::function<void(nim::NIMResCode res_code)> CreateConfCallback;
84  typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, int64_t channel_id, const std::string& custom_info)>
85  JoinConfCallback;
86  typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, int channel_type, bool accept)> AckCallback;
87  typedef std::function<void(const std::string& session_id, int channel_type, bool accept, const std::string& uid)> AckNotifyCallback;
88  typedef std::function<void(const std::string& session_id, int channel_type, bool accept)> SyncAckNotifyCallback;
89  typedef std::function<void(const std::string& session_id, int channel_type, int code, const std::string& json)> ConnectNotifyCallback;
90  typedef std::function<void(const std::string& session_id, int channel_type, const std::string& uid, int code, int leave_type)>
91  MemberNotifyCallback;
92  typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id)> HangupCallback;
93  typedef std::function<void(const std::string& session_id, const std::string& uid)> HangupNotifyCallback;
94  typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, const std::string& info)> ControlCallback;
95  typedef std::function<void(const std::string& session_id, const std::string& info, const std::string& uid)> ControlNotifyCallback;
96  typedef std::function<void(const std::string& session_id, int channel_type, const std::string& uid, const std::string& data)> RecDataCallback;
97  typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, int channel_type, const std::string& json)> OptCallback;
98 
108  static void SetProxy(NIMProxyType type, const std::string& host, int port, const std::string& user, const std::string& password);
109  // 发起相关
125  static void StartChannel(int channel_type, const std::string& uid, RtsStartInfo info, const StartChannelCallback& cb);
126 
135  static void SetStartNotifyCb(const StartNotifyCallback& cb);
136 
146  static void CreateConf(const std::string& name, const std::string& custom_info, const CreateConfCallback& cb);
147 
158  static void JoinConf(const std::string& name, const std::string& session_id, bool record, const JoinConfCallback& cb);
159 
170  static void Ack(const std::string& session_id, int channel_type, bool accept, bool data_record, bool audio_record, const AckCallback& cb);
171 
179  static void SetAckNotifyCb(const AckNotifyCallback& cb);
180 
186  static void SetSyncAckNotifyCb(const SyncAckNotifyCallback& cb);
187 
188  // 状态回调相关
194  static void SetConnectNotifyCb(const ConnectNotifyCallback& cb);
195 
202  static void SetMemberChangeCb(const MemberNotifyCallback& cb);
203 
204  // 控制接口
212  static void Control(const std::string& session_id, const std::string& info, const ControlCallback& cb);
213 
219  static void SetControlNotifyCb(const ControlNotifyCallback& cb);
220 
227  static void SetVChatMode(const std::string& session_id, int mode);
228 
229  // 结束相关
236  static void Hangup(const std::string& session_id, const HangupCallback& cb);
237 
243  static void SetHangupNotifyCb(const HangupNotifyCallback& cb);
244 
252  static void Relogin(const std::string& session_id, int channel_type, OptCallback cb);
253 
254  // 数据相关
264  static void SendData(const std::string& session_id, int channel_type, const std::string& data, const std::string& uid = "");
265 
272  static void SetRecDataCb(const RecDataCallback& cb);
273 };
274 
275 } // namespace nim
276 
277 #endif //_NIM_SDK_CPP_RTS_H_
nim::RtsStartInfo::custom_info_
std::string custom_info_
Definition: nim_cpp_rts.h:30
nim::RtsStartInfo::need_badge_
bool need_badge_
Definition: nim_cpp_rts.h:32
nim::RtsStartInfo::apns_
std::string apns_
Definition: nim_cpp_rts.h:29
nim::RtsStartInfo
点对点白板发起的参数信息
Definition: nim_cpp_rts.h:24
nim::RtsStartInfo::keepcalling_
bool keepcalling_
Definition: nim_cpp_rts.h:36
nim::RtsStartInfo::audio_record_
bool audio_record_
Definition: nim_cpp_rts.h:28
nim::RtsStartInfo::webrtc_
bool webrtc_
Definition: nim_cpp_rts.h:37
nim::RtsStartInfo::custom_video_
bool custom_video_
Definition: nim_cpp_rts.h:25
nim
namespace nim
nim::RtsStartInfo::session_id_
std::string session_id_
Definition: nim_cpp_rts.h:38
nim::RtsStartInfo::push_enable_
bool push_enable_
Definition: nim_cpp_rts.h:31
nim::RtsStartInfo::need_nick_
bool need_nick_
Definition: nim_cpp_rts.h:33
nim::RtsStartInfo::data_record_
bool data_record_
Definition: nim_cpp_rts.h:27
nim::Rts
NIM Rts提供的相关接口
Definition: nim_cpp_rts.h:77
nim::RtsStartInfo::payload_
std::string payload_
Definition: nim_cpp_rts.h:34
nim::RtsStartInfo::custom_audio_
bool custom_audio_
Definition: nim_cpp_rts.h:26
nim_sdk_cpp_wrapper.h
定义导出宏
nim::RtsStartInfo::sound_
std::string sound_
Definition: nim_cpp_rts.h:35