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


C++ Publisher::createServices方法代码示例

本文整理汇总了C++中Publisher::createServices方法的典型用法代码示例。如果您正苦于以下问题:C++ Publisher::createServices方法的具体用法?C++ Publisher::createServices怎么用?C++ Publisher::createServices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Publisher的用法示例。


在下文中一共展示了Publisher::createServices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: entryGroupCallback

void Publisher::entryGroupCallback(AvahiEntryGroup *g, AvahiEntryGroupState state, void *context) {
	Publisher *publisher = (Publisher*) context;
	const char* name = publisher->info.getServiceName().c_str();
	const int port = publisher->info.getPort();

	// callback called whenever our entry group state changes
	switch (state) {
	case AVAHI_ENTRY_GROUP_ESTABLISHED:
		std::cout << "Registration ok:" << name <<":" << port << " (" << publisher->serviceType << ")" << std::endl;
		break;
	case AVAHI_ENTRY_GROUP_COLLISION:
		// build new name
		publisher->nextName();
		// retry
		publisher->createServices(avahi_entry_group_get_client(g));
		break;
	case AVAHI_ENTRY_GROUP_FAILURE:
		std::cerr << "Registration failure ("
				<< avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g)))
				<< ")" << std::endl;
		publisher->quit();
		break;
	case AVAHI_ENTRY_GROUP_UNCOMMITED:
	case AVAHI_ENTRY_GROUP_REGISTERING:
		;
	}
}
开发者ID:checko,项目名称:zeroconf-for-android,代码行数:27,代码来源:Publisher.cpp

示例2: clientCallback

void Publisher::clientCallback(AvahiClient *client, AvahiClientState state, void *context) {
	Publisher *publisher = (Publisher*) context;

	// called on every server state change
	switch (state) {
	case AVAHI_CLIENT_S_RUNNING:
		// server is fine, we can register
		publisher->createServices(client);
		break;
	case AVAHI_CLIENT_S_COLLISION:
	case AVAHI_CLIENT_S_REGISTERING:
		// server not ready (collision, registering)
		// make sure we restart registration
		avahi_entry_group_reset(publisher->group);
		break;
	case AVAHI_CLIENT_CONNECTING:
		// wait
		break;
	case AVAHI_CLIENT_FAILURE:
		std::cerr << "Server connection failure: "
					<<  avahi_strerror(avahi_client_errno(client)) << std::endl;
		publisher->quit();
	}
}
开发者ID:checko,项目名称:zeroconf-for-android,代码行数:24,代码来源:Publisher.cpp


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