MCSession MCSession Class
Represents a persistent connection between multiple devices.
[Foundation.Register("MCSession", true)] [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.TvOS, 10, 0, ObjCRuntime.PlatformArchitecture.All, null)] [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.iOS, 7, 0, ObjCRuntime.PlatformArchitecture.All, null)] [ObjCRuntime.Introduced(ObjCRuntime.PlatformName.MacOSX, 10, 10, ObjCRuntime.PlatformArchitecture.Arch64, null)] public class MCSession : Foundation.NSObject
type MCSession = class inherit NSObject
Multipeer Connectivity has two phases: discovery and the session. The role of the discovery phase is to associate an MCSession object on each device with an MCSession object on the peer devices. In the session phase, the MCSession object is the channel through which devices communicate and its lifecycle events are associated with connections, disconnections, transmissions, and receptions.
The MCSession is instantiated by the application developer. During the discovery phase, there are two roles: advertisers that broadcast their willingness to connect to a certain protocol and browsers that discover these advertisers and invite them to sessions.
Advertising is managed by either the stock MCAdvertiserAssistant or custom controller that uses a MCNearbyServiceAdvertiser. Similarly, browsing is managed by a
The following image shows the sequence of functions with programmatic advertising and browsing:
|Create a new MCNearbyServiceAdvertiserDelegate and assign it to the Delegate property.||Create a new MCNearbyServiceBrowserDelegate and assign it to Delegate property.||Discovery and connection is taken care of by the delegate objects for the MCNearbyServiceAdvertiser and MCNearbyServiceBrowser.|
|The advertiser may instantiate a new MCSession now or wait until it receives an invitation.||Instantiate a new MCSession.||The browser should maintain a reference to a single MCSession object no matter how many peers ultimately connect.|
|StartAdvertisingPeer()||StartBrowsingForPeers()||Advertiser and browser must use identical |
|The system will call FoundPeer(MCNearbyServiceBrowser, MCPeerID, NSDictionary), passing in a reference to the MCNearbyServiceBrowser. The application developer calls InvitePeer(MCPeerID, MCSession, NSData, Double), passing in a reference to the previously-created MCSession.||The callback is likely to occur on a background thread. If the application developer wishes to update the display, they must use InvokeOnMainThread(Selector, NSObject).|
|The system will call DidReceiveInvitationFromPeer(MCNearbyServiceAdvertiser, MCPeerID, NSData, MCNearbyServiceAdvertiserInvitationHandler). To connect the devices, the application developer must invoke the passed-in ||The callback is likely to occur on a background thread. If the application developer wishes to update the display, they must use InvokeOnMainThread(Selector, NSObject).|
|Once the devices are connected, the MCSession objects can be used to transmit messages and data between devices.|
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.
Constructs a session with the specified identity for the local peer.
|MCSession(MCPeerID, SecIdentity, MCEncryptionPreference) MCSession(MCPeerID, SecIdentity, MCEncryptionPreference)||
Constructor that allows the application developer to specify security constraints.
|MCSession(MCPeerID, SecIdentity, SecCertificate, MCEncryptionPreference) MCSession(MCPeerID, SecIdentity, SecCertificate, MCEncryptionPreference)||
Constructor that allows the application developer to specify security constraints and certificates.
Constructor to call on derived classes to skip initialization and merely allocate the object.
|Class Class||Inherited from NSObject|
The handle for this class.
An array of the currently connected devices.
A developer-meaningful description of this object.(Inherited from NSObject)
An instance of the MultipeerConnectivity.IMCSessionDelegate model class which acts as the class delegate.
Description of the object, the Objective-C version of ToString.(Inherited from NSObject)
What type, if any, encryption s preferred.
Handle (pointer) to the unmanaged object representation.(Inherited from NSObject)
|IsDirectBinding IsDirectBinding||Inherited from NSObject|
|IsProxy IsProxy||Inherited from NSObject|
Represents the value associated with the constant kMCSessionMaximumNumberOfPeers
Represents the value associated with the constant kMCSessionMinimumNumberOfPeers
The peer ID associated with this device.
Returns the current Objective-C retain count for the object.(Inherited from NSObject)
The security identity of this peer.
|Self Self||Inherited from NSObject|
|Superclass Superclass||Inherited from NSObject|
Handle used to represent the methods in the base class for this NSObject.(Inherited from NSObject)
An object that can respond to the delegate protocol for this type
|Zone Zone||Inherited from NSObject|
Gets the array of UIAccessibilityCustomRotor objects appropriate for
|SetAccessibilityCustomRotors(NSObject, UIAccessibilityCustomRotor) SetAccessibilityCustomRotors(NSObject, UIAccessibilityCustomRotor)||
Sets the array of UIAccessibilityCustomRotor objects appropriate for
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.