Fawkes API  Fawkes Development Version
browse_handler.h
1 
2 /***************************************************************************
3  * browse_handler.h - Avahi browse handler
4  *
5  * Created: Wed Nov 08 13:16:47 2006
6  * Copyright 2006 Tim Niemueller [www.niemueller.de]
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version. A runtime exception applies to
14  * this software (see LICENSE.GPL_WRE file mentioned below for details).
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Library General Public License for more details.
20  *
21  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22  */
23 
24 #ifndef _NETCOMM_SERVICE_DISCOVERY_BROWSE_HANDLER_H_
25 #define _NETCOMM_SERVICE_DISCOVERY_BROWSE_HANDLER_H_
26 
27 #include <sys/socket.h>
28 #include <sys/types.h>
29 
30 #include <list>
31 #include <stdint.h>
32 #include <string>
33 
34 namespace fawkes {
35 
36 /** @class ServiceBrowseHandler <netcomm/service_discovery/browse_handler.h>
37  * Interface for class that process browse results.
38  * Implement this class if you want to browse for services on the network.
39  * Then register your handler and it will be informed of services that
40  * join or leave the network. This is also required for an active search.
41  *
42  * It is recommended that you read about mDNS, DNS-SD and Avahi.
43  *
44  * @author Tim Niemueller
45  */
47 {
48 public:
49  /** Virtual destructor */
50  virtual ~ServiceBrowseHandler(){};
51 
52  /** All results have been retrieved.
53  * If you read the DNS-SD specs you will see that there is no explicit
54  * "not existent" or "end of records" message - it cannot be. But after
55  * some time it is assumed that there are no more records. If that is
56  * the case this method is called.
57  */
58  virtual void all_for_now() = 0;
59 
60  /** Cache exhausted. */
61  virtual void cache_exhausted() = 0;
62 
63  /** Failed to browse for a given service.
64  * @param name name of the service
65  * @param type type of the service
66  * @param domain domain of the service
67  */
68  virtual void browse_failed(const char *name, const char *type, const char *domain) = 0;
69 
70  /** A service has been announced on the network.
71  * @param name name of the service
72  * @param type type of the service
73  * @param domain domain of the service
74  * @param host_name name of the host that provides the service
75  * @param interface name of network interface to reach service
76  * @param addr pointer to sockaddr struct of appropriate type for address
77  * @param addr_size size of addr struct
78  * @param port port of the service
79  * @param txt list of txt records.
80  * @param flags extra flags, see Avahi documentation
81  */
82  virtual void service_added(const char * name,
83  const char * type,
84  const char * domain,
85  const char * host_name,
86  const char * interface,
87  const struct sockaddr * addr,
88  const socklen_t addr_size,
89  uint16_t port,
90  std::list<std::string> &txt,
91  int flags) = 0;
92 
93  /** A service has been removed from the network.
94  * @param name name of the service
95  * @param type type of the service
96  * @param domain domain of the service
97  */
98  virtual void service_removed(const char *name, const char *type, const char *domain) = 0;
99 };
100 
101 } // end namespace fawkes
102 
103 #endif
virtual ~ServiceBrowseHandler()
Virtual destructor.
Fawkes library namespace.
virtual void service_removed(const char *name, const char *type, const char *domain)=0
A service has been removed from the network.
virtual void browse_failed(const char *name, const char *type, const char *domain)=0
Failed to browse for a given service.
Interface for class that process browse results.
virtual void all_for_now()=0
All results have been retrieved.
virtual void service_added(const char *name, const char *type, const char *domain, const char *host_name, const char *interface, const struct sockaddr *addr, const socklen_t addr_size, uint16_t port, std::list< std::string > &txt, int flags)=0
A service has been announced on the network.
virtual void cache_exhausted()=0
Cache exhausted.