Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MultiPeer Connectivity Framework

4,649 views

Published on

MultiPeer Connectivity Framework par Nicolas Zinovieff. Technologie Apple permettant de faire de la discussion peer-to-peer entre devices.

Demo Github Project : https://github.com/krugazor/MCChat

Published in: Software
  • Be the first to comment

  • Be the first to like this

MultiPeer Connectivity Framework

  1. 1. MULTIPEER CONNECTIVITY YO, WANNA TALK? 1
  2. 2. MULTIPEER CONNECTIVITY PLAN ▸ Pourquoi? ▸ Comment? ▸ Quoi? 2
  3. 3. MULTIPEER CONNECTIVITY POURQUOI? ▸ Mobilité accrue ▸ Hétérogénéité des accès plutôt que des méthodes ▸ Zéro configuration 3
  4. 4. MULTIPEER CONNECTIVITY BT Advertisement / Discovery Data Exchange Get Ad-hoc WiFi Settings & connect Setup Ad-hoc WiFi Network Create Session Join Session Session Data Exchange COMMENT? ▸ “Discovery” Bluetooth ▸ Débit et stabilité WiFi ▸ Zéroconf / Bonjour 4
  5. 5. MULTIPEER CONNECTIVITY QUOI? ▸ Réseau ▸ MCAdvertiserAssistant ▸ MCNearbyServiceAdvertiser / MCNearbyServiceBrowser ▸ Peers ▸ MCSession ▸ MCPeerID 5
  6. 6. MULTIPEER CONNECTIVITY CAVEATS ▸ Limitations réseau (évidemment) : portée, débit, etc ▸ Une session contient au plus 8 participants ▸ Peu de fonctions avancées ▸ Mac - iPhone - iPad - Watch - TV 6
  7. 7. MULTIPEER CONNECTIVITY CRÉER / REJOINDRE UNE SESSION ▸ Service Type (NSString) ▸ Peer Display Name (NSString) ▸ MCNearbyServiceAdvertiser -> MCSession ▸ MCNearbyServiceBrowser -> MCSession 7
  8. 8. static NSString * const AppServiceType = @“chat-service"; NSString *dName = [[UIDevice currentDevice] name]; MCPeerID *localPeerID = [[MCPeerID alloc] initWithDisplayName:dName]; Service Type & Local Peer MULTIPEER CONNECTIVITY 8
  9. 9. MCNearbyServiceAdvertiser *advertiser = [[MCNearbyServiceAdvertiser alloc] initWithPeer:localPeerID discoveryInfo:nil serviceType:AppServiceType];
 advertiser.delegate = self; [advertiser startAdvertisingPeer]; Advertising MULTIPEER CONNECTIVITY 9
  10. 10. - (void) advertiser:(MCNearbyServiceAdvertiser *)advertiser didReceiveInvitationFromPeer:(MCPeerID *)peerID withContext:(NSData *)context invitationHandler: (void(^)(BOOL accept, MCSession *session))invitationHandler { if(self.session == nil) {
 self.session = [[MCSession alloc] initWithPeer:localPeerID securityIdentity:nil encryptionPreference:MCEncryptionNone]; } invitationHandler(YES, self.session); } Advertising Attack of The Clones MULTIPEER CONNECTIVITY 10
  11. 11. MCNearbyServiceBrowser *browser = [[MCNearbyServiceBrowser alloc] initWithPeer:localPeerID serviceType:AppServiceType]; browser.delegate = self; Discovery MULTIPEER CONNECTIVITY 11
  12. 12. // optional GUI MCBrowserViewController *browserViewController = [[MCBrowserViewController alloc] initWithBrowser:browser session:session]; browserViewController.delegate = self; [self presentViewController:browserViewController animated:YES completion: ^{ [browser startBrowsingForPeers]; }]; Discovery Harder MULTIPEER CONNECTIVITY 12
  13. 13. MULTIPEER CONNECTIVITY MCSESSION IS LIVE! ▸ Message == NSData ▸ Blobs ▸ NSSecureCoding Objects ▸ Contenu d’une ressource par une NSURL (file ou http) ▸ NSInputStream/NSOutputStream (ouep) 13
  14. 14. MULTIPEER CONNECTIVITY DEMO 14
  15. 15. MULTIPEER CONNECTIVITY QUESTIONS? 15

×