Class Sync


  • public final class Sync
    extends java.lang.Object
    ObjectBox Sync makes data available on other devices.

    Use the static methods to build a Sync client or embedded server.

    • Method Detail

      • isAvailable

        public static boolean isAvailable()
        Returns true if the included native (JNI) ObjectBox library supports Sync.
      • isServerAvailable

        public static boolean isServerAvailable()
        Returns true if the included native (JNI) ObjectBox library supports Sync server.
      • isHybridAvailable

        public static boolean isHybridAvailable()
        Returns true if the included native (JNI) ObjectBox library supports Sync hybrids (server & client).
      • client

        public static SyncBuilder client​(BoxStore boxStore,
                                         java.lang.String url,
                                         SyncCredentials credentials)
        Starts building a SyncClient. Once done, complete with build().
        Parameters:
        boxStore - The BoxStore the client should use.
        url - The URL of the Sync server on which the Sync protocol is exposed. This is typically a WebSockets URL starting with ws:// or wss:// (for encrypted connections), for example ws://127.0.0.1:9999.
        credentials - SyncCredentials to authenticate with the server.
      • server

        public static SyncServerBuilder server​(BoxStore boxStore,
                                               java.lang.String url,
                                               SyncCredentials authenticatorCredentials)
        Starts building a SyncServer. Once done, complete with build().

        Note: when also using Admin, make sure it is started before the server.

        Parameters:
        boxStore - The BoxStore the server should use.
        url - The URL of the Sync server on which the Sync protocol is exposed. This is typically a WebSockets URL starting with ws:// or wss:// (for encrypted connections), for example ws://0.0.0.0:9999.
        authenticatorCredentials - An authentication method available to Sync clients and peers. Additional authenticator credentials can be supplied using the returned builder. For the embedded server, currently only SyncCredentials.sharedSecret(java.lang.String) and SyncCredentials.none() are supported.