NIM 跨平台 C++ SDK
载入中...
搜索中...
未找到
nim_cpp_rts.h
浏览该文件的文档.
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"
15
20namespace nim {
21
33 std::string apns_;
35 std::string custom_info_;
43 std::string payload_;
45 std::string sound_;
49 bool webrtc_;
51 std::string session_id_;
52
54 custom_video_ = false;
55 custom_audio_ = false;
56 data_record_ = false;
57 audio_record_ = false;
58 push_enable_ = true;
59 need_badge_ = true;
60 need_nick_ = true;
61 keepcalling_ = true;
62 webrtc_ = false;
63 }
64 std::string GetJsonStr() {
65 std::string json;
67 values_temp[nim::kNIMRtsVChatCustomAudio] = custom_audio_ ? 1 : 0;
68 values_temp[nim::kNIMRtsVChatCustomVideo] = custom_video_ ? 1 : 0;
69 values_temp[nim::kNIMRtsDataRecord] = data_record_ ? 1 : 0;
70 values_temp[nim::kNIMRtsAudioRecord] = audio_record_ ? 1 : 0;
71 values_temp[nim::kNIMRtsApnsText] = apns_;
72 values_temp[nim::kNIMRtsCreateCustomInfo] = custom_info_;
73 values_temp[nim::kNIMRtsPushEnable] = push_enable_ ? 1 : 0;
74 values_temp[nim::kNIMRtsNeedBadge] = need_badge_ ? 1 : 0;
75 values_temp[nim::kNIMRtsNeedFromNick] = need_nick_ ? 1 : 0;
76 values_temp[nim::kNIMRtsApnsPayload] = payload_;
77 values_temp[nim::kNIMRtsSound] = sound_;
78 values_temp[nim::kNIMRtsKeepCalling] = keepcalling_ ? 1 : 0;
79 values_temp[nim::kNIMRtsWebRtc] = webrtc_ ? 1 : 0;
80 values_temp[nim::kNIMRtsSessionId] = session_id_;
81 json = nim::GetJsonStringWithNoStyled(values_temp);
82 return json;
83 }
84};
85
90public:
91 typedef std::function<void(NIMResCode res_code, const std::string& session_id, int channel_type, const std::string& uid)> StartChannelCallback;
92 typedef std::function<void(const std::string& session_id, int channel_type, const std::string& uid, const std::string& custom_info)>
94 typedef std::function<void(NIMResCode res_code)> CreateConfCallback;
95 typedef std::function<void(NIMResCode res_code, const std::string& session_id, int64_t channel_id, const std::string& custom_info)>
97 typedef std::function<void(NIMResCode res_code, const std::string& session_id, int channel_type, bool accept)> AckCallback;
98 typedef std::function<void(const std::string& session_id, int channel_type, bool accept, const std::string& uid)> AckNotifyCallback;
99 typedef std::function<void(const std::string& session_id, int channel_type, bool accept)> SyncAckNotifyCallback;
100 typedef std::function<void(const std::string& session_id, int channel_type, int code, const std::string& json)> ConnectNotifyCallback;
101 typedef std::function<void(const std::string& session_id, int channel_type, const std::string& uid, int code, int leave_type)>
103 typedef std::function<void(NIMResCode res_code, const std::string& session_id)> HangupCallback;
104 typedef std::function<void(const std::string& session_id, const std::string& uid)> HangupNotifyCallback;
105 typedef std::function<void(NIMResCode res_code, const std::string& session_id, const std::string& info)> ControlCallback;
106 typedef std::function<void(const std::string& session_id, const std::string& info, const std::string& uid)> ControlNotifyCallback;
107 typedef std::function<void(const std::string& session_id, int channel_type, const std::string& uid, const std::string& data)> RecDataCallback;
108 typedef std::function<void(NIMResCode res_code, const std::string& session_id, int channel_type, const std::string& json)> OptCallback;
109
119 static void SetProxy(NIMProxyType type, const std::string& host, int port, const std::string& user, const std::string& password);
120 // 发起相关
136 static void StartChannel(int channel_type, const std::string& uid, RtsStartInfo info, const StartChannelCallback& cb);
137
146 static void SetStartNotifyCb(const StartNotifyCallback& cb);
147
157 static void CreateConf(const std::string& name, const std::string& custom_info, const CreateConfCallback& cb);
158
169 static void JoinConf(const std::string& name, const std::string& session_id, bool record, const JoinConfCallback& cb);
170
181 static void Ack(const std::string& session_id, int channel_type, bool accept, bool data_record, bool audio_record, const AckCallback& cb);
182
190 static void SetAckNotifyCb(const AckNotifyCallback& cb);
191
197 static void SetSyncAckNotifyCb(const SyncAckNotifyCallback& cb);
198
199 // 状态回调相关
205 static void SetConnectNotifyCb(const ConnectNotifyCallback& cb);
206
213 static void SetMemberChangeCb(const MemberNotifyCallback& cb);
214
215 // 控制接口
223 static void Control(const std::string& session_id, const std::string& info, const ControlCallback& cb);
224
230 static void SetControlNotifyCb(const ControlNotifyCallback& cb);
231
238 static void SetVChatMode(const std::string& session_id, int mode);
239
240 // 结束相关
247 static void Hangup(const std::string& session_id, const HangupCallback& cb);
248
254 static void SetHangupNotifyCb(const HangupNotifyCallback& cb);
255
263 static void Relogin(const std::string& session_id, int channel_type, OptCallback cb);
264
265 // 数据相关
275 static void SendData(const std::string& session_id, int channel_type, const std::string& data, const std::string& uid = "");
276
283 static void SetRecDataCb(const RecDataCallback& cb);
284};
285
286} // namespace nim
287
288#endif //_NIM_SDK_CPP_RTS_H_
NIM Rts提供的相关接口
Definition nim_cpp_rts.h:89
std::function< void(const std::string &session_id, int channel_type, const std::string &uid, const std::string &data) RecDataCallback)
Definition nim_cpp_rts.h:107
std::function< void(NIMResCode res_code)> CreateConfCallback
Definition nim_cpp_rts.h:94
std::function< void(NIMResCode res_code, const std::string &session_id, int channel_type, bool accept) AckCallback)
Definition nim_cpp_rts.h:97
std::function< void(NIMResCode res_code, const std::string &session_id, const std::string &info) ControlCallback)
Definition nim_cpp_rts.h:105
std::function< void(const std::string &session_id, int channel_type, const std::string &uid, int code, int leave_type) MemberNotifyCallback)
Definition nim_cpp_rts.h:102
std::function< void(const std::string &session_id, const std::string &info, const std::string &uid) ControlNotifyCallback)
Definition nim_cpp_rts.h:106
std::function< void(NIMResCode res_code, const std::string &session_id, int channel_type, const std::string &json) OptCallback)
Definition nim_cpp_rts.h:108
std::function< void(const std::string &session_id, const std::string &uid) HangupNotifyCallback)
Definition nim_cpp_rts.h:104
std::function< void(const std::string &session_id, int channel_type, const std::string &uid, const std::string &custom_info) StartNotifyCallback)
Definition nim_cpp_rts.h:93
std::function< void(const std::string &session_id, int channel_type, int code, const std::string &json) ConnectNotifyCallback)
Definition nim_cpp_rts.h:100
std::function< void(const std::string &session_id, int channel_type, bool accept) SyncAckNotifyCallback)
Definition nim_cpp_rts.h:99
std::function< void(NIMResCode res_code, const std::string &session_id, int channel_type, const std::string &uid) StartChannelCallback)
Definition nim_cpp_rts.h:91
std::function< void(const std::string &session_id, int channel_type, bool accept, const std::string &uid) AckNotifyCallback)
Definition nim_cpp_rts.h:98
std::function< void(NIMResCode res_code, const std::string &session_id) HangupCallback)
Definition nim_cpp_rts.h:103
std::function< void(NIMResCode res_code, const std::string &session_id, int64_t channel_id, const std::string &custom_info) JoinConfCallback)
Definition nim_cpp_rts.h:96
Represents a JSON value.
Definition value.h:196
namespace nim
std::string GetJsonStringWithNoStyled(const nim_cpp_wrapper_util::Json::Value &values)
获得非格式化的Json string,传入SDK的json string格式要求为非格式化的,如果是格式化的json string可能会影响功能
Definition nim_json_util.cpp:89
NIM 公共数据类型定义总的包含文件
NIMProxyType
Definition nim_global_def.h:204
JSON辅助方法
定义导出宏
#define NIM_SDK_CPPWRAPPER_DLL_API
Definition nim_sdk_cpp_wrapper.h:38
NIMResCode
Definition public_defines.h:21
点对点白板发起的参数信息
Definition nim_cpp_rts.h:23
bool need_nick_
是否需要推送昵称
Definition nim_cpp_rts.h:41
std::string payload_
JSON格式,推送payload
Definition nim_cpp_rts.h:43
bool keepcalling_
是否强制持续呼叫(对方离线也会呼叫)
Definition nim_cpp_rts.h:47
std::string custom_info_
string 自定义数据,透传给被邀请方
Definition nim_cpp_rts.h:35
std::string apns_
推送用的文本
Definition nim_cpp_rts.h:33
bool custom_video_
是否用自主的视频数据
Definition nim_cpp_rts.h:25
RtsStartInfo()
Definition nim_cpp_rts.h:53
std::string GetJsonStr()
Definition nim_cpp_rts.h:64
bool webrtc_
是否支持webrtc互通(针对点对点中的音频通话)
Definition nim_cpp_rts.h:49
bool custom_audio_
是否用自主的音频数据
Definition nim_cpp_rts.h:27
bool data_record_
是否需要服务器录制白板数据
Definition nim_cpp_rts.h:29
std::string session_id_
会话id
Definition nim_cpp_rts.h:51
std::string sound_
推送声音
Definition nim_cpp_rts.h:45
bool need_badge_
是否需要角标计数
Definition nim_cpp_rts.h:39
bool audio_record_
是否需要服务器录制音频数据
Definition nim_cpp_rts.h:31
bool push_enable_
是否需要推送
Definition nim_cpp_rts.h:37