本文整理汇总了C++中Msg::search_option方法的典型用法代码示例。如果您正苦于以下问题:C++ Msg::search_option方法的具体用法?C++ Msg::search_option怎么用?C++ Msg::search_option使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Msg
的用法示例。
在下文中一共展示了Msg::search_option方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process_request
void Casan::process_request (Msg &in, Msg &out)
{
option *o ;
bool rfound = false ; // resource found
in.reset_next_option () ;
for (o = in.next_option () ; o != NULL ; o = in.next_option ())
{
if (o->optcode () == option::MO_Uri_Path)
{
// request for all resources
if (o->optlen () == (int) (sizeof CASAN_RESOURCES_ALL - 1)
&& memcmp (o->optval ((int *) 0), CASAN_RESOURCES_ALL,
sizeof CASAN_RESOURCES_ALL - 1) == 0)
{
rfound = true ;
out.set_type (COAP_TYPE_ACK) ;
out.set_id (in.get_id ()) ;
out.set_token (in.get_token ()) ;
out.set_code (COAP_CODE_OK) ;
(void) get_well_known (out) ;
}
else
{
Resource *res ;
// we benefit from the added '\0' at the end of an option
res = get_resource ((char *) o->optval ((int *) 0)) ;
if (res != NULL)
{
option *obs ;
uint32_t obsval ;
rfound = true ;
obs = in.search_option (option::MO_Observe) ;
if (obs != NULL)
obsval = obs->optval () ;
if (obs != NULL && obsval == 0)
res->observed (true, &in) ;
else
res->observed (false, NULL) ;
out.set_type (COAP_TYPE_ACK) ;
out.set_id (in.get_id ()) ;
out.set_token (in.get_token ()) ;
if (obs != NULL && obsval == 0)
{
option robs (option::MO_Observe, res->next_serial ()) ;
out.push_option (robs) ;
}
request_resource (&in, &out, res) ;
}
}
break ;
}
}
if (! rfound)
{
out.set_type (COAP_TYPE_ACK) ;
out.set_id (in.get_id ()) ;
out.set_token (in.get_token ()) ;
out.set_code (COAP_CODE_NOT_FOUND) ;
}
}