Multipeer Connectivity Framework

0 %
100 %
Information about Multipeer Connectivity Framework

Published on March 6, 2014

Author: nscoder-mad



Explanation of the Multipeer Connectivity Framework for iOS and examples.

Multipeer Connectivity Framework @alexruperez

Multipeer Connectivity Framework • Provides support for discovering services provided by nearby iOS devices using infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth personal area networks and subsequently communicating with those services by sending message-based data, streaming data, and resources (such as files). • This connection is not Android compatible, for Android devices you can use Wi-Fi Direct, although it is not as fast as Multipeer. @alexruperez

MCPeerID • The MCPeerID class represents a peer 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 ID for the local app and associate a display name with that ID, call initWithDisplayName:. The peer’s name must be no longer than 63 bytes in UTF-8 encoding. @alexruperez

MCAdvertiserAssistant • Handles advertising, presents incoming invitations to the user and handles users’ responses. This class should be used to provide a user interface for handling invitations when your app does not require programmatic control over the invitation process. • Before you can advertise a service, you must create an MCPeerID object that identifies your app and the user to nearby devices. @alexruperez

• initWithServiceType:(NSString*) serviceType discoveryInfo:(NSDictionary*) info session:(MCSession*) session • serviceType must be 1–15 characters long and can contain only ASCII lowercase letters, numbers, and hyphens. Ex. @“abc-txtchat” • info is just extra information to be broadcasted, may be nil. • Then simply start or stop the advertising. • For more customization check out MCNearbyServiceAdvertiser. @alexruperez

MCAdvertiserAssistantDelegate • Describes the methods that the delegate object for an MCAdvertiserAssistant instance can implement to handle advertising-related events. • advertiserAssitantWillPresentInvitation: (MCAdvertiserAssistant*) advertiserAssistant • advertiserAssistantDidDismissInvitation: (MCAdvertiserAssistant*) advertiserAssistant @alexruperez

MCBrowserViewController • Presents nearby devices to the user and enables the user to invite nearby devices to a session. To use this class, call methods from the underlying UIViewController class (performSegueWithIdentifier:sender: for storyboards or presentViewController:animated:completion: for nib-based views) to present and dismiss the view controller. @alexruperez

• initWithServiceType:(NSString*) serviceType session:(MCSession*) session • The maximumNumberOfPeers property represents max peers allowed in a session, including the local peer. The largest allowable value (and the default) is 8. • The minimumNumberOfPeers property represents min peers allowed in a session, including the local peer. The smallest allowable value (and the default) is 2. @alexruperez

MCBrowserViewControllerDelegate • - (BOOL)browserViewController: (MCBrowserViewController*) browserViewController shouldPresentNearbyPeer:(MCPeerID*) peerID withDiscoveryInfo:(NSDictionary*) info • - (void)browserViewControllerDidFinish: (MCBrowserViewController*) browserViewController • - (void)browserViewControllerWasCancelled: (MCBrowserViewController*) browserViewController @alexruperez

MCNearbyServiceBrowser • Searches (by service type) for services offered by nearby devices using infrastructure Wi-Fi, peer-to-peer Wi-Fi, and Bluetooth, and provides the ability to easily invite those devices to a Multipeer Connectivity session (MCSession). • You can create a custom MCBrowserViewController using your own MCNearbyServiceBrowser with initWithBrowser:session: @alexruperez

MCSession • Enables and manages communication among all peers in a Multipeer Connectivity session. • initWithPeer:(MCPeerID*) myPeerID • The connectedPeers property is array of all peers that are currently connected to this session. @alexruperez

• - (BOOL)sendData:(NSData*) data toPeers: (NSArray*) peerIDs withMode: (MCSessionSendDataMode) mode error:(NSError**) error • - (NSProgress*)sendResourceAtURL:(NSURL*) resourceURL withName:(NSString*) resourceName toPeer:(MCPeerID*) peerID withCompletionHandler: (void (^)(NSError *error))completionHandler • - (NSOutputStream*)startStreamWithName: (NSString*) streamName toPeer:(MCPeerID*) peerID error:(NSError**) error @alexruperez

MCSessionSendDataMode • MCSessionSendDataReliable: The framework should guarantee delivery of each message, enqueueing and retransmitting data as needed, and ensuring in-order delivery. • MCSessionSendDataUnreliable: Messages to peers should be sent immediately without socket-level queueing. If a message cannot be sent immediately, it should be dropped. The order of messages is not guaranteed. This message type should be used for data that ceases to be relevant if delayed, such as real-time gaming data. @alexruperez

Addendum • alexruperez/ARMultipeerConnectivityExample • Multipeer Connectivity Framework Reference • MultipeerGroupChat • tonyd256/TDAudioPlayer • pj4533/AVCaptureMultipeerVideoDataOutput @alexruperez

Add a comment

Related presentations

Related pages

Multipeer Connectivity - NSHipster

Multipeer Connectivity is a framework that enables nearby devices to communicate over infrastructure Wi-Fi networks, peer-to-peer Wi-Fi, and Bluetooth ...
Read more

MultipeerConnectivity | Apple Developer Documentation

The Multipeer Connectivity framework supports the discovery of services provided by nearby devices and supports communicating with those services through ...
Read more

Multipeer Connectivity Framework: Chatten ohne Internet ...

Apples iOS 7 bietet mit Multipeer Connectivity Framework eine Vernetzungsmöglichkeit über WLAN und Bluetooth zwischen iOS-Geräten, ohne dass dafür eine ...
Read more

iOS & Swift Tutorial: Multipeer Connectivity - Ralf Ebert

iOS & Swift Tutorial: Multipeer Connectivity. This tutorial shows how to use the Multipeer Connectivity framework to communicate between iOS devices:
Read more

ios - Multipeer Connectivity Framework - Lost Peer stays ...

I wonder if this Multipeer Connectivity framework is ready for use in the real world, given all the bugs that have been encountered by the community.
Read more

Multipeer Connectivity Framework - AppCoda

Apple introduced the Multipeer Connectivity Framework in iOS 7. In this tutorial, we'll give an introduction of the framework and build a demo ...
Read more

Exploring the Multipeer Connectivity framework: Project Setup

Prior to Xcode 5, we first would have needed to link the project against the Multipeer Connectivity framework. In Xcode 5, however, this is no longer ...
Read more

Multipeer Connectivity Framework -

A new iOS app called FireChat is blowing up in the App Store. But it's not the app itself that's causing such a stir; it's the underlying networking ...
Read more

Multipeer-Connectivity-Framework – Tobias Gillen

Tobias Gillen auf Twitter; Tobias Gillen auf Facebook; Tobias Gillen auf Google+; Tobias Gillen auf Instagram; Tobias Gillen auf LinkedIn
Read more

ios - Using MultipeerConnectivity Framework with WiFly ...

Is it possible to use MultipeerConnectivity Framework to establish a local communication between an iOS device and a WiFly? In other words, is the ...
Read more