11 #ifndef _UGCS_VSM_SERVICE_DISCOVERY_PROCESSOR_H_
12 #define _UGCS_VSM_SERVICE_DISCOVERY_PROCESSOR_H_
27 Socket_address::Ptr muticast_adress =
28 Socket_address::Create(DEFAULT_DISCOVERY_ADDRESS, DEFAULT_DISCOVERY_PORT));
53 Make_detection_handler,
54 (std::string, std::string, std::string, std::string,
bool),
55 (
"",
"",
"",
"",
true));
70 Advertise_service(
const std::string& type,
const std::string& name,
const std::string& location);
76 Unadvertise_service(
const std::string& type,
const std::string& name,
const std::string& location);
85 const std::string &type,
103 template <
typename... Args>
107 return singleton.Get_instance(std::forward<Args>(args)...);
111 static std::string DEFAULT_DISCOVERY_ADDRESS;
112 static std::string DEFAULT_DISCOVERY_PORT;
113 static std::string LOOPBACK_BROADCAST_ADDRESS;
114 static std::string SEARCH_METHOD_STRING;
115 static std::string NOTIFY_METHOD_STRING;
117 static std::string LOCAL_ADDRESS_IDENTIFIER;
119 static std::string LOOPBACK_IDENTIFIER;
121 static std::string MC_IDENTIFIER;
126 std::string my_instance_identifier;
132 typedef std::tuple<std::string, std::string, std::string> Service_info;
135 typedef std::pair<Operation_waiter, Socket_processor::Stream::Ref> My_socket;
138 Socket_address::Ptr multicast_adress;
142 Socket_address::Ptr loopback_broadcast_adress;
154 std::map<std::string, My_socket> sender_sockets;
157 My_socket sender_loopback;
160 std::set<Service_info> my_services;
164 std::map<std::string, std::pair<Detection_handler, Request_processor::Ptr>> subscribed_services;
176 Socket_address::Ptr addr,
177 std::string stream_id);
191 Socket_address::Ptr dest_addr,
192 const std::string& type,
193 const std::string& name,
194 const std::string& location,
199 Send_notify_all_services(
201 Socket_address::Ptr dest_addr);
205 Socket_address::Ptr addr,
206 const std::string& type,
207 const std::string& name,
208 const std::string& location);
213 Socket_address::Ptr dest_addr,
214 const std::string& type);
219 On_enable()
override;
228 Deactivate_if_no_services();
232 const std::string type,
233 const std::string name,
234 const std::string location,
239 const std::string type,
240 const std::string name,
241 const std::string location,
245 On_subscribe_for_service(
246 const std::string type,
252 On_unsubscribe_from_service(
253 const std::string type,
257 On_search_for_service(
258 const std::string type,
267 On_disable()
override;
270 Schedule_read(std::string
id);
273 Has_location_string(
const std::string& loc);
276 Build_location_string(
const std::string& loc, Socket_address::Ptr local_addr);
Callback_proxy< void, std::string, std::string, std::string, std::string, bool > Detection_handler
Detector function.
Definition: service_discovery_processor.h:49
static Ptr Get_instance(Args &&...args)
Get global or create new object instance.
Definition: service_discovery_processor.h:105
#define DEFINE_CALLBACK_BUILDER(__name, __types, __values)
Define callback builder function.
Definition: callback.h:42
Definition: service_discovery_processor.h:22
std::shared_ptr< Service_discovery_processor > Ptr
Pointer type.
Definition: service_discovery_processor.h:24
Io_result
Result of I/O operation.
Definition: io_stream.h:37
void Search_for_service(const std::string &type)
Sends out the M-SEARCH on all available interfaces.
Generic callback which can be used to define and create an instance of an abstract callable operation...
std::shared_ptr< Request > Ptr
Pointer type.
Definition: request_container.h:38
std::shared_ptr< Request_worker > Ptr
Pointer type.
Definition: request_worker.h:25
void Advertise_service(const std::string &type, const std::string &name, const std::string &location)
Sends out the NOTIFY ssdp:alive on all available interfaces.
Request execution context.
Definition: request_context.h:24
Helper class for proxying callback invocation.
Definition: callback.h:699
Generic container for queued requests.
Definition: request_container.h:30
void Subscribe_for_service(const std::string &type, Detection_handler handler, Request_processor::Ptr context)
Sends out the M-SEARCH on all available interfaces.
std::shared_ptr< Request_context > Ptr
Pointer type.
Definition: request_context.h:25
std::shared_ptr< Io_buffer > Ptr
Pointer type.
Definition: io_buffer.h:34
void Unsubscribe_from_service(const std::string &type)
Remove service type from subscription list.
void Unadvertise_service(const std::string &type, const std::string &name, const std::string &location)
Sends out the NOTIFY ssdp:byebye on all available interfaces.
#define DEFINE_COMMON_CLASS(__class_name,...)
Use this macro to define some common attributes for a class.
Definition: utils.h:25
std::shared_ptr< Timer > Ptr
Pointer type.
Definition: timer_processor.h:46
Helper class for implementing singletons.
Definition: singleton.h:69