linux开发板改sdk教程,Linux SDK 集成说明
发布日期:2022-02-03 04:38:37 浏览次数:16 分类:技术文章

本文共 918 字,大约阅读时间需要 3 分钟。

接收消息需要实现 EMChatManagerListener 的 onReceiveMessage() 方法并且注册该listener。

class Chat : public easemob::EMChatManagerListener {

void onReceiveMessage(const easemob::EMMessageList &messages);

}

chatClient->getChatManager().addListener(this);

发送消息需要创建 EMMessage 实例,目前支持文本、图片、音频文件等消息类型。

EMTextMessageBody* body = new EMTextMessageBody("How are you, du");

easemob::EMMessagePtr msg = EMMessage::createSendMessage(loginUser, to, body);

easemob::EMCallbackPtr callback(new easemob::EMCallback(mHandle,

[=]()->bool{

window_->AddOutput("Msg send success");

return true;

},

[=](const easemob::EMErrorPtr error)->bool{

window_->AddOutput( "Send message failed: " + error->mDescription);

return true;

}));

msg->setCallback(callback);

chatClient->getChatManager().sendMessage(msg);

请注意 callback 的定义,为了能够获知 callback 的拥有者是否仍然存在,需要在您的类中定义EMCallbackObserverHandle。

easemob::EMCallbackObserverHandle mHandle;

具体接口说明及使用可以参考 SDK 中的文档和 demo 程序。

转载地址:https://blog.csdn.net/weixin_30596151/article/details/116841410 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:linux 查看网络 历史,Linux历史命令操作记录查询
下一篇:linux系统怎样安装gcc,在QuickLinux系统中安装GCC的详细步骤是怎样的?

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2024年04月14日 08时02分09秒