public class MCSession extends NSObject
A MCSession facilitates communication among all peers in a multipeer session.
To start a multipeer session with remote peers, a MCPeerID that represents the local peer needs to be supplied to the init method.
Once a peer is added to the session on both sides, the delegate callback -session:peer:didChangeState: will be called with MCSessionStateConnected state for the remote peer.
Data messages can be sent to a connected peer with the -sendData: toPeers:withMode:error: method.
The receiver of data messages will receive a delegate callback -session:didReceiveData:fromPeer:.
Resources referenced by NSURL (e.g. a file) can be sent to a connected peer with the -sendResourceAtURL:toPeer:withTimeout:completionHandler: method. The completionHandler will be called when the resource is fully received by the remote peer, or if an error occurred during transmission. The receiver of data messages will receive a delegate callbacks -session:didStartReceivingResourceWithName:fromPeer: withProgress: when it starts receiving the resource and -session: didFinishReceivingResourceWithName:fromPeer:atURL:withError: when the resource has been fully received.
A byte stream can be sent to a connected peer with the -startStreamWithName:toPeer:error: method. On success, an NSOutputStream object is returned, and can be used to send bytes to the remote peer once the stream is properly set up. The receiver of the byte stream will receive a delegate callback -session:didReceiveStream: withName:fromPeer:
Delegate calls occur on a private serial queue. If your app needs to perform an action on a particular run loop or operation queue, its delegate method should explicitly dispatch or schedule that work.
| Modifier and Type | Class and Description |
|---|---|
static interface |
MCSession.Block_nearbyConnectionDataForPeerWithCompletionHandler |
static interface |
MCSession.Block_sendResourceAtURLWithNameToPeerWithCompletionHandler |
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret| Modifier | Constructor and Description |
|---|---|
protected |
MCSession(org.moe.natj.general.Pointer peer) |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
accessInstanceVariablesDirectly() |
static MCSession |
alloc() |
static MCSession |
allocWithZone(org.moe.natj.general.ptr.VoidPtr zone) |
static boolean |
automaticallyNotifiesObserversForKey(java.lang.String key) |
void |
cancelConnectPeer(MCPeerID peerID)
Cancel connection attempt with a peer.
|
static void |
cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget) |
static void |
cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument) |
static NSArray<java.lang.String> |
classFallbacksForKeyedArchiver() |
static org.moe.natj.objc.Class |
classForKeyedUnarchiver() |
NSArray<? extends MCPeerID> |
connectedPeers() |
void |
connectPeerWithNearbyConnectionData(MCPeerID peerID,
NSData data)
Connect a peer to the session once connection data is received.
|
static java.lang.String |
debugDescription_static() |
MCSessionDelegate |
delegate() |
static java.lang.String |
description_static() |
void |
disconnect()
Disconnect from the session.
|
long |
encryptionPreference() |
static long |
hash_static() |
MCSession |
init() |
MCSession |
initWithPeer(MCPeerID myPeerID)
Create a session with an MCPeerID for the local peer.
|
MCSession |
initWithPeerSecurityIdentityEncryptionPreference(MCPeerID myPeerID,
NSArray<?> identity,
long encryptionPreference)
Create a session with a security configuration.
|
static NSObject.Function_instanceMethodForSelector_ret |
instanceMethodForSelector(org.moe.natj.objc.SEL aSelector) |
static NSMethodSignature |
instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
instancesRespondToSelector(org.moe.natj.objc.SEL aSelector) |
static boolean |
isSubclassOfClass(org.moe.natj.objc.Class aClass) |
static NSSet<java.lang.String> |
keyPathsForValuesAffectingValueForKey(java.lang.String key) |
MCPeerID |
myPeerID() |
void |
nearbyConnectionDataForPeerWithCompletionHandler(MCPeerID peerID,
MCSession.Block_nearbyConnectionDataForPeerWithCompletionHandler completionHandler)
Gets the connection data for a remote peer.
|
static MCSession |
new_objc() |
static boolean |
resolveClassMethod(org.moe.natj.objc.SEL sel) |
static boolean |
resolveInstanceMethod(org.moe.natj.objc.SEL sel) |
NSArray<?> |
securityIdentity() |
boolean |
sendDataToPeersWithModeError(NSData data,
NSArray<? extends MCPeerID> peerIDs,
long mode,
org.moe.natj.general.ptr.Ptr<NSError> error)
Send a data message to a list of destination peers.
|
NSProgress |
sendResourceAtURLWithNameToPeerWithCompletionHandler(NSURL resourceURL,
java.lang.String resourceName,
MCPeerID peerID,
MCSession.Block_sendResourceAtURLWithNameToPeerWithCompletionHandler completionHandler)
Send a resource referenced by an NSURL to a remote peer.
|
void |
setDelegate_unsafe(MCSessionDelegate value) |
void |
setDelegate(MCSessionDelegate value) |
static void |
setVersion_static(long aVersion) |
NSOutputStream |
startStreamWithNameToPeerError(java.lang.String streamName,
MCPeerID peerID,
org.moe.natj.general.ptr.Ptr<NSError> error)
Start a named byte stream with the remote peer.
|
static org.moe.natj.objc.Class |
superclass_static() |
static long |
version_static() |
accessibilityActivate, accessibilityActivationPoint, accessibilityAssistiveTechnologyFocusedIdentifiers, accessibilityAttributedHint, accessibilityAttributedLabel, accessibilityAttributedUserInputLabels, accessibilityAttributedValue, accessibilityContainerType, accessibilityCustomActions, accessibilityCustomRotors, accessibilityDecrement, accessibilityDragSourceDescriptors, accessibilityDropPointDescriptors, accessibilityElementAtIndex, accessibilityElementCount, accessibilityElementDidBecomeFocused, accessibilityElementDidLoseFocus, accessibilityElementIsFocused, accessibilityElements, accessibilityElementsHidden, accessibilityFrame, accessibilityHint, accessibilityIncrement, accessibilityLabel, accessibilityLanguage, accessibilityNavigationStyle, accessibilityPath, accessibilityPerformEscape, accessibilityPerformMagicTap, accessibilityRespondsToUserInteraction, accessibilityScroll, accessibilityTextualContext, accessibilityTraits, accessibilityUserInputLabels, accessibilityValue, accessibilityViewIsModal, addObserverForKeyPathOptionsContext, attemptRecoveryFromErrorOptionIndex, attemptRecoveryFromErrorOptionIndexDelegateDidRecoverSelectorContextInfo, autoContentAccessingProxy, awakeAfterUsingCoder, awakeFromNib, class_objc, classForCoder, classForKeyedArchiver, copy, dealloc, debugDescription, description, dictionaryWithValuesForKeys, didChangeValueForKey, didChangeValueForKeyWithSetMutationUsingObjects, didChangeValuesAtIndexesForKey, doesNotRecognizeSelector, fileManagerShouldProceedAfterError, fileManagerWillProcessPath, finalize_objc, forwardingTargetForSelector, forwardInvocation, hash, indexOfAccessibilityElement, isAccessibilityElement, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableArrayValueForKey, mutableArrayValueForKeyPath, mutableCopy, mutableOrderedSetValueForKey, mutableOrderedSetValueForKeyPath, mutableSetValueForKey, mutableSetValueForKeyPath, observationInfo, observeValueForKeyPathOfObjectChangeContext, performSelector, performSelectorInBackgroundWithObject, performSelectorOnMainThreadWithObjectWaitUntilDone, performSelectorOnMainThreadWithObjectWaitUntilDoneModes, performSelectorOnThreadWithObjectWaitUntilDone, performSelectorOnThreadWithObjectWaitUntilDoneModes, performSelectorWithObject, performSelectorWithObjectAfterDelay, performSelectorWithObjectAfterDelayInModes, performSelectorWithObjectWithObject, prepareForInterfaceBuilder, provideImageDataBytesPerRowOrigin_Size_UserInfo, removeObserverForKeyPath, removeObserverForKeyPathContext, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, self, setAccessibilityActivationPoint, setAccessibilityAttributedHint, setAccessibilityAttributedLabel, setAccessibilityAttributedUserInputLabels, setAccessibilityAttributedValue, setAccessibilityContainerType, setAccessibilityCustomActions, setAccessibilityCustomRotors, setAccessibilityDragSourceDescriptors, setAccessibilityDropPointDescriptors, setAccessibilityElements, setAccessibilityElementsHidden, setAccessibilityFrame, setAccessibilityHint, setAccessibilityLabel, setAccessibilityLanguage, setAccessibilityNavigationStyle, setAccessibilityPath, setAccessibilityRespondsToUserInteraction, setAccessibilityTextualContext, setAccessibilityTraits, setAccessibilityUserInputLabels, setAccessibilityValue, setAccessibilityViewIsModal, setIsAccessibilityElement, setNilValueForKey, setObservationInfo, setShouldGroupAccessibilityChildren, setValueForKey, setValueForKeyPath, setValueForUndefinedKey, setValuesForKeysWithDictionary, shouldGroupAccessibilityChildren, superclass, validateValueForKeyError, validateValueForKeyPathError, valueForKey, valueForKeyPath, valueForUndefinedKey, willChangeValueForKey, willChangeValueForKeyWithSetMutationUsingObjects, willChangeValuesAtIndexesForKeypublic static boolean accessInstanceVariablesDirectly()
public static MCSession alloc()
public static MCSession allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget,
org.moe.natj.objc.SEL aSelector,
java.lang.Object anArgument)
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
public static java.lang.String debugDescription_static()
public static java.lang.String description_static()
public static long hash_static()
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
public static MCSession new_objc()
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
public static void setVersion_static(long aVersion)
public static org.moe.natj.objc.Class superclass_static()
public static long version_static()
public void cancelConnectPeer(MCPeerID peerID)
public void connectPeerWithNearbyConnectionData(MCPeerID peerID, NSData data)
public MCSessionDelegate delegate()
public void disconnect()
public long encryptionPreference()
public MCSession initWithPeer(MCPeerID myPeerID)
public MCSession initWithPeerSecurityIdentityEncryptionPreference(MCPeerID myPeerID, NSArray<?> identity, long encryptionPreference)
public MCPeerID myPeerID()
public void nearbyConnectionDataForPeerWithCompletionHandler(MCPeerID peerID, MCSession.Block_nearbyConnectionDataForPeerWithCompletionHandler completionHandler)
public NSArray<?> securityIdentity()
public boolean sendDataToPeersWithModeError(NSData data, NSArray<? extends MCPeerID> peerIDs, long mode, org.moe.natj.general.ptr.Ptr<NSError> error)
public NSProgress sendResourceAtURLWithNameToPeerWithCompletionHandler(NSURL resourceURL, java.lang.String resourceName, MCPeerID peerID, MCSession.Block_sendResourceAtURLWithNameToPeerWithCompletionHandler completionHandler)
The primary mechanism for observing progress of the send should be to create an NSProgress using +progressWithTotalUnitCount, -becomeCurrentWithPendingUnitCount:, invoking this method, then calling -resignCurrent. This is described in the NSProgress documentation. Alternatively, if you wish to observe the progress directly instead of incorporating it into a larger operation, you may observe the NSProgress returned from this method.
public void setDelegate_unsafe(MCSessionDelegate value)
public void setDelegate(MCSessionDelegate value)
public NSOutputStream startStreamWithNameToPeerError(java.lang.String streamName, MCPeerID peerID, org.moe.natj.general.ptr.Ptr<NSError> error)