Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
PeriodicNotifier.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Frameworks_UPnP_SSDP_Server_PeriodicNotifier_h_
5#define _Stroika_Frameworks_UPnP_SSDP_Server_PeriodicNotifier_h_ 1
6
7#include "Stroika/Frameworks/StroikaPreComp.h"
8
10#include "Stroika/Foundation/Common/Common.h"
13
14#include "Stroika/Frameworks/UPnP/Device.h"
16
17/*
18 * \file
19 *
20 * \note Code-Status: <a href="Code-Status.md#Alpha">Alpha</a>
21 *
22 * TODO:
23 * @todo Look at http://brisa.garage.maemo.org/doc/html/upnp/ssdp.html for example server API
24 */
25
26namespace Stroika::Frameworks::UPnP::SSDP::Server {
27
28 using Traversal::Iterable;
29
30 /**
31 * A big part of SSDP server functinality is to send periodic notifications of the Device description
32 *
33 * Instantiating the class starts the (background) notifications automatically, and they
34 * continue until the PeriodicNotifier object is destroyed.
35 *
36 * \note requires Execution::IntervalTimer::Manager::Activator intervalTimerMgrActivator
37 *
38 * \note - this behavior differs from Stroika 2.1, where you had to explicitly call Run ()
39 * \note - requirement to instantiate IntervalTimer::Manager::Activator before this new in Stroika v3
40 */
42 public:
43 // Very primitive definition - should refine - read details on spec on this...
44 struct FrequencyInfo {
45 Time::DurationSeconds fRepeatInterval{3 * 60.0s};
46 };
47
48 public:
49 /**
50 * Note this binds to the sockets on construction, and then keeps notifying through IntervalTimer wakeups, until
51 * this object is destroyed.
52 *
53 * Errors doing sends are just logged with DbgTrace()
54 */
55 PeriodicNotifier (const Iterable<Advertisement>& advertisements, const FrequencyInfo& fi,
56 IO::Network::InternetProtocol::IP::IPVersionSupport ipVersion = IO::Network::InternetProtocol::IP::IPVersionSupport::eDEFAULT);
57 PeriodicNotifier (const PeriodicNotifier&) = delete;
58
59 public:
60 const PeriodicNotifier operator= (const PeriodicNotifier&) = delete;
61
62 public:
63 ~PeriodicNotifier () = default;
64
65#if 0
66 //...
67 //Get/Set supported DeviceEntries ();
68
69 //Get/Set Refresh/MaxAge (default is autocompute refresh pace based on maxage)
70
71 // smart ptr to one of these - caller keeps it around, it runs in its own
72 // thread as needed, does responses etc.
73#endif
74 private:
75 unique_ptr<Execution::IntervalTimer::Adder> fIntervalTimerAdder_;
76 };
77
78}
79
80/*
81 ********************************************************************************
82 ***************************** Implementation Details ***************************
83 ********************************************************************************
84 */
85#include "PeriodicNotifier.inl"
86
87#endif /*_Stroika_Frameworks_UPnP_SSDP_Server_PeriodicNotifier_h_*/
chrono::duration< double > DurationSeconds
chrono::duration<double> - a time span (length of time) measured in seconds, but high precision.
Definition Realtime.h:57
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
Definition Iterable.h:237