NIM PC Cross Platform SDK
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"
15#include "public_defines.h"
16
21namespace nim {
22
24NIM_SDK_CPPWRAPPER_DLL_API struct RtsStartInfo {
34 std::string apns_;
36 std::string custom_info_;
44 std::string payload_;
46 std::string sound_;
50 bool webrtc_;
52 std::string session_id_;
53
54 RtsStartInfo() {
55 custom_video_ = false;
56 custom_audio_ = false;
57 data_record_ = false;
58 audio_record_ = false;
59 push_enable_ = true;
60 need_badge_ = true;
61 need_nick_ = true;
62 keepcalling_ = true;
63 webrtc_ = false;
64 }
65 std::string GetJsonStr() {
66 std::string json;
68 values_temp[nim::kNIMRtsVChatCustomAudio] = custom_audio_ ? 1 : 0;
69 values_temp[nim::kNIMRtsVChatCustomVideo] = custom_video_ ? 1 : 0;
70 values_temp[nim::kNIMRtsDataRecord] = data_record_ ? 1 : 0;
71 values_temp[nim::kNIMRtsAudioRecord] = audio_record_ ? 1 : 0;
72 values_temp[nim::kNIMRtsApnsText] = apns_;
74 values_temp[nim::kNIMRtsPushEnable] = push_enable_ ? 1 : 0;
75 values_temp[nim::kNIMRtsNeedBadge] = need_badge_ ? 1 : 0;
76 values_temp[nim::kNIMRtsNeedFromNick] = need_nick_ ? 1 : 0;
77 values_temp[nim::kNIMRtsApnsPayload] = payload_;
78 values_temp[nim::kNIMRtsSound] = sound_;
79 values_temp[nim::kNIMRtsKeepCalling] = keepcalling_ ? 1 : 0;
80 values_temp[nim::kNIMRtsWebRtc] = webrtc_ ? 1 : 0;
82 json = nim::GetJsonStringWithNoStyled(values_temp);
83 return json;
84 }
85};
86
90class NIM_SDK_CPPWRAPPER_DLL_API Rts {
91public:
92 typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, int channel_type, const std::string& uid)>
93 StartChannelCallback;
94 typedef std::function<void(const std::string& session_id, int channel_type, const std::string& uid, const std::string& custom_info)>
95 StartNotifyCallback;
96 typedef std::function<void(nim::NIMResCode res_code)> CreateConfCallback;
97 typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, int64_t channel_id, const std::string& custom_info)>
98 JoinConfCallback;
99 typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, int channel_type, bool accept)> AckCallback;
100 typedef std::function<void(const std::string& session_id, int channel_type, bool accept, const std::string& uid)> AckNotifyCallback;
101 typedef std::function<void(const std::string& session_id, int channel_type, bool accept)> SyncAckNotifyCallback;
102 typedef std::function<void(const std::string& session_id, int channel_type, int code, const std::string& json)> ConnectNotifyCallback;
103 typedef std::function<void(const std::string& session_id, int channel_type, const std::string& uid, int code, int leave_type)>
104 MemberNotifyCallback;
105 typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id)> HangupCallback;
106 typedef std::function<void(const std::string& session_id, const std::string& uid)> HangupNotifyCallback;
107 typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, const std::string& info)> ControlCallback;
108 typedef std::function<void(const std::string& session_id, const std::string& info, const std::string& uid)> ControlNotifyCallback;
109 typedef std::function<void(const std::string& session_id, int channel_type, const std::string& uid, const std::string& data)> RecDataCallback;
110 typedef std::function<void(nim::NIMResCode res_code, const std::string& session_id, int channel_type, const std::string& json)> OptCallback;
111
121 static void SetProxy(NIMProxyType type, const std::string& host, int port, const std::string& user, const std::string& password);
122 // 发起相关
138 static void StartChannel(int channel_type, const std::string& uid, RtsStartInfo info, const StartChannelCallback& cb);
139
148 static void SetStartNotifyCb(const StartNotifyCallback& cb);
149
159 static void CreateConf(const std::string& name, const std::string& custom_info, const CreateConfCallback& cb);
160
171 static void JoinConf(const std::string& name, const std::string& session_id, bool record, const JoinConfCallback& cb);
172
183 static void Ack(const std::string& session_id, int channel_type, bool accept, bool data_record, bool audio_record, const AckCallback& cb);
184
192 static void SetAckNotifyCb(const AckNotifyCallback& cb);
193
199 static void SetSyncAckNotifyCb(const SyncAckNotifyCallback& cb);
200
201 // 状态回调相关
207 static void SetConnectNotifyCb(const ConnectNotifyCallback& cb);
208
215 static void SetMemberChangeCb(const MemberNotifyCallback& cb);
216
217 // 控制接口
225 static void Control(const std::string& session_id, const std::string& info, const ControlCallback& cb);
226
232 static void SetControlNotifyCb(const ControlNotifyCallback& cb);
233
240 static void SetVChatMode(const std::string& session_id, int mode);
241
242 // 结束相关
249 static void Hangup(const std::string& session_id, const HangupCallback& cb);
250
256 static void SetHangupNotifyCb(const HangupNotifyCallback& cb);
257
265 static void Relogin(const std::string& session_id, int channel_type, OptCallback cb);
266
267 // 数据相关
277 static void SendData(const std::string& session_id, int channel_type, const std::string& data, const std::string& uid = "");
278
285 static void SetRecDataCb(const RecDataCallback& cb);
286};
287
288} // namespace nim
289
290#endif //_NIM_SDK_CPP_RTS_H_
NIM Rts提供的相关接口
Definition: nim_cpp_rts.h:90
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
NIMResCode
Definition: nim_chatroom_res_code_def.h:15
NIM 公共数据类型定义总的包含文件
NIMProxyType
Definition: nim_global_def.h:186
JSON辅助方法
static const char * kNIMRtsCreateCustomInfo
string 自定义数据,透传给被邀请方 nim_rts_ack无效
Definition: nim_rts_def.h:92
static const char * kNIMRtsWebRtc
int, 是否支持webrtc互通(针对点对点中的音频通话)
Definition: nim_rts_def.h:106
static const char * kNIMRtsAudioRecord
int 是否需要服务器录制音频数据 >0表示是
Definition: nim_rts_def.h:88
static const char * kNIMRtsNeedBadge
int 是否需要角标计数 >0表示是 默认是
Definition: nim_rts_def.h:96
static const char * kNIMRtsApnsText
string 推送用的文本 nim_rts_ack无效
Definition: nim_rts_def.h:90
static const char * kNIMRtsVChatCustomAudio
int 是否用自主的音频数据 >0表示是
Definition: nim_rts_def.h:84
static const char * kNIMRtsPushEnable
int 是否需要推送 >0表示是 默认是
Definition: nim_rts_def.h:94
static const char * kNIMRtsApnsPayload
string JSON格式,推送payload
Definition: nim_rts_def.h:100
static const char * kNIMRtsSound
string 推送声音
Definition: nim_rts_def.h:102
static const char * kNIMRtsSessionId
string 发起会话的标识id,将在创建点对点和多人通话时,如果填写了此参数优先使用用户填写的session_id
Definition: nim_rts_def.h:78
static const char * kNIMRtsKeepCalling
int, 是否强制持续呼叫(对方离线也会呼叫),1表示是,0表示否。默认是
Definition: nim_rts_def.h:104
static const char * kNIMRtsVChatCustomVideo
int 是否用自主的视频数据 >0表示是
Definition: nim_rts_def.h:82
static const char * kNIMRtsNeedFromNick
int 是否需要推送昵称 >0表示是 默认是
Definition: nim_rts_def.h:98
static const char * kNIMRtsDataRecord
int 是否需要服务器录制白板数据 >0表示是
Definition: nim_rts_def.h:86
定义导出宏
NIM SDK 及 NIM ChatRoom SDK 公用头文件
点对点白板发起的参数信息
Definition: nim_cpp_rts.h:24
bool need_nick_
是否需要推送昵称
Definition: nim_cpp_rts.h:42
std::string payload_
JSON格式,推送payload.
Definition: nim_cpp_rts.h:44
bool keepcalling_
是否强制持续呼叫(对方离线也会呼叫)
Definition: nim_cpp_rts.h:48
std::string custom_info_
string 自定义数据,透传给被邀请方
Definition: nim_cpp_rts.h:36
std::string apns_
推送用的文本
Definition: nim_cpp_rts.h:34
bool custom_video_
是否用自主的视频数据
Definition: nim_cpp_rts.h:26
bool webrtc_
是否支持webrtc互通(针对点对点中的音频通话)
Definition: nim_cpp_rts.h:50
bool custom_audio_
是否用自主的音频数据
Definition: nim_cpp_rts.h:28
bool data_record_
是否需要服务器录制白板数据
Definition: nim_cpp_rts.h:30
std::string session_id_
会话id
Definition: nim_cpp_rts.h:52
std::string sound_
推送声音
Definition: nim_cpp_rts.h:46
bool need_badge_
是否需要角标计数
Definition: nim_cpp_rts.h:40
bool audio_record_
是否需要服务器录制音频数据
Definition: nim_cpp_rts.h:32
bool push_enable_
是否需要推送
Definition: nim_cpp_rts.h:38