Show / Hide Table of Contents

    Class Session

    An object encapsulating a Realm Object Server session. Sessions represent the communication between the client (and a local Realm file on disk), and the server (and a remote Realm at a given URL stored on a Realm Object Server). Sessions are always created by the SDK and vended out through various APIs. The lifespans of sessions associated with Realms are managed automatically.

    Inheritance
    Object
    Session
    Inherited Members
    Object.Equals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Object.ToString()
    Namespace:Realms.Sync
    Assembly:Realm.Sync.dll
    Syntax
    public class Session

    Properties

    | Improve this Doc View Source

    Path

    Gets the on-disk path of the Realm file backing the Realm this Session represents.

    Declaration
    public string Path { get; }
    Property Value
    Type Description
    String

    The file path.

    | Improve this Doc View Source

    ServerUri

    Gets the Uri describing the remote Realm which this session connects to and synchronizes changes with.

    Declaration
    public Uri ServerUri { get; }
    Property Value
    Type Description
    Uri

    The Uri where the Realm Object Server resides.

    | Improve this Doc View Source

    State

    Gets the session’s current state.

    Declaration
    public SessionState State { get; }
    Property Value
    Type Description
    SessionState

    An enum value indicating the state of the session.

    | Improve this Doc View Source

    User

    Gets the User defined by the SyncConfiguration that is used to connect to the Realm Object Server.

    Declaration
    public User User { get; }
    Property Value
    Type Description
    User

    The User that was used to create the Realm's SyncConfiguration.

    Methods

    | Improve this Doc View Source

    Equals(Object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean
    Overrides
    Object.Equals(Object)
    | Improve this Doc View Source

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    Object.GetHashCode()
    | Improve this Doc View Source

    GetProgressObservable(ProgressDirection, ProgressMode)

    Gets an IObservable<T> that can be used to track upload or download progress.

    Declaration
    public IObservable<SyncProgress> GetProgressObservable(ProgressDirection direction, ProgressMode mode)
    Parameters
    Type Name Description
    ProgressDirection direction

    The transfer direction (upload or download) to track in the subscription callback.

    ProgressMode mode

    The desired behavior of this progress notification block.

    Returns
    Type Description
    IObservable<SyncProgress>

    An observable that you can subscribe to and receive progress updates.

    Remarks

    To start receiving notifications, you should call Subscribe(IObserver<T>) on the returned object. The token returned from Subscribe(IObserver<T>) should be retained as long as progress notifications are desired. To stop receiving notifications, call Dispose() on the token. You don't need to keep a reference to the observable itself. The progress callback will always be called once immediately upon subscribing in order to provide the latest available status information.

    Examples

    class ProgressNotifyingViewModel
    {
        private IDisposable notificationToken;

    public void ShowProgress()
    {
        var observable = session.GetProgressObservable(ProgressDirection.Upload, ProgressMode.ReportIndefinitely);
        notificationToken = observable.Subscribe(progress =&gt;
        {
            // Update relevant properties by accessing
            // progress.TransferredBytes and progress.TransferableBytes
        });
    }
    
    public void HideProgress()
    {
        notificationToken?.Dispose();
        notificationToken = null;
    }
    

    }

    In this example we're using ObservableExtensions.Subscribe found in the Reactive Extensions class library. If you prefer not to take a dependency on it, you can create a class that implements IObserver<T> and use it to subscribe instead.

    | Improve this Doc View Source

    Reconnect()

    Attempts to reconnect all sessions.

    Declaration
    public static void Reconnect()
    Remarks

    By default, the sync engine will attempt to reconnect sessions at incrementing intervals. This method is useful when you are monitoring connectivity yourself, using e.g. Connectivity Plugin or through the native connectivity API and you wish to cancel that delay and try to reconnect immediately.

    | Improve this Doc View Source

    WaitForDownloadAsync()

    Waits for the Session to finish all pending downloads.

    Declaration
    public Task WaitForDownloadAsync()
    Returns
    Type Description
    Task

    A Task that will be completed when all pending downloads for this Session are completed.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when a faulted session is waited on.

    | Improve this Doc View Source

    WaitForUploadAsync()

    Waits for the Session to finish all pending uploads.

    Declaration
    public Task WaitForUploadAsync()
    Returns
    Type Description
    Task

    A Task that will be completed when all pending uploads for this Session are completed.

    Exceptions
    Type Condition
    InvalidOperationException

    Thrown when a faulted session is waited on.

    Events

    | Improve this Doc View Source

    Error

    Triggered when an error occurs on a session. The sender argument will be the session which has errored.

    Declaration
    public static event EventHandler<ErrorEventArgs> Error
    Event Type
    Type Description
    EventHandler<ErrorEventArgs>

    Extension Methods

    TestingExtensions.SimulateError(Session, ErrorCode, String, Boolean)
    TestingExtensions.SimulateProgress(Session, UInt64, UInt64, UInt64, UInt64)
    • Improve this Doc
    • View Source
    Back to top Copyright © 2017 Realm
    Generated by DocFX