|
12 | 12 |
|
13 | 13 | #pragma once |
14 | 14 | #include "c4Base.hh" |
15 | | -#include "c4DatabaseTypes.h" |
16 | 15 | #include "c4PeerSyncTypes.h" // for C4PeerID |
17 | 16 | #include "c4Error.h" |
18 | | -#include "ObserverList.hh" |
| 17 | +#include "Observer.hh" |
19 | 18 | #include "fleece/InstanceCounted.hh" |
20 | 19 | #include "fleece/RefCounted.hh" |
21 | 20 | #include <functional> |
|
24 | 23 | #include <span> |
25 | 24 | #include <unordered_map> |
26 | 25 | #include <vector> |
| 26 | +#include <memory> |
27 | 27 |
|
28 | 28 | #ifdef COUCHBASE_ENTERPRISE |
29 | 29 | C4_ASSUME_NONNULL_BEGIN |
@@ -80,18 +80,18 @@ class C4PeerDiscovery { |
80 | 80 | ~C4PeerDiscovery(); |
81 | 81 |
|
82 | 82 | /// The peer group ID. |
83 | | - std::string const& peerGroupID() const { return _peerGroupID; } |
| 83 | + std::string const& peerGroupID() const; |
84 | 84 |
|
85 | 85 | /// This device's peer ID. |
86 | | - C4PeerID const& peerID() const { return _peerID; } |
| 86 | + C4PeerID const& peerID() const; |
87 | 87 |
|
88 | 88 | /// The `C4PeerDiscoveryProvider`s in use. |
89 | | - std::vector<ProviderRef> const& providers() const { return _providers; } |
| 89 | + std::vector<ProviderRef> const& providers() const; |
90 | 90 |
|
91 | 91 | /// Registers a default C4SocketFactory to be used when a Provider doesn't have a custom one. |
92 | 92 | /// This factory is expected to handle normal IP-based WebSocket connections. |
93 | 93 | /// @warning Do not call this after there have been any calls to `startPublishing`. |
94 | | - static void setDefaultSocketFactory(C4SocketFactory const&); |
| 94 | + CBL_CORE_API static void setDefaultSocketFactory(C4SocketFactory const&); |
95 | 95 |
|
96 | 96 | /// Tells providers to start looking for peers. |
97 | 97 | void startBrowsing(); |
@@ -181,13 +181,8 @@ class C4PeerDiscovery { |
181 | 181 | void notifyMetadataChanged(C4Peer*); |
182 | 182 |
|
183 | 183 | private: |
184 | | - std::mutex _mutex; |
185 | | - std::string const _peerGroupID; |
186 | | - C4PeerID const _peerID; |
187 | | - std::vector<ProviderRef> _providers; // List of providers. Never changes. |
188 | | - std::unordered_map<std::string, fleece::Ref<C4Peer>> _peers; |
189 | | - std::vector<fleece::Ref<C4Peer>> _peersComing, _peersGoing; |
190 | | - litecore::ObserverList<Observer> _observers; |
| 184 | + struct Impl; |
| 185 | + std::unique_ptr<Impl> _impl; |
191 | 186 | }; |
192 | 187 |
|
193 | 188 | # pragma mark - PEER: |
|
0 commit comments