I'am working on Multipeer connectivity in ios 7 and its working nice.But what i need is,when i press a search button it need to display all nearby sessions(not nearby devices).Is there any possible solution for this. Please Help!!!
Multipeer Connectivity :List all nearby sessions
842 views Asked by DHEERAJ AtThere are 2 answers
On
You can not advertise an MCSession, instead use multiple MCNearbyServiceBrowser objects and MCNearbyServiceAdvertiser objects to browse and advertise multiple service types.
When you initilize an MCNearbyServiceAdvertiser using initWithPeer:discoveryInfo:serviceType:
put your service name(service type) in discover info so that when you peer get found by an MCNearbyServiceBrowser (browsing for same service type) inside MCNearbyServiceBrowserDelegate's browser:foundPeer:withDiscoveryInfo: you can determine the service type and display in UI.
In this way same peer will appear multiple times with different service types. You can choose desired service type to proceed with.
I adivse you to use a separate MCSession for each service type.
For doing this you need to maintain all the browsers and advertisers objects carefully.
Hope it helps.
You don't say why you want to pass
MCSessionobjects between peers, but once you have two connected peers, you can pass any object that conforms to theNSCodingprotocol between the peers using one of the MCSession data sending methods such asHowever MCSession doesn't conform to NSCoding, so you'd be better off sending metadata from the MCSession between peers. So if Peer A and Peer B were connected, and Peer A wanted to know which other peers Peer B was connected to, Peer B could send an array of
NSStringobjects listing thedisplayNameof each peer.But even if you did that, if Peer A hasn't discovered (or been discovered by) Peer B's connected peers, you're not going to be able to communicate with them anyway. The fact that you're looking for ways to send
MCSessionobjects between peers means there's probably a better way to tackle what you're trying to achieve.tl;dr
MCSessionhandles connections between peers. The peers would need to be connected to share their MCSession objects in the first place.