CBLMultipeerReplicator

@interface CBLMultipeerReplicator : NSObject

A multipeer replicator that manages peer discovery, connection, and replication in multipeer mesh network. Peer discovery uses DNS-SD (Bonjour) over Wi-Fi, requiring peers to be on the same network to find and connect to each other.

  • The configuration.

    Declaration

    Objective-C

    @property (nonatomic, copy, readonly) CBLMultipeerReplicatorConfiguration *_Nonnull config;
  • The peer identifier represents this multipeer replicator instance.

    Declaration

    Objective-C

    @property (nonatomic, readonly) CBLPeerID *_Nonnull peerID;
  • A list of currently visible peer identifiers.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSArray<CBLPeerID *> *_Nonnull neighborPeers;
  • Initializes the multipeer replicator with the given configuration.

    Declaration

    Objective-C

    - (nullable instancetype)
        initWithConfig:(nonnull CBLMultipeerReplicatorConfiguration *)config
                 error:(NSError *_Nullable *_Nullable)error;

    Parameters

    config

    The configuration.

    error

    On return, the error if any.

    Return Value

    An initialized replicator instance, or nil on failure.

  • Starts peer discovery and replication with connected peers.

    Note

    Once stopped, restarting is not currently supported.

    Declaration

    Objective-C

    - (void)start;
  • Stops peer discovery and all active replicators.

    Note

    Once stopped, restarting is not currently supported.

    Declaration

    Objective-C

    - (void)stop;
  • Returns information about a peer.

    Declaration

    Objective-C

    - (nullable CBLPeerInfo *)peerInfoForPeerID:(nonnull CBLPeerID *)peerID;

    Parameters

    peerID

    The peer identifier.

    Return Value

    The peer info instance, or nil if the peer is unknown.

  • Adds a listener for changes to the overall multipeer replicator status.

    Declaration

    Objective-C

    - (nonnull id<CBLListenerToken>)
        addStatusListenerWithQueue:(nullable dispatch_queue_t)queue
                          listener:
                              (nonnull void (^)(
                                  CBLMultipeerReplicatorStatus *_Nonnull))listener;

    Parameters

    queue

    The dispatch queue for invoking the listener. If nil, the main queue is used.

    listener

    A block to receive status updates.

    Return Value

    A token for removing the listener.

  • Adds a listener for updates to peer discovery status.

    Declaration

    Objective-C

    - (nonnull id<CBLListenerToken>)
        addPeerDiscoveryStatusListenerWithQueue:(nullable dispatch_queue_t)queue
                                       listener:
                                           (nonnull void (^)(
                                               CBLPeerDiscoveryStatus *_Nonnull))
                                               listener;

    Parameters

    queue

    The dispatch queue for invoking the listener. If nil, the main queue is used.

    listener

    A block to receive discovery status updates.

    Return Value

    A token for removing the listener.

  • Adds a listener for replicator status updates for each connected peer.

    Declaration

    Objective-C

    - (nonnull id<CBLListenerToken>)
        addPeerReplicatorStatusListenerWithQueue:(nullable dispatch_queue_t)queue
                                        listener:
                                            (nonnull void (^)(
                                                CBLPeerReplicatorStatus *_Nonnull))
                                                listener;

    Parameters

    queue

    The dispatch queue for invoking the listener. If nil, the main queue is used.

    listener

    A block to receive per-peer replicator status updates.

    Return Value

    A token for removing the listener.

  • Adds a listener for document replication updates from each connected peer.

    Declaration

    Objective-C

    - (nonnull id<CBLListenerToken>)
        addPeerDocumentReplicationListenerWithQueue:(nullable dispatch_queue_t)queue
                                           listener:(nonnull void (^)(
                                                        CBLPeerDocumentReplication
                                                            *_Nonnull))listener;

    Parameters

    queue

    The dispatch queue for invoking the listener. If nil, the main queue is used.

    listener

    A block to receive per-peer document replication updates.

    Return Value

    A token for removing the listener.

  • Unavailable

    Not available.

    Declaration

    Objective-C

    - (nonnull instancetype)init;