Skip to content

Commit 6dceecd

Browse files
RichardSmedleyosfameron
authored andcommitted
work-in-progress
1 parent bb51404 commit 6dceecd

File tree

2 files changed

+174
-6
lines changed

2 files changed

+174
-6
lines changed

modules/android/pages/p2psync-multipeer.adoc

Lines changed: 172 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,24 @@ If you are working with a bluetooth network, you will need to use Couchbase Lite
1818
// tag::introduction-full[]
1919
// tag::introduction[]
2020
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+
2237
// end::introduction[]
38+
// end::introduction-full[]
2339

2440

2541

@@ -28,7 +44,7 @@ Multipeer Replicator
2844
=== Transport and Peer Discovery Protocol
2945

3046
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.
3248

3349
=== Supported Platforms
3450

@@ -44,7 +60,9 @@ To maintain optimal connectivity, efficient data transport, and balanced workloa
4460
It avoids redundant direct connections, evenly distributes connections across peers, and optimizes communication paths.
4561
The mesh network continuously adapts as peers join or leave.
4662

47-
63+
====
64+
*TODO* Mesh Diagram
65+
====
4866

4967

5068
== Configuration
@@ -84,4 +102,155 @@ public struct MultipeerReplicatorConfiguration {
84102

85103
TIP: In version 3.3.0, the recommended maximum number of peers in a mesh network is approximately 15.
86104

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.
139+
public typealias MultipeerReplicationFilter =
140+
(PeerID, Document, DocumentFlags) -> Bool
141+
142+
143+
/// Multipeer Conflict Resolver Protocol.
144+
public protocol MultipeerConflictResolver {
145+
func resolve(peerID: PeerID, conflict: Conflict) -> Document?
146+
}
147+
148+
/// 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,
231+
attributes: [String: String],
232+
expiration: Date?,
233+
issuer: TLSIdentity?,
234+
label: String?) throws -> TLSIdentity
235+
236+
237+
238+
239+
@Deprecated, “Use createIdentity(keyUsages:attributes:expiration:issuer:label)”
240+
public static func createIdentity(server: Bool,
241+
attributes: [String: String],
242+
expiration: Date?,
243+
label: String) throws -> TLSIdentity
244+
}
245+
----
246+
247+
248+
249+
=== Logging
250+
251+
`LogDomain`
252+
253+
254+
== API Reference
87255

256+
*URL*

modules/android/pages/p2psync-websocket.adoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
2-
= Data Sync Peer-to-Peer
1+
= Active-Passive Peer-to-Peer Sync
32
:page-aliases: learn/java-android-p2psync-websocket.adoc
43
ifdef::show_edition[:page-edition: Enterprise Edition]
54
:page-role:
6-
: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
76

87

98
:source-language: Java

0 commit comments

Comments
 (0)