Skip to content

Commit b9d858c

Browse files
(DOCSP-39538): Consolidate Manage Sync Sessions page (#3285)
## Pull Request Info - SDK Docs Consolidation Jira ticket: https://jira.mongodb.org/browse/DOCSP-39538 *Staged Page* - [Manage Sync Sessions](https://preview-mongodbdacharyc.gatsbyjs.io/realm/DOCSP-39538/sdk/sync/manage-sync-sessions/) *Page Source* Add links to every SDK's pages where you got the SDK-specific information: - [C++: Manage Sync Sessions](https://www.mongodb.com/docs/atlas/device-sdks/sdk/cpp/sync/manage-sync-session/) - [Flutter: Manage Sync Sessions](https://www.mongodb.com/docs/atlas/device-sdks/sdk/flutter/sync/manage-sync-session/) - [Java: Pause or Resume a Sync Session](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/sync/pause-resume-sync/) - [Java: Check the Network Connection](https://www.mongodb.com/docs/atlas/device-sdks/sdk/java/sync/network-connection/) - [Kotlin: Manage Sync Session](https://www.mongodb.com/docs/atlas/device-sdks/sdk/kotlin/sync/manage-sync-session/) - [.NET: Suspend or Resume a Sync Session](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/sync/sync-session/) - [.NET: Check Upload and Download Progress](https://www.mongodb.com/docs/atlas/device-sdks/sdk/dotnet/sync/sync-progress/) - [Node.js: Manage a Sync Session](https://www.mongodb.com/docs/atlas/device-sdks/sdk/node/sync/manage-sync-session/) - [Swift: Manage Sync Sessions](https://www.mongodb.com/docs/atlas/device-sdks/sdk/swift/sync/sync-session/) ### PR Author Checklist Before requesting a review for your PR, please check these items: - [x] Open the PR against the `feature-consolidated-sdk-docs` branch instead of `master` - [x] Tag the consolidated page for: - genre - meta.keywords - meta.description #### Naming - [x] Update Realm naming and the language around persistence layer/local/device per [this document](https://docs.google.com/document/d/126OczVxBWAwZ4P5ZsSM29WI3REvONEr1ald-mAwPtyQ/edit?usp=sharing) - [x] Include `.rst` files comply with [the naming guidelines](https://docs.google.com/document/d/1h8cr66zoEVeXytVfvDxlCSsUS5IZwvUQvfSCEXNMpek/edit#heading=h.ulh8b5f2hu9) #### Links and Refs - [x] Create new consolidated SDK ref targets starting with "_sdks-" for relevant sections - [x] Remove or update any SDK-specific refs to use the new consolidated SDK ref targets - [x] [Update any Kotlin API links](https://jira.mongodb.org/browse/DOCSP-32519) to use the new Kotlin SDK roles #### Content - [x] Shared code boxes have snippets or placeholders for all 9 languages - [x] API description sections have API details or a generic placeholder for all 9 languages - [x] Check related pages for relevant content to include - [x] Create a ticket for missing examples in each relevant SDK: Consolidation Gaps epic ### Reviewer Checklist As a reviewer, please check these items: - [x] Shared code example boxes contain language-specific snippets or placeholders for every language - [x] API reference details contain working API reference links or generic content - [x] Realm naming/language has been updated - [x] All relevant content from individual SDK pages is present on the consolidated page --------- Co-authored-by: Kyle Rollins <[email protected]>
1 parent ae0e146 commit b9d858c

File tree

64 files changed

+1472
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1472
-38
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The C++ SDK does not currently support this API.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
**Check Connection State**
2+
3+
To check the connection state, you can read the
4+
:cpp-sdk:`sync session instance's <structrealm_1_1internal_1_1bridge_1_1sync__session.html>`
5+
``connection_state()`` property directly.
6+
7+
.. literalinclude:: /examples/generated/cpp/sync-session.snippet.connection-state.cpp
8+
:language: cpp
9+
10+
The network connection state is distinct from the Device Sync connection state
11+
that you can check with the ``state()`` method. For more information about
12+
sync connection state, refer to the Check the Sync State documentation on
13+
this page.
14+
15+
**Observe Connection State**
16+
17+
You can also observe the connection state with the
18+
:cpp-sdk:`observe_connection_change() <structrealm_1_1internal_1_1bridge_1_1sync__session.html#a38096e71024b3fd252d3356af5eee113>`
19+
function. This function registers a callback that the SDK invokes when the
20+
underlying sync session changes its connection state.
21+
22+
.. literalinclude:: /examples/generated/cpp/sync-session.snippet.observe-connection-change.cpp
23+
:language: cpp
24+
25+
If you register a connection change listener, you can unregister it when
26+
you're done listening for changes. Call the sync session instance's
27+
:cpp-sdk:`unregister_connection_change_observer() <structrealm_1_1internal_1_1bridge_1_1sync__session.html#a86b911bc662f02f607c5e9513d80c0c7>`
28+
method to unregister an observation token.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
You can use the :cpp-sdk:`sync_session
2+
<structrealm_1_1internal_1_1bridge_1_1sync__session.html>`'s public
3+
member function ``state()`` to check whether the sync session is active.
4+
This returns an enum whose value reflects possible Device Sync states.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
You can use the member function :cpp-sdk:`get_sync_session()
2+
<structrealm_1_1db.html#a79c5e6e92896703a54693be35720ae12>` to get a
3+
:cpp-sdk:`sync_session
4+
<structrealm_1_1internal_1_1bridge_1_1sync__session.html>`
5+
object for any synced database. The SDK returns this object as an optional.
6+
It is a lightweight handle that you can pass around by value.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
You can choose to manually trigger a reconnect attempt with a sync session's
2+
:cpp-sdk:`reconnect() <structrealm_1_1internal_1_1bridge_1_1sync__session.html#af5557f2a2ae8869e6a129afc264e8695>`
3+
method.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
To pause a sync session, call the sync session's
2+
:cpp-sdk:`pause() <structrealm_1_1internal_1_1bridge_1_1sync__session.html#ab187b267f0391c8262a0edcff32fcc29>`
3+
method.
4+
5+
.. literalinclude:: /examples/generated/cpp/sync-session.snippet.pause.cpp
6+
:language: cpp
7+
8+
To resume a sync session, call the sync session's
9+
:cpp-sdk:`resume() <structrealm_1_1internal_1_1bridge_1_1sync__session.html#a253ef9e08d9f4cf7c42edfd6b6f6df80>`
10+
method.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
You can use the
2+
:cpp-sdk:`sync_session <structrealm_1_1internal_1_1bridge_1_1sync__session.html>`'s
3+
``wait_for_upload_completion()`` and ``wait_for_download_completion()``
4+
methods to wait for changes to upload to or download from Atlas. Both of these
5+
methods can optionally take a callback to execute when upload or download
6+
is complete.
7+
8+
To wait for all changes to upload to Atlas from your synced database,
9+
use the member function ``wait_for_upload_completion()``.
10+
11+
.. literalinclude:: /examples/generated/cpp/sync-session.snippet.wait-for-upload.cpp
12+
:language: cpp
13+
14+
To wait for all changes from Atlas
15+
to download to your synced database, use the member function
16+
``wait_for_download_completion()``. Refresh the database after downloading
17+
any changes to be sure it reflects the most recent data.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
To check the connection state, you can read the
2+
:dotnet-sdk:`Session instance's ConnectionState
3+
<reference/Realms.Sync.Session.html#Realms_Sync_Session_ConnectionState>`
4+
property. Its value is a :dotnet-sdk:`ConnectionState enum
5+
<reference/Realms.Sync.ConnectionState.html>` that reflects the current state
6+
of the sync session's connection.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
To check the Sync state, you can read the
2+
:dotnet-sdk:`Session instance's State
3+
<reference/Realms.Sync.Session.html#Realms_Sync_Session_State>`
4+
property. Its value is a :dotnet-sdk:`ConnectionState enum
5+
<reference/Realms.Sync.SessionState.html>` that reflects the current state
6+
of the Sync session's communication with the server.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
To monitor Sync progress, get the Sync session from the
2+
:dotnet-sdk:`Realms.Sync.SyncSession
3+
<reference/Realms.Realm.html#Realms_Realm_SyncSession>` property, then add a
4+
progress notification by calling the
5+
:dotnet-sdk:`session.GetProgressObservable() <reference/Realms.Sync.Session.html#Realms_Sync_Session_GetProgressObservable_Realms_Sync_ProgressDirection_Realms_Sync_ProgressMode_>`
6+
method.
7+
8+
The ``session.GetProgressObservable`` method takes in the following two parameters:
9+
10+
- A :dotnet-sdk:`ProgressDirection <reference/Realms.Sync.ProgressDirection.html>`
11+
parameter that can be set to ``Upload`` or ``Download``.
12+
13+
- A :dotnet-sdk:`ProgressMode <reference/Realms.Sync.ProgressMode.html>` parameter
14+
that can be set to ``ReportIndefinitely``
15+
for the notifications to continue until the callback is unregistered, or
16+
``ForCurrentlyOutstandingWork`` for the notifications to continue until only
17+
the currently transferable bytes are synced.
18+
19+
When you `Subscribe <https://docs.microsoft.com/en-us/dotnet/api/system.iobservable-1.subscribe?view=net-6.0#system-iobservable-1-subscribe(system-iobserver((-0)))>`_
20+
to the notifications, you receive a
21+
:dotnet-sdk:`SyncProgress <reference/Realms.Sync.SyncProgress.html>`
22+
object that provides a percentage estimate of the current progress, expressed
23+
as a double between 0.0 and 1.0.
24+
25+
Once you no longer wish to receive notifications, unregister the token with
26+
``token.Dispose()``.

0 commit comments

Comments
 (0)