本文整理汇总了C++中OCRepresentation::getPayload方法的典型用法代码示例。如果您正苦于以下问题:C++ OCRepresentation::getPayload方法的具体用法?C++ OCRepresentation::getPayload怎么用?C++ OCRepresentation::getPayload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OCRepresentation
的用法示例。
在下文中一共展示了OCRepresentation::getPayload方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onGet
// Callback handler on GET request
void onGet(const HeaderOptions &headerOptions, const OCRepresentation &rep, const int eCode)
{
(void)headerOptions;
try
{
if (eCode == OC_STACK_OK)
{
std::cout << "GET request was successful" << std::endl;
std::cout << "Resource URI: " << rep.getUri() << std::endl;
std::cout << "Payload: " << rep.getPayload() << std::endl;
rep.getValue("on-off", mylight.m_on_off);
rep.getValue("dim", mylight.m_dim);
rep.getValue("color", mylight.m_color);
std::cout << "\ton-off: " << mylight.m_on_off << std::endl;
std::cout << "\tcolor: " << mylight.m_color << std::endl;
std::cout << "\tdim: " << mylight.m_dim << std::endl;
putLightRepresentation(curResource);
}
else
{
std::cout << "onGET Response error: " << eCode << std::endl;
}
}
catch (std::exception &e)
{
std::cout << "Exception: " << e.what() << " in onGet" << std::endl;
}
}
示例2: onGetForDISensor
void onGetForDISensor(const HeaderOptions &headerOptions, const OCRepresentation &rep,
const int eCode)
{
(void)headerOptions;
try
{
if (eCode == OC_STACK_OK)
{
std::cout << "GET request was successful" << std::endl;
std::cout << "Resource URI: " << DISensorResource->uri() << std::endl;
std::cout << "Payload: " << rep.getPayload() << std::endl;
std::cout << "\tdiscomfortIndex: " << rep.getValue<std::string>("discomfortIndex") << std::endl;
}
else
{
std::cout << "onGET Response error: " << eCode << std::endl;
}
}
catch (std::exception &e)
{
std::cout << "Exception: " << e.what() << " in onPut" << std::endl;
}
}
示例3: handleLoginoutCB
void handleLoginoutCB(const HeaderOptions &,
const OCRepresentation &rep, const int ecode)
{
cout << "Auth response received code: " << ecode << endl;
if (rep.getPayload() != NULL)
{
printRepresentation(rep);
}
if (ecode == 4)
{
g_accesstoken = rep.getValueToString("accesstoken");
g_uid = rep.getValueToString("uid");
}
g_callbackLock.notify_all();
}