本文整理汇总了C++中Browser::add_service方法的典型用法代码示例。如果您正苦于以下问题:C++ Browser::add_service方法的具体用法?C++ Browser::add_service怎么用?C++ Browser::add_service使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Browser
的用法示例。
在下文中一共展示了Browser::add_service方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: resolve_callback
void Browser::resolve_callback(AvahiServiceResolver *r,
AvahiIfIndex,
AvahiProtocol,
AvahiResolverEvent event,
const char *name,
const char *type,
const char *,
const char *host_name,
const AvahiAddress *address,
uint16_t port,
AvahiStringList *txt,
AvahiLookupResultFlags,
void *data)
{
assert(data);
Browser *browser = static_cast<Browser *>(data);
assert(r);
switch (event) {
case AVAHI_RESOLVER_FAILURE:
//cerr << "[Resolver] Failed to resolve service '" << name << "' of type '" << type << "' in domain '" << domain
// << "': " << avahi_strerror(avahi_client_errno(avahi_service_resolver_get_client(r))) << endl;
break;
case AVAHI_RESOLVER_FOUND:
//cerr << "[Resolver] Service '" << name << " (" << host_name << ":" << port << ")"
// << "' of type '" << type <<"' in domain '" << domain << "'" << endl;
//cout << a->browse_services_.size() << endl;
browser->add_service(name, Service(type, host_name, address, port, txt));
// XXX cache service, broadcast
#if 0
avahi_address_snprint(a, sizeof(a), address);
t = avahi_string_list_to_string(txt);
fprintf(stderr,
"\t%s:%u (%s)\n"
"\tTXT=%s\n"
"\tcookie is %u\n"
"\tis_local: %i\n"
"\tour_own: %i\n"
"\twide_area: %i\n"
"\tmulticast: %i\n"
"\tcached: %i\n",
host_name, port, a,
t,
avahi_string_list_get_service_cookie(txt),
!!(flags & AVAHI_LOOKUP_RESULT_LOCAL),
!!(flags & AVAHI_LOOKUP_RESULT_OUR_OWN),
!!(flags & AVAHI_LOOKUP_RESULT_WIDE_AREA),
!!(flags & AVAHI_LOOKUP_RESULT_MULTICAST),
!!(flags & AVAHI_LOOKUP_RESULT_CACHED));
avahi_free(t);
#endif
}
avahi_service_resolver_free(r);
}