OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_NetworkServiceDiscovery.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23 namespace juce
24{
25
26//==============================================================================
34 struct NetworkServiceDiscovery
35{
44 struct Advertiser : private Thread
45 {
53 Advertiser (const String& serviceTypeUID,
54 const String& serviceDescription,
55 int broadcastPort,
56 int connectionPort,
57 RelativeTime minTimeBetweenBroadcasts = RelativeTime::seconds (1.5));
58
60 ~Advertiser() override;
61
62 private:
63 XmlElement message;
64 const int broadcastPort;
65 const RelativeTime minInterval;
66 DatagramSocket socket { true };
67
68 void run() override;
69 void sendBroadcast();
70 };
71
72 //==============================================================================
80 struct Service
81 {
82 String instanceID;
83 String description;
84 IPAddress address;
85 int port;
86 Time lastSeen;
87 };
88
89 //==============================================================================
102 struct AvailableServiceList : private Thread,
103 private AsyncUpdater
104 {
111 AvailableServiceList (const String& serviceTypeUID, int broadcastPort);
112
114 ~AvailableServiceList() override;
115
117 std::function<void()> onChange;
118
120 std::vector<Service> getServices() const;
121
122 private:
123 DatagramSocket socket { true };
124 String serviceTypeUID;
125 CriticalSection listLock;
126 std::vector<Service> services;
127
128 void run() override;
129 void handleAsyncUpdate() override;
130 void handleMessage (const XmlElement&);
131 void handleMessage (const Service&);
132 void removeTimedOutServices();
133
134 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AvailableServiceList)
135 };
136};
137
138} // namespace juce
juce::AsyncUpdater
Definition juce_AsyncUpdater.h:39
juce::CriticalSection
Definition juce_CriticalSection.h:43
juce::DatagramSocket
Definition juce_Socket.h:265
juce::IPAddress
Definition juce_IPAddress.h:33
juce::RelativeTime
Definition juce_RelativeTime.h:37
juce::RelativeTime::seconds
static RelativeTime seconds(double seconds) noexcept
Definition juce_RelativeTime.cpp:33
juce::String
Definition juce_String.h:53
juce::Thread
Definition juce_Thread.h:43
juce::Time
Definition juce_Time.h:37
juce::XmlElement
Definition juce_XmlElement.h:83
juce::NetworkServiceDiscovery::Advertiser
Definition juce_NetworkServiceDiscovery.h:45
juce::NetworkServiceDiscovery::Advertiser::Advertiser
Advertiser(const String &serviceTypeUID, const String &serviceDescription, int broadcastPort, int connectionPort, RelativeTime minTimeBetweenBroadcasts=RelativeTime::seconds(1.5))
Definition juce_NetworkServiceDiscovery.cpp:31
juce::NetworkServiceDiscovery::Advertiser::~Advertiser
~Advertiser() override
Definition juce_NetworkServiceDiscovery.cpp:47
juce::NetworkServiceDiscovery::AvailableServiceList
Definition juce_NetworkServiceDiscovery.h:104
juce::NetworkServiceDiscovery::AvailableServiceList::AvailableServiceList
AvailableServiceList(const String &serviceTypeUID, int broadcastPort)
Definition juce_NetworkServiceDiscovery.cpp:87
juce::NetworkServiceDiscovery::AvailableServiceList::onChange
std::function< void()> onChange
Definition juce_NetworkServiceDiscovery.h:117
juce::NetworkServiceDiscovery::AvailableServiceList::~AvailableServiceList
~AvailableServiceList() override
Definition juce_NetworkServiceDiscovery.cpp:98
juce::NetworkServiceDiscovery::AvailableServiceList::getServices
std::vector< Service > getServices() const
Definition juce_NetworkServiceDiscovery.cpp:128
juce::NetworkServiceDiscovery
Definition juce_NetworkServiceDiscovery.h:35
juce::NetworkServiceDiscovery::Service::instanceID
String instanceID
Definition juce_NetworkServiceDiscovery.h:82
juce::NetworkServiceDiscovery::Service::lastSeen
Time lastSeen
Definition juce_NetworkServiceDiscovery.h:86
juce::NetworkServiceDiscovery::Service::port
int port
Definition juce_NetworkServiceDiscovery.h:85
juce::NetworkServiceDiscovery::Service::description
String description
Definition juce_NetworkServiceDiscovery.h:83
juce::NetworkServiceDiscovery::Service::address
IPAddress address
Definition juce_NetworkServiceDiscovery.h:84
juce::NetworkServiceDiscovery::Service
Definition juce_NetworkServiceDiscovery.h:81