You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/android/pages/p2psync-multipeer.adoc
+172-3Lines changed: 172 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,24 @@ If you are working with a bluetooth network, you will need to use Couchbase Lite
18
18
// tag::introduction-full[]
19
19
// tag::introduction[]
20
20
Couchbase Lite's Peer-to-Peer synchronization solution offers secure storage and bidirectional data synchronization between edge devices without needing a centralized cloud-based control point.
21
-
Multipeer Replicator
21
+
22
+
23
+
// *** advantages ***
24
+
25
+
Multipeer Replicator for small mesh topologies offers autodiscovery for wifi-based networks.
26
+
Multipeer Sync thus requires less management and less code than using active-passive peer-to-peer sync, and also manages peer discovery for you.
27
+
28
+
// Bluetooth - not yet
29
+
30
+
[TIP]
31
+
.Bluetooth networking
32
+
====
33
+
If you are working over a bluetooth network, then take a look at Couchbase Lite's Active-Passive Peer-to-Peer synchronization.
34
+
====
35
+
36
+
22
37
// end::introduction[]
38
+
// end::introduction-full[]
23
39
24
40
25
41
@@ -28,7 +44,7 @@ Multipeer Replicator
28
44
=== Transport and Peer Discovery Protocol
29
45
30
46
MultipeerReplicator supports Wi-Fi transport, using DNS-SD (also known as Bonjour) for peer discovery.
31
-
Peers must be connected to the same Wi-Fi network to discover and establish connections with one another.
47
+
Peers must be connected to the same Wi-Fi network to discover and establish connections with one another.
32
48
33
49
=== Supported Platforms
34
50
@@ -44,7 +60,9 @@ To maintain optimal connectivity, efficient data transport, and balanced workloa
44
60
It avoids redundant direct connections, evenly distributes connections across peers, and optimizes communication paths.
45
61
The mesh network continuously adapts as peers join or leave.
46
62
47
-
63
+
====
64
+
*TODO* Mesh Diagram
65
+
====
48
66
49
67
50
68
== Configuration
@@ -84,4 +102,155 @@ public struct MultipeerReplicatorConfiguration {
84
102
85
103
TIP: In version 3.3.0, the recommended maximum number of peers in a mesh network is approximately 15.
86
104
105
+
=== Life Cycle
106
+
107
+
Starting and stopping a peer-to-peer connection...
108
+
109
+
110
+
=== Listening for Changes
111
+
112
+
Event types...
113
+
114
+
115
+
`PeerDocumentReplication`
116
+
117
+
118
+
== Example Use
119
+
120
+
Here we will show how to instansiate a `MultipeerReplicatorConfiguration` configuration with self-signed certificates, and connect it to an example collection.
121
+
122
+
[source,kotlin]
123
+
----
124
+
// Code sample
125
+
----
126
+
127
+
128
+
129
+
=== MultipeerCollectionConfiguration
130
+
131
+
`MultipeerCollectionConfiguration` specifies a collection and its associated settings.
132
+
This includes a conflict resolver and replication filters.
133
+
A list of these configurations is required to define which collections will be replicated within the peer group network.
134
+
135
+
136
+
[source,kotlin]
137
+
----
138
+
/// Type Alias for Multipeer Replication Filter Function.
/// Defines collection for replication including optional filters and
149
+
/// custom conflict resolver.
150
+
public struct MultipeerCollectionConfiguration {
151
+
/// The collection.
152
+
public let collection: Collection
153
+
154
+
/// Document IDs filter.
155
+
public var documentIDs: Array<String>?
156
+
157
+
/// Push filter.
158
+
public var pushFilter: MultipeerReplicationFilter?
159
+
160
+
/// Pull filter.
161
+
public var pullFilter: MultipeerReplicationFilter?
162
+
163
+
164
+
/// Custom conflict resolver.
165
+
public var conflictResolver: MultipeerConflictResolver?
166
+
167
+
168
+
/// Initialize with a collection.
169
+
public init(collection: Collection)
170
+
}
171
+
----
172
+
173
+
174
+
=== Authenticator
175
+
176
+
`MultipeerCertificateAuthenticator` *TODO*
177
+
178
+
179
+
=== Peer Info
180
+
181
+
`PeerInfo` provides information about the peer, including a peer unique identifier, the peer certificate, online status, replicator status, and its current `neighborPeers`.
182
+
183
+
184
+
[source,kotlin]
185
+
----
186
+
//
187
+
----
188
+
189
+
190
+
=== Self-signed Certs
191
+
192
+
.Creating a self-signed certificate that can be used as both client and server cert
193
+
[source,kotlin]
194
+
----
195
+
/// Extended Key Usage for which the certified public key may be used.
196
+
public struct KeyUsages: OptionSet {
197
+
/// For Server Authentication
198
+
public static let serverAuth = 0x40
199
+
200
+
/// For Client Authentication
201
+
public static let clientAuth = 0x80
202
+
}
203
+
204
+
/// TLS Identity
205
+
public class TLSIdentity {
206
+
/// Create a TLS identity from private key and certificate data.
207
+
///
208
+
/// The private key and certificate data must be either in PEM or DER format.
209
+
/// This method can be used to create an issuer identity for signing
210
+
/// a certificate when generating a new TLS identity.
211
+
public static func createIdentity(privateKey: Data,
212
+
certificate: Data) throws -> TLSIdentity
213
+
214
+
215
+
/// Generate a TLS identity, either self-signed or signed by an issuer identity.
216
+
///
217
+
/// The `attributes` must include a common name (CN); otherwise an error
218
+
/// will be thrown.
219
+
///
220
+
/// If no the expiration date is specified, the default validity of one year
221
+
/// will be applied.
222
+
///
223
+
/// The optional issuer identity may be specified to sign the certificate.
224
+
/// The issuer identity can be created using
225
+
/// `createIdentity(privateKeyData:certificateData:)`. If no issuer is specified,
226
+
/// the certificate will be self-signed.
227
+
///
228
+
/// If a `label` is provided, the identity will be stored in the
229
+
/// platform’s secure key storage under that label.
230
+
public static func createIdentity(keyUsages: KeyUsages,
:description: Couchbase Lite's Peer-to-Peer Synchronization enables edge devices to synchronize securely without consuming centralized cloud-server resources
5
+
:description: Where MultiPeer Sync is not available, Couchbase Lite's Active-Passive Peer-to-Peer Synchronization enables edge devices to synchronize securely without consuming centralized cloud-server resources
0 commit comments