4#include "Stroika/Frameworks/StroikaPreComp.h"
7#include "Stroika/Foundation/Containers/Sequence.h"
14#include "Stroika/Foundation/Streams/MemoryStream.h"
19#include "BasicServer.h"
25using namespace Stroika::Foundation::IO;
28using Memory::MakeSharedPtr;
30using namespace Stroika::Frameworks;
31using namespace Stroika::Frameworks::UPnP;
32using namespace Stroika::Frameworks::UPnP::SSDP;
33using namespace Stroika::Frameworks::UPnP::SSDP::Server;
40class BasicServer::Rep_ final {
43 FrequencyInfo fFrequencyInfo;
47 , fLocation{d.fLocation}
50 SSDP::Advertisement dan;
52 dan.fServer = d.fServer;
54 dan.fTarget = kTarget_UPNPRootDevice;
55 dan.fUSN = Format (
"uuid:{}::{}"_f, d.fDeviceID, kTarget_UPNPRootDevice);
56 fAdvertisements.
Append (dan);
59 dan.fUSN = Format (
"uuid:{}"_f, d.fDeviceID);
60 dan.fTarget = dan.fUSN;
61 fAdvertisements.
Append (dan);
63 if (not dd.fDeviceType.empty ()) {
64 dan.fUSN = Format (
"uuid:{}::{}"_f, d.fDeviceID, dd.fDeviceType);
65 dan.fTarget = dd.fDeviceType;
66 fAdvertisements.
Append (dan);
72 fNotifier_ = make_unique<PeriodicNotifier> (GetAdjustedAdvertisements_ (), fi, ipVersion);
73 fSearchResponder_ = make_unique<SearchResponder> (GetAdjustedAdvertisements_ (), ipVersion);
77 lm.AddCallback ([
this] (LinkMonitor::LinkChange lc,
String netName,
String ipNum) {
78 Debug::TraceContextBumper ctx{
"Basic SSDP server - LinkMonitor callback",
"lc = {}, netName={}, ipNum={}"_f, lc, netName, ipNum};
79 if (lc == LinkMonitor::LinkChange::eAdded) {
83 fLinkMonitor_ = optional<LinkMonitor>{move (lm)};
92 return fAdvertisements;
96 URI useBaseURL = fLocation;
99 useBaseURL.SetAuthority (useAuthority);
100 for (
auto ai : fAdvertisements) {
101 ai.fLocation = useBaseURL.
Combine (ai.fLocation);
102 revisedAdvertisements.
Append (ai);
104 return revisedAdvertisements;
111 fSearchResponder_.reset ();
112 fNotifier_ = make_unique<PeriodicNotifier> (GetAdjustedAdvertisements_ (), PeriodicNotifier::FrequencyInfo{});
113 fSearchResponder_ = make_unique<SearchResponder> (GetAdjustedAdvertisements_ ());
115 unique_ptr<PeriodicNotifier> fNotifier_;
116 unique_ptr<SearchResponder> fSearchResponder_;
117 optional<IO::Network::LinkMonitor> fLinkMonitor_;
auto MakeSharedPtr(ARGS_TYPE &&... args) -> shared_ptr< T >
same as make_shared, but if type T has block allocation, then use block allocation for the 'shared pa...
String is like std::u32string, except it is much easier to use, often much more space efficient,...
A generalization of a vector: a container whose elements are keyed by the natural numbers.
nonvirtual void Append(ArgByValueType< value_type > item)
nonvirtual URI Combine(const URI &overridingURI) const
Combine overridingURI possibly relative url with this base url, to produce a new URI.
nonvirtual optional< Authority > GetAuthority() const
InternetAddress GetPrimaryInternetAddress()