Package apple.multipeerconnectivity
Class MCSession
- java.lang.Object
-
- org.moe.natj.general.NativeObject
-
- org.moe.natj.objc.ObjCObject
-
- apple.NSObject
-
- apple.multipeerconnectivity.MCSession
-
- All Implemented Interfaces:
NSObject
public class MCSession extends NSObject
MCSession 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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMCSession.Block_nearbyConnectionDataForPeerWithCompletionHandlerstatic interfaceMCSession.Block_sendResourceAtURLWithNameToPeerWithCompletionHandler-
Nested classes/interfaces inherited from class apple.NSObject
NSObject.Function_instanceMethodForSelector_ret, NSObject.Function_methodForSelector_ret
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedMCSession(org.moe.natj.general.Pointer peer)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleanaccessInstanceVariablesDirectly()static MCSessionalloc()static java.lang.ObjectallocWithZone(org.moe.natj.general.ptr.VoidPtr zone)static booleanautomaticallyNotifiesObserversForKey(java.lang.String key)voidcancelConnectPeer(MCPeerID peerID)Cancel connection attempt with a peer.static voidcancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)static voidcancelPreviousPerformRequestsWithTargetSelectorObject(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.ClassclassForKeyedUnarchiver()NSArray<? extends MCPeerID>connectedPeers()voidconnectPeerWithNearbyConnectionData(MCPeerID peerID, NSData data)Connect a peer to the session once connection data is received.static java.lang.StringdebugDescription_static()MCSessionDelegatedelegate()static java.lang.Stringdescription_static()voiddisconnect()Disconnect from the session.longencryptionPreference()static longhash_static()MCSessioninit()MCSessioninitWithPeer(MCPeerID myPeerID)Create a session with an MCPeerID for the local peer.MCSessioninitWithPeerSecurityIdentityEncryptionPreference(MCPeerID myPeerID, NSArray<?> identity, long encryptionPreference)Create a session with a security configuration.static NSObject.Function_instanceMethodForSelector_retinstanceMethodForSelector(org.moe.natj.objc.SEL aSelector)static NSMethodSignatureinstanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)static booleaninstancesRespondToSelector(org.moe.natj.objc.SEL aSelector)static booleanisSubclassOfClass(org.moe.natj.objc.Class aClass)static NSSet<java.lang.String>keyPathsForValuesAffectingValueForKey(java.lang.String key)MCPeerIDmyPeerID()voidnearbyConnectionDataForPeerWithCompletionHandler(MCPeerID peerID, MCSession.Block_nearbyConnectionDataForPeerWithCompletionHandler completionHandler)Gets the connection data for a remote peer.static java.lang.Objectnew_objc()static booleanresolveClassMethod(org.moe.natj.objc.SEL sel)static booleanresolveInstanceMethod(org.moe.natj.objc.SEL sel)NSArray<?>securityIdentity()booleansendDataToPeersWithModeError(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.NSProgresssendResourceAtURLWithNameToPeerWithCompletionHandler(NSURL resourceURL, java.lang.String resourceName, MCPeerID peerID, MCSession.Block_sendResourceAtURLWithNameToPeerWithCompletionHandler completionHandler)Send a resource referenced by an NSURL to a remote peer.voidsetDelegate(MCSessionDelegate value)voidsetDelegate_unsafe(MCSessionDelegate value)static voidsetVersion_static(long aVersion)NSOutputStreamstartStreamWithNameToPeerError(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.Classsuperclass_static()static longversion_static()-
Methods inherited from class apple.NSObject
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, willChangeValuesAtIndexesForKey
-
-
-
-
Method Detail
-
accessInstanceVariablesDirectly
public static boolean accessInstanceVariablesDirectly()
-
alloc
public static MCSession alloc()
-
allocWithZone
public static java.lang.Object allocWithZone(org.moe.natj.general.ptr.VoidPtr zone)
-
automaticallyNotifiesObserversForKey
public static boolean automaticallyNotifiesObserversForKey(java.lang.String key)
-
cancelPreviousPerformRequestsWithTarget
public static void cancelPreviousPerformRequestsWithTarget(java.lang.Object aTarget)
-
cancelPreviousPerformRequestsWithTargetSelectorObject
public static void cancelPreviousPerformRequestsWithTargetSelectorObject(java.lang.Object aTarget, org.moe.natj.objc.SEL aSelector, java.lang.Object anArgument)
-
classFallbacksForKeyedArchiver
public static NSArray<java.lang.String> classFallbacksForKeyedArchiver()
-
classForKeyedUnarchiver
public static org.moe.natj.objc.Class classForKeyedUnarchiver()
-
debugDescription_static
public static java.lang.String debugDescription_static()
-
description_static
public static java.lang.String description_static()
-
hash_static
public static long hash_static()
-
instanceMethodForSelector
public static NSObject.Function_instanceMethodForSelector_ret instanceMethodForSelector(org.moe.natj.objc.SEL aSelector)
-
instanceMethodSignatureForSelector
public static NSMethodSignature instanceMethodSignatureForSelector(org.moe.natj.objc.SEL aSelector)
-
instancesRespondToSelector
public static boolean instancesRespondToSelector(org.moe.natj.objc.SEL aSelector)
-
isSubclassOfClass
public static boolean isSubclassOfClass(org.moe.natj.objc.Class aClass)
-
keyPathsForValuesAffectingValueForKey
public static NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey(java.lang.String key)
-
new_objc
public static java.lang.Object new_objc()
-
resolveClassMethod
public static boolean resolveClassMethod(org.moe.natj.objc.SEL sel)
-
resolveInstanceMethod
public static boolean resolveInstanceMethod(org.moe.natj.objc.SEL sel)
-
setVersion_static
public static void setVersion_static(long aVersion)
-
superclass_static
public static org.moe.natj.objc.Class superclass_static()
-
version_static
public static long version_static()
-
cancelConnectPeer
public void cancelConnectPeer(MCPeerID peerID)
Cancel connection attempt with a peer.
-
connectPeerWithNearbyConnectionData
public void connectPeerWithNearbyConnectionData(MCPeerID peerID, NSData data)
Connect a peer to the session once connection data is received.
-
delegate
public MCSessionDelegate delegate()
-
disconnect
public void disconnect()
Disconnect from the session.
-
encryptionPreference
public long encryptionPreference()
-
initWithPeer
public MCSession initWithPeer(MCPeerID myPeerID)
Create a session with an MCPeerID for the local peer.
-
initWithPeerSecurityIdentityEncryptionPreference
public MCSession initWithPeerSecurityIdentityEncryptionPreference(MCPeerID myPeerID, NSArray<?> identity, long encryptionPreference)
Create a session with a security configuration. The securityIdentity argument is an array of [ SecIdentityRef, [ zero or more additional certs ] ].
-
myPeerID
public MCPeerID myPeerID()
-
nearbyConnectionDataForPeerWithCompletionHandler
public void nearbyConnectionDataForPeerWithCompletionHandler(MCPeerID peerID, MCSession.Block_nearbyConnectionDataForPeerWithCompletionHandler completionHandler)
Gets the connection data for a remote peer.
-
securityIdentity
public NSArray<?> securityIdentity()
-
sendDataToPeersWithModeError
public 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.
-
sendResourceAtURLWithNameToPeerWithCompletionHandler
public 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. The resource can be a file or an HTTP document. The completionHandler is called when the resource is received by the remote peer or if an error occurred. The remote peer will get a -session:didStartReceivingResourceWithName: fromPeer:withProgress callback when it starts receiving the resource and a -session:didFinishReceivingResourceWithName:fromPeer:atURL:withError: when the resource has been fully received. 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.
-
setDelegate_unsafe
public void setDelegate_unsafe(MCSessionDelegate value)
-
setDelegate
public void setDelegate(MCSessionDelegate value)
-
startStreamWithNameToPeerError
public 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.
-
-