Logical Labs Multipeer Module

API Docs for: 1.0.0
Show:

Peer Class

Module: Readme

Objects of this class represents peers in a multipeer session.

The Multipeer Connectivity framework is responsible for creating peer objects that represent other devices. Your app is responsible for creating a single peer object that represents the instance of your app that is running on the local device.

To create a new peer for the local app and associate a display name with that peer, call the createPeer function.

Item Index

Properties

Methods

createAdvertiser

(
  • params
)
Advertiser

Available since 1.0.0

Creates an Advertiser object.

Parameters:

  • params Object
    • discoveryInfo Object

      A dictionary of key-value pairs that are made available to browsers. Each key and value must be a string. This data is advertised using a Bonjour TXT record, encoded according to RFC 6763 (section 6). As a result, the key-value pair must be no longer than 255 bytes (total) when encoded in UTF-8 format with an equals sign (=) between the key and the value, and keys cannot contain an equals sign.

      For optimal performance, the total size of the keys and values in this dictionary should be no more than about 400 bytes so that the entire advertisement can fit within a single Bluetooth data packet.

    • serviceType String

      The type of service to advertise. This should be a short text string that describes the app's networking protocol, in the same format as a Bonjour service type. It must be 1–15 characters long and can contain only ASCII lowercase letters, numbers, and hyphens.

      This name should be easily distinguished from unrelated services. For example, a text chat app made by ABC company could use the service type abc-txtchat.

Returns:

createBrowser

(
  • params
)
Browser

Available since 1.0.0

Creates a Browser object.

Parameters:

  • params Object
    • serviceType String

      The service type to browse for. Must be 1–15 characters long and can contain only ASCII lowercase letters, numbers, and hyphens.

      This name should be easily distinguished from unrelated services. For example, a text chat app made by ABC company could use the service type abc-txtchat.

Returns:

createSession

(
  • params
)
Session

Available since 1.0.0

Creates a Session object.

Parameters:

  • params Object
    • [encryptionPreference] Number optional

      An integer value that indicates whether encryption is required, preferred, or undesirable. Use one of the ENCRYPTION_* constants to set this value. Defaults to ENCRYPTION_OPTIONAL.

Returns:

Properties

name

String read-only

Available since 1.0.0

The display name for this peer.

For the local peer, this property is set when the object is initialized. For other peer objects provided to you by the framework, this property is provided by the peer.