Latest 0.1.6
Homepage https://github.com/dustMason/JSMultiParty
License MIT
Platforms ios 8.0, requires ARC
Frameworks MultipeerConnectivity
Authors

Version
License
Platform

While implementing Apple’s MultipeerConnectivity framework in a recent project, I ran up against a few issues with it. Some research revealed that I wasn’t alone in my frustations so I whipped up a small class which implements MCSessionDelegate, MCNearbyServiceAdvertiserDelegate and MCNearbyServiceBrowserDelegate. It was originally designed for usage in a chat application but would suit other purposes well.

Why you might want to use it:

  • It avoids the issue of "ghost" peers with identical names appearing on the network by storing and re-using an MCPeerID for each client. It further alleviates this issue by allowing the apparent name of each client to change by using the discoveryInfo property of each MCNearbyServiceAdvertiser instance while keeping the displayName the same.
  • Clients automatically invite one another as soon as they appear on the network. The "mutual invite" issue is avoided by determining the inviter and invitee by comparing hashes of their peer IDs.
  • It offers convenience methods for sending / receiving UIImage instances among clients.

Usage

Import the module:

import MultiParty

Then implement JSMultiPartyDelegate:

public protocol JSMultiPartyDelegate {
  func didReceiveMessageFromPeerId(peerId: MCPeerID, message: AnyObject)
  func didConnectToPeerId(peerId: MCPeerID)
  func didDisconnectFromPeerId(peerId: MCPeerID)
  func didFindPeerId(peerId: MCPeerID, name: String?)
  func didLosePeerId(peerId: MCPeerID)
  func didStartReceivingImage(peerId: MCPeerID, progress: NSProgress)
  func didFinishReceivingImage(peerId: MCPeerID, image: UIImage)
  func didReceiveStream(stream: NSInputStream, withName: String, fromPeer: MCPeerID)
  func didFailToReceiveImage(peerId: MCPeerID, error: NSError)
  func didNotStartAdvertisingPeer(error: NSError)
  func didNotStartBrowsingForPeers(error: NSError)
}

Requirements

Being a new Swift based CocoaPod, it wont work on < iOS 8. For iOS 7+ support you can simply copy the class into your project.

Installation

MultiParty is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "MultiParty"

Author

Jordan Sitkin, [email protected]

License

MultiParty is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "MultiParty",
    "version": "0.1.6",
    "summary": "Putting some fun into MultipeerConnectivity",
    "description": "                       A wrapper for Apple's MultipeerConnectivity framework thatn                       makes it easier to handle common uses, such as peer-to-peern                       chat. See https://github.com/dustMason/JSMultiParty for more.n",
    "homepage": "https://github.com/dustMason/JSMultiParty",
    "license": "MIT",
    "authors": {
        "Jordan Sitkin": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dustMason/JSMultiParty.git",
        "tag": "0.1.6"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "source_files": "JSMultiParty.swift",
    "frameworks": "MultipeerConnectivity"
}

Pin It on Pinterest

Share This