MultiPeer

public class MultiPeer: NSObject

Undocumented

  • Undocumented

    Declaration

    Swift

    public static let instance = MultiPeer()
  • Name of MultiPeer session: Up to one hyphen (-) and 15 characters

    Declaration

    Swift

    public var serviceType: String!
  • Device’s name

    Declaration

    Swift

    public var devicePeerID: MCPeerID!
  • Advertises session

    Declaration

    Swift

    public var serviceAdvertiser: MCNearbyServiceAdvertiser!
  • Browses for sessions

    Declaration

    Swift

    public var serviceBrowser: MCNearbyServiceBrowser!
  • Amount of time to spend connecting before timeout

    Declaration

    Swift

    public var connectionTimeout = 10.0
  • Peers available to connect to

    Declaration

    Swift

    public var availablePeers: [Peer] = []
  • Peers connected to

    Declaration

    Swift

    public var connectedPeers: [Peer] = []
  • Names of all connected devices

    Declaration

    Swift

    public var connectedDeviceNames: [String]
  • Prints out all errors and status updates

    Declaration

    Swift

    public var debugMode = false
  • Main session object that manages the current connections

    Declaration

    Swift

    public lazy var session: MCSession =
  • Initializes the MultiPeer service with a serviceType and the default deviceName

    Declaration

    Swift

    public func initialize(serviceType: String)

    Parameters

    serviceType

    String with name of MultiPeer service. Up to one hyphen (-) and 15 characters. Uses default device name

  • Initializes the MultiPeer service with a serviceType and a custom deviceName

    Declaration

    Swift

    public func initialize(serviceType: String, deviceName: String)

    Parameters

    serviceType

    String with name of MultiPeer service. Up to one hyphen (-) and 15 characters.

    deviceName

    String containing custom name for device

  • HOST: Automatically browses and invites all found devices

    Declaration

    Swift

    public func startInviting()
  • JOIN: Automatically advertises and accepts all invites

    Declaration

    Swift

    public func startAccepting()
  • HOST and JOIN: Uses both advertising and browsing to connect.

    Declaration

    Swift

    public func autoConnect()
  • Stops the invitation process

    Declaration

    Swift

    public func stopInviting()
  • Stops accepting invites and becomes invisible on the network

    Declaration

    Swift

    public func stopAccepting()
  • Stops all invite/accept services

    Declaration

    Swift

    public func stopSearching()
  • Disconnects from the current session and stops all searching activity

    Declaration

    Swift

    public func disconnect()
  • Stops all invite/accept services, disconnects from the current session, and stops all searching activity

    Declaration

    Swift

    public func end()
  • Undocumented

    Declaration

    Swift

    public var isConnected: Bool
  • Sends an object (and type) to all connected peers.

    Declaration

    Swift

    public func send(object: Any, type: UInt32)

    Parameters

    object

    Object (Any) to send to all connected peers.

    type

    Type of data (UInt32) sent After sending the object, you can use the extension for Data, convertData() to convert it back into an object.

  • Sends Data (and type) to all connected peers.

    Declaration

    Swift

    public func send(data: Data, type: UInt32)

    Parameters

    data

    Data (Data) to send to all connected peers.

    type

    Type of data (UInt32) sent After sending the data, you can use the extension for Data, convertData() to convert it back into data.

  • Undocumented

    Declaration

    Swift

    public func browser(_ browser: MCNearbyServiceBrowser, foundPeer peerID: MCPeerID, withDiscoveryInfo info: [String: String]?)
  • Undocumented

    Declaration

    Swift

    public func browser(_ browser: MCNearbyServiceBrowser, lostPeer peerID: MCPeerID)
  • Undocumented

    Declaration

    Swift

    public func browser(_ browser: MCNearbyServiceBrowser, didNotStartBrowsingForPeers error: Error)