本文整理汇总了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:
;
}
}
示例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();
}
}