Data Sync
Advanced Customizations

Handling Connection Requests

This article provides concepts and step-by-step instructions for how to use the connectingRequestHandler API method within your app logic to enable end-user functionality of intercepting and managing new peer connections advertised in the mesh.

Overview

Using the connectionRequestHandler API method, you can intercept new peer connections and make decisions to accept or reject them based on the peer metadata set for a given device. (See Setting the Connection Request Handler)

Within the connectionRequestHandler you can use the connectionRequest parameter to access information about the peer connection request. (See Reading Connection Parameter)

  • Peer key string — The identifier encoded as a string that uniquely identifies the requesting peer once discovered within the mesh.
  • Connection type — The type of connection the peer is requesting.
  • Peer metadata — The information provided by the end user associated with the peer making the request. (For more information on peer metadata, see Using Mesh Presence)

Setting the Connection Request Handler

To accept or reject an incoming connection request:

Once you've set the request handler, end users must always make a choice to accept or reject incoming connection requests; otherwise, potential issues like request deadlocks and connection timeouts may result.

Swift
Kotlin
JS
Java
C#
C++
Rust
Dart (beta)


Reading Connection Parameter

To see specific information associated with a requesting peer connection

Swift
Kotlin
JS
Java
C#
C++
Rust
Dart (beta)