Skip to content
11 changes: 11 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@

on:
pull_request:
types: [review_requested]
paths:
# the following should match `path:` declaration below
- example/**

jobs:
diag:
runs-on: ubuntu-latest
steps:
- name: reviewer
run: |
echo REVIEWER $REVIEWER
env:
REVIEWER: ${{ github.event.requested_reviewer.login }}

vale:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
if: github.event.requested_reviewer.login == 'tech-comm-team-couchbase'
uses: couchbaselabs/docs-runner/.github/workflows/vale-review.yml@main
with:
path: example
pull_request_number: ${{ github.event.number }}
base_sha: ${{ github.event.pull_request.base.sha }}
head_sha: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.repository }}
secrets: inherit

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium test

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
350 changes: 350 additions & 0 deletions example/modules/ROOT/pages/cbl-android-p2p.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,350 @@
= Integrate a Custom Built Listener
:page-aliases: learn/java-android-p2psync-custom.adoc
ifdef::show_edition[:page-edition: Enterprise Edition]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
ifdef::show_edition[:page-edition: Enterprise Edition]
ifdef::show_edition[:page-edition: Couchbase Server Enterprise Edition]

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be "Sync Gateway Enterprise Edition"? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
ifdef::show_edition[:page-edition: Enterprise Edition]
ifdef::show_edition[:page-edition: Couchbase Server Enterprise Edition]

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
ifdef::show_edition[:page-edition: Enterprise Edition]
ifdef::show_edition[:page-edition: Couchbase Server Enterprise Edition]

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
ifdef::show_edition[:page-edition: Enterprise Edition]
ifdef::show_edition[:page-edition: Couchbase Server Enterprise Edition]

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
ifdef::show_edition[:page-edition: Enterprise Edition]
ifdef::show_edition[:page-edition: Couchbase Server Enterprise Edition]

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
ifdef::show_edition[:page-edition: Enterprise Edition]
ifdef::show_edition[:page-edition: Couchbase Server Enterprise Edition]

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
ifdef::show_edition[:page-edition: Enterprise Edition]
ifdef::show_edition[:page-edition: Couchbase Server Enterprise Edition]

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

:page-role:
:description: Couchbase Lite database peer-to-peer sync- integrate a custom built listener


:source-language: Java


:source-language: Kotlin


// :param-name: kotlin
// :param-title: Android
// :param-module: android


[abstract]
--
Description -- _{description}_ +
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Description -- _{description}_ +
Description -- {description} +

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Description -- _{description}_ +
Description -- {description} +

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Description -- _{description}_ +
Description -- {description} +

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Description -- _{description}_ +
Description -- {description} +

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Description -- _{description}_ +
Description -- {description} +

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Description -- _{description}_ +
Description -- {description} +

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Description -- _{description}_ +
Description -- {description} +

Using these Vale rules:

Related Content -- https://docs.couchbase.com/mobile/{major}.{minor}.{maintenance-android}{empty}/couchbase-lite-android/[API Reference] | xref:android:p2psync-websocket.adoc[Peer-to-Peer] | xref:android:p2psync-custom.adoc[Integrate Custom Listener]
--

[#overview]
== Overview

.Enterprise Edition only
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
.Enterprise Edition only
.Couchbase Server Enterprise Edition only

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
.Enterprise Edition only
.Couchbase Server Enterprise Edition only

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
.Enterprise Edition only
.Couchbase Server Enterprise Edition only

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
.Enterprise Edition only
.Couchbase Server Enterprise Edition only

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
.Enterprise Edition only
.Couchbase Server Enterprise Edition only

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
.Enterprise Edition only
.Couchbase Server Enterprise Edition only

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
.Enterprise Edition only
.Couchbase Server Enterprise Edition only

Using these Vale rules:

  • Couchbase.CouchbaseServerEnterprise (error) - Use the full product name (Couchbase Server Enterprise Edition) first.

IMPORTANT: Peer-to-Peer Synchronization is an https://www.couchbase.com/products/editions[Enterprise Edition] feature.
You must purchase the Enterprise License, which includes official https://www.couchbase.com/support-policy[Couchbase Support].
To use it in production (also see the https://www.couchbase.com/licensing-and-support-faq[FAQ]).

This content covers how to integrate a custom __MessageEndpointListener__ solution with Couchbase Lite to handle the data transfer, which is the sending and receiving of data.
Where applicable, we discuss how to integrate Couchbase Lite into the workflow.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Where applicable, we discuss how to integrate Couchbase Lite into the workflow.
Where applicable, this documentation discusses how to integrate Couchbase Lite into the workflow.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'we'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Where applicable, we discuss how to integrate Couchbase Lite into the workflow.
Where applicable, this document discusses how to integrate Couchbase Lite into the workflow.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'we'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Where applicable, we discuss how to integrate Couchbase Lite into the workflow.
Where applicable, this document discusses how to integrate Couchbase Lite into the workflow.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'we'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Where applicable, we discuss how to integrate Couchbase Lite into the workflow.
Where applicable, this document discusses how to integrate Couchbase Lite into the workflow.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'we'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Where applicable, we discuss how to integrate Couchbase Lite into the workflow.
Where applicable, this document discusses how to integrate Couchbase Lite into the workflow.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'we'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Where applicable, we discuss how to integrate Couchbase Lite into the workflow.
Where applicable, this document discusses how to integrate Couchbase Lite into the workflow.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'we'.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Where applicable, we discuss how to integrate Couchbase Lite into the workflow.
Where applicable, this document discusses how to integrate Couchbase Lite into the workflow.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'we'.


The following sections describe a typical Peer-to-Peer workflow.

[#peer-discovery]
== Peer Discovery

Peer discovery is the first step.
The communication framework will generally include a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
The communication framework will generally include a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.
The communication framework generally includes a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The communication framework will generally include a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.
The communication framework generally includes a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The communication framework will generally include a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.
The communication framework generally includes a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The communication framework will generally include a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.
The communication framework generally includes a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The communication framework will generally include a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.
The communication framework generally includes a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The communication framework will generally include a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.
The communication framework generally includes a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The communication framework will generally include a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.
The communication framework generally includes a Peer discovery API for devices to advertise themselves on the network and to browse for other Peers.

Using these Vale rules:


image::ROOT:discovery.png[]

[#active-peer]
=== Active Peer

The first step is to initialize the Couchbase Lite database.

[#passive-peer]
=== Passive Peer

In addition to initializing the database, the Passive Peer must initialize the `MessageEndpointListener`.
The `MessageEndpointListener` acts as a Listener for incoming connections.

[source]
----
include::android:example$codesnippet_collection.kt[tag=listener,indent=0]
----

[#peer-selection-and-connection-setup]
== Peer Selection and Connection Setup


Once a Peer device is found, the application code must decide whether it should establish a connection with that Peer.
This step includes inviting a Peer to a session and Peer authentication.

This is handled by the Communication Framework.

image::ROOT:selection.png[]

Once the remote Peer has been authenticated, the next step is to connect with that Peer and initialize the Message Endpoint API.


[#replication-setup]
== Replication Setup


image::ROOT:connection.png[]

[#active-peer-2]
=== Active Peer

When the connection is established, the active Peer must instantiate a `MessageEndpoint` object corresponding to the remote Peer.

[source]
----
include::android:example$codesnippet_collection.kt[tag=message-endpoint,indent=0]
----

The `MessageEndpoint` initializer takes the following arguments.

. `uid`: a unique ID that represents the remote active Peer.
. `target`: This represents the remote passive Peer and could be any suitable representation of the remote Peer.
It could be an Id, URL etc.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
It could be an Id, URL etc.
It could be an Id, URL and so on.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
It could be an Id, URL etc.
It could be an Id, URL and so on.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
It could be an Id, URL etc.
It could be an Id, URL and so on.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
It could be an Id, URL etc.
It could be an Id, URL and so on.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
It could be an Id, URL etc.
It could be an Id, URL and so on.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
It could be an Id, URL etc.
It could be an Id, URL and so on.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
It could be an Id, URL etc.
It could be an Id, URL and so on.

Using these Vale rules:

If using the MultiPeerConnectivity Framework, this could be the MCPeerID.
. `protocolType`: specifies the kind of transport you intend to implement.
There are two options.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
There are two options.
Two options are available.

Using these Vale rules:

  • write-good.ThereIs (error) - Don't start a sentence with 'There are'.
  • Couchbase.ThereIs (error) - Don't start a sentence with "there" + a form of "to be."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
There are two options.
Two options exist.

Using these Vale rules:

  • write-good.ThereIs (error) - Don't start a sentence with 'There are'.
  • Couchbase.ThereIs (error) - Don't start a sentence with "there" + a form of "to be."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
There are two options.
Two options exist.

Using these Vale rules:

  • Couchbase.ThereIs (error) - Don't start a sentence with "there" + a form of "to be."
  • write-good.ThereIs (error) - Don't start a sentence with 'There are'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
There are two options.
Two options exist.

Using these Vale rules:

  • Couchbase.ThereIs (error) - Don't start a sentence with "there" + a form of "to be."
  • write-good.ThereIs (error) - Don't start a sentence with 'There are'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
There are two options.
Two options exist.

Using these Vale rules:

  • write-good.ThereIs (error) - Don't start a sentence with 'There are'.
  • Couchbase.ThereIs (error) - Don't start a sentence with "there" + a form of "to be."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
There are two options.
Two options exist.

Using these Vale rules:

  • write-good.ThereIs (error) - Don't start a sentence with 'There are'.
  • Couchbase.ThereIs (error) - Don't start a sentence with "there" + a form of "to be."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
There are two options.
Two options exist.

Using these Vale rules:

  • write-good.ThereIs (error) - Don't start a sentence with 'There are'.
  • Couchbase.ThereIs (error) - Don't start a sentence with "there" + a form of "to be."

** The default (`MessageStream`) means that you want to "send a series of messages", or in other words the Communication Framework will control the formatting of messages so that there are clear boundaries between messages.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
** The default (`MessageStream`) means that you want to "send a series of messages", or in other words the Communication Framework will control the formatting of messages so that there are clear boundaries between messages.
** The default (`MessageStream`) means that you want to "send a series of messages," or in other words the Communication Framework controls the formatting of messages so that there are clear boundaries between messages.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The default (`MessageStream`) means that you want to "send a series of messages", or in other words the Communication Framework will control the formatting of messages so that there are clear boundaries between messages.
** The default (`MessageStream`) means that you want to "send a series of messages," or in other words the Communication Framework controls the formatting of messages so that there are clear boundaries between messages.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The default (`MessageStream`) means that you want to "send a series of messages", or in other words the Communication Framework will control the formatting of messages so that there are clear boundaries between messages.
** The default (`MessageStream`) means that you want to "send a series of messages," or in other words the Communication Framework controls the formatting of messages so that there are clear boundaries between messages.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The default (`MessageStream`) means that you want to "send a series of messages", or in other words the Communication Framework will control the formatting of messages so that there are clear boundaries between messages.
** The default (`MessageStream`) means that you want to "send a series of messages," or in other words the Communication Framework controls the formatting of messages so that there are clear boundaries between messages.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The default (`MessageStream`) means that you want to "send a series of messages", or in other words the Communication Framework will control the formatting of messages so that there are clear boundaries between messages.
** The default (`MessageStream`) means that you want to "send a series of messages," or in other words the Communication Framework controls the formatting of messages so that there are clear boundaries between messages.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The default (`MessageStream`) means that you want to "send a series of messages", or in other words the Communication Framework will control the formatting of messages so that there are clear boundaries between messages.
** The default (`MessageStream`) means that you want to "send a series of messages," or in other words the Communication Framework controls the formatting of messages so that there are clear boundaries between messages.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The default (`MessageStream`) means that you want to "send a series of messages", or in other words the Communication Framework will control the formatting of messages so that there are clear boundaries between messages.
** The default (`MessageStream`) means that you want to "send a series of messages," or in other words the Communication Framework controls the formatting of messages so that there are clear boundaries between messages.

Using these Vale rules:

** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to ensure that messages get delivered in full.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to ensure that messages get delivered in full.
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to make sure that messages get delivered in full.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to ensure that messages get delivered in full.
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to make sure that messages get delivered in full.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to ensure that messages get delivered in full.
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to make sure that messages get delivered in full.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to ensure that messages get delivered in full.
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to make sure that messages get delivered in full.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to ensure that messages get delivered in full.
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to make sure that messages get delivered in full.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to ensure that messages get delivered in full.
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to make sure that messages get delivered in full.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to ensure that messages get delivered in full.
** The alternative (`ByteStream`) means that you just want to send raw bytes over the stream and Couchbase should format for you to make sure that messages get delivered in full.

Using these Vale rules:

+
Typically, the Communication Framework will handle message assembly and disassembly so you would use the `MessageType` option in most cases.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Typically, the Communication Framework will handle message assembly and disassembly so you would use the `MessageType` option in most cases.
Typically, the Communication Framework handles message assembly and disassembly so you would use the `MessageType` option in most cases.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Typically, the Communication Framework will handle message assembly and disassembly so you would use the `MessageType` option in most cases.
Typically, the Communication Framework handles message assembly and disassembly so you would use the `MessageType` option in most cases.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Typically, the Communication Framework will handle message assembly and disassembly so you would use the `MessageType` option in most cases.
Typically, the Communication Framework handles message assembly and disassembly so you would use the `MessageType` option in most cases.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Typically, the Communication Framework will handle message assembly and disassembly so you would use the `MessageType` option in most cases.
Typically, the Communication Framework handles message assembly and disassembly so you would use the `MessageType` option in most cases.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Typically, the Communication Framework will handle message assembly and disassembly so you would use the `MessageType` option in most cases.
Typically, the Communication Framework handles message assembly and disassembly so you would use the `MessageType` option in most cases.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Typically, the Communication Framework will handle message assembly and disassembly so you would use the `MessageType` option in most cases.
Typically, the Communication Framework handles message assembly and disassembly so you would use the `MessageType` option in most cases.

Using these Vale rules:


. `delegate`: the delegate that will implement the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
. `delegate`: the delegate that will implement the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.
. `delegate`: the delegate that implements the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
. `delegate`: the delegate that will implement the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.
. `delegate`: the delegate that implements the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
. `delegate`: the delegate that will implement the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.
. `delegate`: the delegate that implements the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
. `delegate`: the delegate that will implement the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.
. `delegate`: the delegate that implements the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
. `delegate`: the delegate that will implement the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.
. `delegate`: the delegate that implements the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
. `delegate`: the delegate that will implement the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.
. `delegate`: the delegate that implements the `MessageEndpointDelegate` protocol, which is a factory for `MessageEndpointConnection`.

Using these Vale rules:


Then, a `Replicator` is instantiated with the initialized `MessageEndpoint` as the target.

[source]
----
include::android:example$codesnippet_collection.kt[tag=message-endpoint-replicator,indent=0]
----

Next, Couchbase Lite will call back the application code through the `MessageEndpointDelegate.createConnection` interface method.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointDelegate.createConnection` interface method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointDelegate.createConnection` interface method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointDelegate.createConnection` interface method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointDelegate.createConnection` interface method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointDelegate.createConnection` interface method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointDelegate.createConnection` interface method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointDelegate.createConnection` interface method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointDelegate.createConnection` interface method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointDelegate.createConnection` interface method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointDelegate.createConnection` interface method.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointDelegate.createConnection` interface method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointDelegate.createConnection` interface method.

Using these Vale rules:

When the application receives the callback, it must create an instance of `MessageEndpointConnection` and return it.


[source]
----
include::android:example$codesnippet_collection.kt[tag=create-connection,indent=0]
----
Next, Couchbase Lite will call back the application code through the `MessageEndpointConnection.open` method.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointConnection.open` method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointConnection.open` method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointConnection.open` method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointConnection.open` method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointConnection.open` method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Next, Couchbase Lite will call back the application code through the `MessageEndpointConnection.open` method.
Next, Couchbase Lite calls back the application code through the `MessageEndpointConnection.open` method.

Using these Vale rules:


[source]
----
include::android:example$codesnippet_collection.kt[tag=active-peer-open,indent=0]
----

The connection argument is then set on an instance variable.
The application code must keep track of every `ReplicatorConnection` associated with every `MessageEndpointConnection`.

The `MessageError` argument in the completion block specifies whether the error is recoverable or not.
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection` instance.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection` instance.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection` instance.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection` instance.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection` instance.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection` instance.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection` instance.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection` instance.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection` instance.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection` instance.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection` instance.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection` instance.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection` instance.

Using these Vale rules:


[#passive-peer-2]
=== Passive Peer

After connection establishment on the Passive Peer, the first step is to initialize a new `MessageEndpointConnection` and pass it to the listener.
This message tells the listener to accept incoming data from that Peer.

[source]
----
include::android:example$codesnippet_collection.kt[tag=advertizer-accept,indent=0]
----

`messageEndpointListener` is the instance of the `MessageEndpointListener` that was created in the first step (<<peer-discovery,Peer Discovery>>)

Couchbase Lite will call the application code back through the `MessageEndpointConnection.open` method.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI:

Suggested change
Couchbase Lite will call the application code back through the `MessageEndpointConnection.open` method.
Couchbase Lite calls the application code back through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Couchbase Lite will call the application code back through the `MessageEndpointConnection.open` method.
Couchbase Lite calls the application code back through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Couchbase Lite will call the application code back through the `MessageEndpointConnection.open` method.
Couchbase Lite calls the application code back through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Couchbase Lite will call the application code back through the `MessageEndpointConnection.open` method.
Couchbase Lite calls the application code back through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Couchbase Lite will call the application code back through the `MessageEndpointConnection.open` method.
Couchbase Lite calls the application code back through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Couchbase Lite will call the application code back through the `MessageEndpointConnection.open` method.
Couchbase Lite calls the application code back through the `MessageEndpointConnection.open` method.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Couchbase Lite will call the application code back through the `MessageEndpointConnection.open` method.
Couchbase Lite calls the application code back through the `MessageEndpointConnection.open` method.

Using these Vale rules:


[source]
----
include::android:example$codesnippet_collection.kt[tag=passive-peer-open,indent=0]
----

The `connection` argument is then set on an instance variable.
The application code must keep track of every `ReplicatorConnection` associated with every `MessageEndpointConnection`.

At this point, the connection is established, and both Peers are ready to exchange data.


[#pushpull-replication]
== Push/Pull Replication

Typically, an application needs to send data and receive data.
The directionality of the replication could be any of the following.

* *Push only:* The data is pushed from the local database to the remote database.

* *Pull only:* The data is pulled from the remote database to the local database.

* *Push and Pull:* The data is exchanged both ways.

Typically, the remote is a Sync Gateway database identified through a URL.
In Peer-to-Peer syncing, the remote is another Couchbase Lite database.

image::ROOT:replication.png[]

The replication lifecycle is handled through the `MessageEndpointConnection`.

[#active-peer-3]
=== Active Peer

When Couchbase Lite calls back the application code through the `MessageEndpointConnection.send` method, you should send that data to the other Peer using the communication framework.

[source]
----
include::android:example$codesnippet_collection.kt[tag=active-peer-send,indent=0]
----

Once the data is sent, call the completion block to acknowledge the completion.
You can use the `MessageError` in the completion block to specify whether the error is recoverable.
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:



When data is received from the passive Peer via the Communication Framework, you call the `ReplicatorConnection.receive` method.

[source]
----
include::android:example$codesnippet_collection.kt[tag=active-peer-receive,indent=0]
----

The replication connection's `receive` method is called. Which then processes the data to persist to the local database.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
The replication connection's `receive` method is called. Which then processes the data to persist to the local database.
The replication connection's `receive` method is called.
Which then processes the data to persist to the local database.

Using these Vale rules:

  • Couchbase.VentilatedProse (warning) - Use ventilated prose. Start every sentence on a new line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The replication connection's `receive` method is called. Which then processes the data to persist to the local database.
The replication connection's `receive` method is called.
Which then processes the data to persist to the local database.

Using these Vale rules:

  • Couchbase.VentilatedProse (warning) - Use ventilated prose. Start every sentence on a new line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The replication connection's `receive` method is called. Which then processes the data to persist to the local database.
The replication connection's `receive` method is called.
Which then processes the data to persist to the local database.

Using these Vale rules:

  • Couchbase.VentilatedProse (warning) - Use ventilated prose. Start every sentence on a new line.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The replication connection's `receive` method is called. Which then processes the data to persist to the local database.
The replication connection's `receive` method is called.
Which then processes the data to persist to the local database.

Using these Vale rules:

  • Couchbase.VentilatedProse (warning) - Use ventilated prose. Start every sentence on a new line.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
The replication connection's `receive` method is called. Which then processes the data to persist to the local database.
The replication connection's `receive` method is called.
Which then processes the data to persist to the local database.

Using these Vale rules:

  • Couchbase.VentilatedProse (warning) - Use ventilated prose. Start every sentence on a new line.


[#passive-peer-3]
=== Passive Peer

As in the case of the active Peer, the passive Peer must implement the `MessageEndpointConnection.send` method to send data to the other Peer.

[source]
----
include::android:example$codesnippet_collection.kt[tag=passive-peer-send,indent=0]
----

Once the data is sent, call the completion block to acknowledge the completion.
You can use the `MessageError` in the completion block to specify whether the error is recoverable.
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
If it is a recoverable error, the replicator will begin a retry process, creating a new `MessageEndpointConnection`.
If it's a recoverable error, the replicator begins a retry process, creating a new `MessageEndpointConnection`.

Using these Vale rules:


When data is received from the active Peer via the Communication Framework, you call the `ReplicatorConnection.receive` method.

[source]
----
include::android:example$codesnippet_collection.kt[tag=passive-peer-receive,indent=0]
----

[#connection-teardown]
== Connection Teardown

When a Peer disconnects from a Peer-to-Peer network, all connected Peers are notified.
The disconnect notification is a good opportunity to close and remove a replication connection.
The steps to Teardown the connection are slightly different depending on whether the active or passive Peer disconnects first.
We will cover each case below.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
We will cover each case below.
Each case is covered in this documentation.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'We'.
  • Google.Will (warning) - Avoid using 'will'.
  • Couchbase.DirectionalLanguage (warning) - Avoid directional language like 'below'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
We will cover each case below.
This document covers each case.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'We'.
  • Google.Will (warning) - Avoid using 'will'.
  • Couchbase.DirectionalLanguage (warning) - Avoid directional language like 'below'.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
We will cover each case below.
This document covers each case.

Using these Vale rules:

  • Google.We (warning) - Try to avoid using first-person plural like 'We'.
  • Google.Will (warning) - Avoid using 'will'.
  • Couchbase.DirectionalLanguage (warning) - Avoid directional language like 'below'.


[#initiated-by-active-peer]
=== Initiated by Active Peer

image::ROOT:dis-active.png[]

[#active-peer-4]
=== Active Peer

When an active Peer disconnects, it must call the `ReplicatorConnection.close` method.

[source]
----
include::android:example$codesnippet_collection.kt[tag=active-replicator-close,indent=0]
----

Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:


[source]
----
include::android:example$codesnippet_collection.kt[tag=active-peer-close,indent=0]
----

[#passive-peer-4]
=== Passive Peer

When the passive Peer receives the corresponding disconnect notification from the Communication Framework, it must call the `ReplicatorConnection.close` method.

[source]
----
include::android:example$codesnippet_collection.kt[tag=passive-replicator-close,indent=0]
----

Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:


[source]
----
include::android:example$codesnippet_collection.kt[tag=passive-peer-close,indent=0]
----

[#initiated-by-passive-peer]
=== Initiated by Passive Peer

image::ROOT:dis-passive.png[]

[#passive-peer-5]
=== Passive Peer

When the passive disconnects, it must class the `MessageEndpointListener.closeAll` method.

[source]
----
include::android:example$codesnippet_collection.kt[tag=passive-stop-listener,indent=0]
----

Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:


[source]
----
include::android:example$codesnippet_collection.kt[tag=passive-peer-close,indent=0]
----

[#active-peer-5]
=== Active Peer

When the active Peer receives the corresponding disconnect notification from the Communication Framework, it must call the `ReplicatorConnection.close` method.

[source]
----
include::android:example$codesnippet_collection.kt[tag=active-replicator-close,indent=0]
----

Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4.1 model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review comment from Vale and OpenAI using the gpt-4o-mini model:

Suggested change
Then, Couchbase Lite will call back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.
Then, Couchbase Lite calls back your code through the `MessageEndpointConnection.close` to allow the application to disconnect with the Communication Framework.

Using these Vale rules:


[source]
----
include::android:example$codesnippet_collection.kt[tag=active-peer-close,indent=0]
----

[#related-content]
== Related Content
++++
<div class="card-row three-column-row">
++++

[.column]
=== {empty}
.How to
* xref:android:p2psync-websocket-using-passive.adoc[Passive Peer]
* xref:android:p2psync-websocket-using-active.adoc[Active Peer]


.

[.column]
=== {empty}
.Concepts
* xref:android:landing-p2psync.adoc[Peer-to-Peer Sync]

* https://docs.couchbase.com/mobile/{major}.{minor}.{maintenance-android}{empty}/couchbase-lite-android/[API References]

.


[.column]
=== {empty}
.Community Resources ...
https://forums.couchbase.com/c/mobile/14[Mobile Forum] |
https://blog.couchbase.com/[Blog] |
https://docs.couchbase.com/tutorials/[Tutorials]

.
xref:tutorials:cbl-p2p-sync-websockets:swift/cbl-p2p-sync-websockets.adoc[Getting Started with Peer-to-Peer Synchronization]


++++
</div>
++++

Loading
Loading