当前位置: 首页>>代码示例>>C++>>正文


C++ Browser::add_service方法代码示例

本文整理汇总了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);
    }
开发者ID:mhaberler,项目名称:directoryd,代码行数:59,代码来源:Browser.cpp


注:本文中的Browser::add_service方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。