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 MCSession allocWithZone​(org.moe.natj.general.ptr.VoidPtr zone)
      • automaticallyNotifiesObserversForKey

        public static boolean automaticallyNotifiesObserversForKey​(@NotNull
                                                                   @NotNull java.lang.String key)
      • cancelPreviousPerformRequestsWithTarget

        public static void cancelPreviousPerformRequestsWithTarget​(@NotNull
                                                                   @NotNull java.lang.Object aTarget)
      • cancelPreviousPerformRequestsWithTargetSelectorObject

        public static void cancelPreviousPerformRequestsWithTargetSelectorObject​(@NotNull
                                                                                 @NotNull java.lang.Object aTarget,
                                                                                 @NotNull
                                                                                 @NotNull org.moe.natj.objc.SEL aSelector,
                                                                                 @Nullable
                                                                                 @Nullable java.lang.Object anArgument)
      • classFallbacksForKeyedArchiver

        @NotNull
        public static @NotNull NSArray<java.lang.String> classFallbacksForKeyedArchiver()
      • classForKeyedUnarchiver

        @NotNull
        public static @NotNull 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

        @NotNull
        public static @NotNull NSSet<java.lang.String> keyPathsForValuesAffectingValueForKey​(@NotNull
                                                                                             @NotNull java.lang.String key)
      • new_objc

        public static MCSession 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​(@NotNull
                                      @NotNull MCPeerID peerID)
        Cancel connection attempt with a peer.
      • connectPeerWithNearbyConnectionData

        public void connectPeerWithNearbyConnectionData​(@NotNull
                                                        @NotNull MCPeerID peerID,
                                                        @NotNull
                                                        @NotNull NSData data)
        Connect a peer to the session once connection data is received.
      • connectedPeers

        @NotNull
        public @NotNull NSArray<? extends MCPeerID> connectedPeers()
      • disconnect

        public void disconnect()
        Disconnect from the session.
      • encryptionPreference

        public long encryptionPreference()
      • initWithPeer

        public MCSession initWithPeer​(@NotNull
                                      @NotNull MCPeerID myPeerID)
        Create a session with an MCPeerID for the local peer.
      • initWithPeerSecurityIdentityEncryptionPreference

        public MCSession initWithPeerSecurityIdentityEncryptionPreference​(@NotNull
                                                                          @NotNull MCPeerID myPeerID,
                                                                          @Nullable
                                                                          @Nullable 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

        @NotNull
        public @NotNull MCPeerID myPeerID()
      • securityIdentity

        @Nullable
        public @Nullable NSArray<?> securityIdentity()
      • sendDataToPeersWithModeError

        public boolean sendDataToPeersWithModeError​(@NotNull
                                                    @NotNull NSData data,
                                                    @NotNull
                                                    @NotNull NSArray<? extends MCPeerID> peerIDs,
                                                    long mode,
                                                    @Nullable
                                                    @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Send a data message to a list of destination peers.
      • sendResourceAtURLWithNameToPeerWithCompletionHandler

        @Nullable
        public @Nullable NSProgress sendResourceAtURLWithNameToPeerWithCompletionHandler​(@NotNull
                                                                                         @NotNull NSURL resourceURL,
                                                                                         @NotNull
                                                                                         @NotNull java.lang.String resourceName,
                                                                                         @NotNull
                                                                                         @NotNull MCPeerID peerID,
                                                                                         @Nullable
                                                                                         @Nullable 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​(@Nullable
                                       @Nullable MCSessionDelegate value)
      • setDelegate

        public void setDelegate​(@Nullable
                                @Nullable MCSessionDelegate value)
      • startStreamWithNameToPeerError

        @Nullable
        public @Nullable NSOutputStream startStreamWithNameToPeerError​(@NotNull
                                                                       @NotNull java.lang.String streamName,
                                                                       @NotNull
                                                                       @NotNull MCPeerID peerID,
                                                                       @Nullable
                                                                       @Nullable org.moe.natj.general.ptr.Ptr<NSError> error)
        Start a named byte stream with the remote peer.
      • useStoredAccessor

        @Deprecated
        public static boolean useStoredAccessor()
        Deprecated.