更新时间:2022-03-21 GMT+08:00
分享

自定义通知回调类

示例代码

继承Huawei::Idea::IEventHandler,参见IEventHandler.h

IShareServiceController.h

#include "IShareServiceController.h"   
#include "IdeaShareDef.h"   
   
class IDEA_SHARE_API IShareEventHandler : public Huawei::Idea::IEventHandler{   
public:   
    ~IShareEventHandler();   
    void OnError(ShareAppErr errorCode, std::string errorMsg, void* extralInfo);   
    void OnDiscoverResult(DiscoverResult* discoverResult);   
    void OnConnectResult(DeviceInfo* deviceInfo);   
    void OnDisconnectResult(int reason);   
    void OnSharePlayResult();   
    void OnShareStopResult(int reason);   
    ....   
}

ShareEventHandler.cpp 实现

#include "IShareServiceController.h"   
#include "IdeaShareDef.h"   
   
IShareEventHandler::~IShareEventHandler() {}   
   
void IShareEventHandler::OnError(ShareAppErr errorCode, std::string errorMsg, void* extralInfo   
{   
  // 错误事件上报   
}   
void IShareEventHandler::OnDiscoverResult(DiscoverResult* discoverResult)   
{   
  //投屏码查询   
}   
void IShareEventHandler::OnConnectResult(DeviceInfo* deviceInfo)   
{   
   // 连接事件上报   
}   
void IShareEventHandler::OnDisconnectResult(int reason)   
{   
   //断开连接事件上报   
}   
void IShareEventHandler::OnSharePlayResult()   
{   
  // 开始共享事件上报   
}   
void IShareEventHandler::OnShareStopResult(int reason)   
{   
   //结束共享事件上报   
}   
.....

详情参见4.6.4 通知参考。

分享:

    相关文档

    相关产品