NIM PC Cross Platform SDK
载入中...
搜索中...
未找到
v2::V2NIMMessageCreator类 参考

IM 消息创建器 更多...

#include <v2_nim_utilities.hpp>

静态 Public 成员函数

static nstd::optional< V2NIMMessagecreateTextMessage (nstd::string text)
 创建文本消息
 
static nstd::optional< V2NIMMessagecreateImageMessage (nstd::string imagePath, nstd::string name, nstd::string sceneName, uint32_t width, uint32_t height)
 创建图片消息
 
static nstd::optional< V2NIMMessagecreateAudioMessage (nstd::string audioPath, nstd::string name, nstd::string sceneName, uint32_t duration)
 创建音频消息
 
static nstd::optional< V2NIMMessagecreateVideoMessage (nstd::string videoPath, nstd::string name, nstd::string sceneName, uint32_t duration, uint32_t width, uint32_t height)
 创建视频消息
 
static nstd::optional< V2NIMMessagecreateFileMessage (nstd::string filePath, nstd::string name, nstd::string sceneName)
 创建文件消息
 
static nstd::optional< V2NIMMessagecreateLocationMessage (double latitude, double longitude, nstd::string address)
 创建位置消息
 
static nstd::optional< V2NIMMessagecreateCustomMessage (nstd::string text, nstd::string rawAttachment)
 创建自定义消息
 
static nstd::optional< V2NIMMessagecreateTipsMessage (nstd::string text)
 创建提示消息
 
static nstd::optional< V2NIMMessagecreateForwardMessage (V2NIMMessage message)
 创建转发消息
 
static nstd::optional< V2NIMMessagecreateCallMessage (int32_t type, const nstd::string &channelId, int32_t status, const nstd::vector< V2NIMMessageCallDuration > &durations, const nstd::string &text)
 构造话单消息
 

详细描述

IM 消息创建器

成员函数说明

◆ createAudioMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createAudioMessage ( nstd::string  audioPath,
nstd::string  name,
nstd::string  sceneName,
uint32_t  duration 
)
inlinestatic

创建音频消息

参数
audioPath音频路径
name文件显示名称, 为空则使用文件名
sceneName文件存储场景
duration音频时长
返回
nstd::optional<V2NIMMessage>
示例代码
auto audioMessage = V2NIMMessageCreator::createAudioMessage("audioPath", "audioName", V2NIM_STORAGE_SCENE_NAME_DEFAULT_IM, 100);
if(!audioMessage) {
// create audio message failed
}
static const char * V2NIM_STORAGE_SCENE_NAME_DEFAULT_IM
Definition: v2_nim_def_enum.hpp:1606
static nstd::optional< V2NIMMessage > createAudioMessage(nstd::string audioPath, nstd::string name, nstd::string sceneName, uint32_t duration)
创建音频消息
Definition: v2_nim_internal.hpp:154

◆ createCallMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createCallMessage ( int32_t  type,
const nstd::string channelId,
int32_t  status,
const nstd::vector< V2NIMMessageCallDuration > &  durations,
const nstd::string text 
)
inlinestatic

构造话单消息

参数
type话单类型,业务自定义,内容不校验
channelId话单频道 ID,内容不校验
status通话状态,业务自定义状态,内容不校验
durations通话成员时长列表,内容不校验
text话单描述
返回
nstd::optional<V2NIMMessage>
示例代码
auto callMessage = V2NIMMessageCreator::createCallMessage(1, "channelId", 1, {{"account1", 100}, {"account2", 200}}, "text");
if(!callMessage) {
// create call message failed
}
static nstd::optional< V2NIMMessage > createCallMessage(int32_t type, const nstd::string &channelId, int32_t status, const nstd::vector< V2NIMMessageCallDuration > &durations, const nstd::string &text)
构造话单消息
Definition: v2_nim_internal.hpp:183

◆ createCustomMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createCustomMessage ( nstd::string  text,
nstd::string  rawAttachment 
)
inlinestatic

创建自定义消息

参数
text文本内容
attachment附件
返回
nstd::optional<V2NIMMessage>
示例代码
auto customMessage = V2NIMMessageCreator::createCustomMessage("text", R"({"key": "value"})");
if(!customMessage) {
// create custom message failed
}
static nstd::optional< V2NIMMessage > createCustomMessage(nstd::string text, nstd::string rawAttachment)
创建自定义消息
Definition: v2_nim_internal.hpp:174

◆ createFileMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createFileMessage ( nstd::string  filePath,
nstd::string  name,
nstd::string  sceneName 
)
inlinestatic

创建文件消息

参数
filePath文件路径
name文件显示名称, 为空则使用文件名
sceneName文件存储场景
返回
nstd::optional<V2NIMMessage>
示例代码
if(!fileMessage) {
// create file message failed
}
static nstd::optional< V2NIMMessage > createFileMessage(nstd::string filePath, nstd::string name, nstd::string sceneName)
创建文件消息
Definition: v2_nim_internal.hpp:168

◆ createForwardMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createForwardMessage ( V2NIMMessage  message)
inlinestatic

创建转发消息

参数
message原消息
返回
nstd::optional<V2NIMMessage>
示例代码
auto forwardMessage = V2NIMMessageCreator::createForwardMessage(message);
if(!forwardMessage) {
// create forward message failed
}
static nstd::optional< V2NIMMessage > createForwardMessage(V2NIMMessage message)
创建转发消息
Definition: v2_nim_internal.hpp:180

◆ createImageMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createImageMessage ( nstd::string  imagePath,
nstd::string  name,
nstd::string  sceneName,
uint32_t  width,
uint32_t  height 
)
inlinestatic

创建图片消息

参数
imagePath图片路径
name文件显示名称, 为空则使用文件名
sceneName文件存储场景
width图片宽度
height图片高度
返回
nstd::optional<V2NIMMessage>
示例代码
auto imageMessage = V2NIMMessageCreator::createImageMessage("imagePath", "imageName", V2NIM_STORAGE_SCENE_NAME_DEFAULT_IM, 100,
100); if(!imageMessage) {
// create image message failed
}
static nstd::optional< V2NIMMessage > createImageMessage(nstd::string imagePath, nstd::string name, nstd::string sceneName, uint32_t width, uint32_t height)
创建图片消息
Definition: v2_nim_internal.hpp:147

◆ createLocationMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createLocationMessage ( double  latitude,
double  longitude,
nstd::string  address 
)
inlinestatic

创建位置消息

参数
latitude纬度
longitude经度
address详细位置信息
返回
nstd::optional<V2NIMMessage>
示例代码
auto locationMessage = V2NIMMessageCreator::createLocationMessage(100, 100, "address");
if(!locationMessage) {
// create location message failed
}
static nstd::optional< V2NIMMessage > createLocationMessage(double latitude, double longitude, nstd::string address)
创建位置消息
Definition: v2_nim_internal.hpp:171

◆ createTextMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createTextMessage ( nstd::string  text)
inlinestatic

创建文本消息

参数
text文本内容
返回
nstd::optional<V2NIMMessage>
示例代码
auto textMessage = V2NIMMessageCreator::createTextMessage("hello world");
if(!textMessage) {
// create text message failed
}
static nstd::optional< V2NIMMessage > createTextMessage(nstd::string text)
创建文本消息
Definition: v2_nim_internal.hpp:144

◆ createTipsMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createTipsMessage ( nstd::string  text)
inlinestatic

创建提示消息

参数
text文本内容
返回
nstd::optional<V2NIMMessage>
示例代码
auto tipMessage = V2NIMMessageCreator::createTipsMessage("text");
if(!tipMessage) {
// create tip message failed
}
static nstd::optional< V2NIMMessage > createTipsMessage(nstd::string text)
创建提示消息
Definition: v2_nim_internal.hpp:177

◆ createVideoMessage()

nstd::optional< V2NIMMessage > v2::V2NIMMessageCreator::createVideoMessage ( nstd::string  videoPath,
nstd::string  name,
nstd::string  sceneName,
uint32_t  duration,
uint32_t  width,
uint32_t  height 
)
inlinestatic

创建视频消息

参数
videoPath视频路径
name文件显示名称, 为空则使用文件名
sceneName文件存储场景
duration视频时长
width视频宽度
height视频高度
返回
nstd::optional<V2NIMMessage>
示例代码
auto videoMessage = V2NIMMessageCreator::createVideoMessage("videoPath", "videoName", V2NIM_STORAGE_SCENE_NAME_DEFAULT_IM, 100, 100, 100);
if (!videoMessage) {
// create video message failed
}
static nstd::optional< V2NIMMessage > createVideoMessage(nstd::string videoPath, nstd::string name, nstd::string sceneName, uint32_t duration, uint32_t width, uint32_t height)
创建视频消息
Definition: v2_nim_internal.hpp:160

该类的文档由以下文件生成: