4#include "Stroika/Frameworks/StroikaPreComp.h"
7#include "Stroika/Foundation/Containers/Sequence.h"
13#include "Stroika/Foundation/Streams/MemoryStream.h"
18#include "BasicServer.h"
24using namespace Stroika::Foundation::IO;
27using Memory::MakeSharedPtr;
29using namespace Stroika::Frameworks;
30using namespace Stroika::Frameworks::UPnP;
31using namespace Stroika::Frameworks::UPnP::SSDP;
32using namespace Stroika::Frameworks::UPnP::SSDP::Server;
39class BasicServer::Rep_ final {
42 LocationProvider fLocation;
49 SSDP::Advertisement dan;
50 dan.fServer = d.fServer;
51 dan.fMaxAge = options.fFrequencyInfo.fMaxAge;
53 dan.fTarget = kTarget_UPNPRootDevice;
54 dan.fUSN = Format (
"uuid:{}::{}"_f, d.
fDeviceID, kTarget_UPNPRootDevice);
55 fAdvertisements.
Append (dan);
58 dan.fUSN = Format (
"uuid:{}"_f, d.
fDeviceID);
59 dan.fTarget = dan.fUSN;
60 fAdvertisements.
Append (dan);
62 if (not dd.fDeviceType.empty ()) {
63 dan.fUSN = Format (
"uuid:{}::{}"_f, d.
fDeviceID, dd.fDeviceType);
64 dan.fTarget = dd.fDeviceType;
65 fAdvertisements.
Append (dan);
70 if (not s.fServiceType.empty () and
71 not fAdvertisements.
Any ([&] (
const Advertisement& a) { return a.fTarget == s.fServiceType; })) {
72 dan.fUSN = Format (
"uuid:{}::{}"_f, d.
fDeviceID, s.fServiceType);
73 dan.fTarget = s.fServiceType;
74 fAdvertisements.
Append (dan);
81 fNotifier_ = make_unique<PeriodicNotifier> (fAdvertisements, fLocation,
82 PeriodicNotifier::Options{.fFrequencyInfo = fOptions.fFrequencyInfo,
83 .fIPVersion = fOptions.fIPVersion,
84 .fMulticastTTL = fOptions.fMulticastTTL,
85 .fInterfaces = fOptions.fInterfaces,
86 .fFollowNetworkChanges = fOptions.fFollowNetworkChanges});
87 fSearchResponder_ = make_unique<SearchResponder> (fAdvertisements, fLocation,
88 SearchResponder::Options{.fIPVersion = fOptions.fIPVersion,
89 .fInterfaces = fOptions.fInterfaces,
90 .fFollowNetworkChanges = fOptions.fFollowNetworkChanges});
92 unique_ptr<PeriodicNotifier> fNotifier_;
93 unique_ptr<SearchResponder> fSearchResponder_;
102 : fRep_{MakeSharedPtr<Rep_> (d, dd, location, options)}
108 InterfacesByID result = fRep_->fNotifier_->GetNetworkInterfaces ();
109 result += fRep_->fSearchResponder_->GetNetworkInterfaces ();
a cross between Mapping<KEY, T> and Collection<T> and Set<T>
A generalization of a vector: a container whose elements are keyed by the natural numbers.
nonvirtual void Append(ArgByValueType< value_type > item)
nonvirtual bool Any() const
Any() same as not empty (); Any (includeIfTrue) returns true iff includeIfTrue returns true on any va...
nonvirtual IO::Network::InterfacesByID GetNetworkInterfaces() const
The network interfaces it is advertising on now: those its NOTIFYs last went out of,...