Class 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.
    • Constructor Detail

      • MCSession

        protected MCSession​(org.moe.natj.general.Pointer peer)
    • Method Detail

      • accessInstanceVariablesDirectly

        public static boolean accessInstanceVariablesDirectly()
      • 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()
      • 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.
      • 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 ] ].
      • 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.
      • 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.