service_discovery
Public Member Functions | Friends | List of all members
servicediscovery::avahi::LocalService Class Reference

LocalService for service objects that are meant to be published. Should be not used directly unless you take care of taking the client lock. More...

#include <LocalService.hpp>

Inheritance diagram for servicediscovery::avahi::LocalService:
servicediscovery::avahi::Service

Public Member Functions

 LocalService (Client *client, std::string name, std::string type, uint16_t port, std::list< std::string > list, uint32_t ttl=0, bool publish=true)
 
 LocalService (Client *client, AvahiIfIndex interf, AvahiProtocol prot, AvahiPublishFlags flags, std::string name, std::string type, std::string domain, uint16_t port, std::list< std::string > list, uint32_t ttl=0, bool publish=false)
 
virtual ~LocalService ()
 
int publish ()
 
void unpublish ()
 
bool published ()
 
int updateStringList (std::list< std::string > list)
 
- Public Member Functions inherited from servicediscovery::avahi::Service
 Service (const Service &)
 
 Service (Client *client, AvahiIfIndex interf, AvahiProtocol prot, std::string name, std::string type, std::string domain, uint16_t port=0, std::list< std::string > list=std::list< std::string >())
 
virtual ~Service ()
 
bool operator== (const Service &)
 
uint16_t getPort () const
 
AvahiStringList * getTxt () const
 
std::list< std::string > getStringList () const
 
std::string getName () const
 
void setConfiguration (const ServiceConfiguration &config)
 
ServiceConfiguration getConfiguration () const
 
ClientgetClient ()
 

Friends

class ServiceDiscovery
 

Additional Inherited Members

- Public Attributes inherited from servicediscovery::avahi::Service
bool dontCheckTXT
 
- Protected Member Functions inherited from servicediscovery::avahi::Service
void setTxt (AvahiStringList *ntxt)
 
void setStringList (std::list< std::string > list)
 
void addDescriptionsToConfiguration (const std::list< std::string > &strlist)
 
- Static Protected Member Functions inherited from servicediscovery::avahi::Service
static AvahiStringList * getTxt (std::list< std::string >)
 
- Protected Attributes inherited from servicediscovery::avahi::Service
uint16_t port
 
AvahiStringList * txt
 
std::list< std::string > stringlist
 
Clientclient_
 
ServiceConfiguration configuration_
 

Detailed Description

LocalService for service objects that are meant to be published. Should be not used directly unless you take care of taking the client lock.

Constructor & Destructor Documentation

◆ LocalService() [1/2]

servicediscovery::avahi::LocalService::LocalService ( Client client,
std::string  name,
std::string  type,
uint16_t  port,
std::list< std::string >  list,
uint32_t  ttl = 0,
bool  publish = true 
)

constructor

Parameters
clientthe related AvahiClient instance
namethe name of the service
typethe type of the service: usually "_sometype._tcp" (must have a ._tcp or ._udp at the end for a protocol type)
portthe port number at which the service is present
lista list of strings as additional information (TODO: avahi api supports map of strings, implement this functionality)
ttltime to live of the service in case of network failure
publishtrue if the related entry group is to be immediately commited

◆ LocalService() [2/2]

servicediscovery::avahi::LocalService::LocalService ( Client client,
AvahiIfIndex  interf,
AvahiProtocol  prot,
AvahiPublishFlags  flags,
std::string  name,
std::string  type,
std::string  domain,
uint16_t  port,
std::list< std::string >  list,
uint32_t  ttl = 0,
bool  publish = false 
)

constructor

Parameters
clientthe related AvahiClient instance
interfthe network interface at which the service is to be published (above default is all interfaces)
protthe protocol ipv4 or ipv6 (above default is unspecified)
flagspublish flags (above default is no flags)
namethe name of the service
typethe type of the service: usually "_sometype._tcp" (must have a ._tcp or ._udp at the end for a protocol type)
domaindomain of the service (above default is ".local")
portthe port number at which the service is present
lista list of strings as additional information (TODO: avahi api supports map of strings, implement this functionality)
ttltime to live of the service in case of network failure
publishtrue if the related entry group is to be immediately commited

◆ ~LocalService()

servicediscovery::avahi::LocalService::~LocalService ( )
virtual

Member Function Documentation

◆ publish()

int servicediscovery::avahi::LocalService::publish ( )

create and commit the related entry group

Returns
int 0 success (at least for commiting the entry group, also depends on the asynchronous message returned by avahi-daemon TODO: add a signal for this) -1 missing client -2 entry group pointer not null -3 cannot create entry group -4 failed to add the service to the entry group -5 failed to commit the entry group

◆ published()

bool servicediscovery::avahi::LocalService::published ( )

Tests whether the local service is published or not

Returns
True when published, false when not

◆ unpublish()

void servicediscovery::avahi::LocalService::unpublish ( )

opposite of publish. Unpublish a service.

◆ updateStringList()

int servicediscovery::avahi::LocalService::updateStringList ( std::list< std::string >  list)

update the service additional information

Friends And Related Function Documentation

◆ ServiceDiscovery

friend class ServiceDiscovery
friend

The documentation for this class was generated from the following files: