Beispiel #1
0
 /// <summary>
 /// Loads a specific match.
 /// </summary>
 /// <param name="matchID">Match I.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public static void LoadMatchWithID(string matchID, Action <GKTurnBasedMatch, NSError> completionHandler)
 {
     C.GKTurnBasedMatch_loadMatchWithID(
         matchID,
         InternalSingleMatchCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #2
0
        private static void InternalMultipleMatchesCallback(IntPtr matches, IntPtr error, IntPtr secondaryCallback)
        {
            if (PInvokeUtil.IsNull(secondaryCallback))
            {
                return;
            }

            GKTurnBasedMatch[] gkMatches = null;

            if (PInvokeUtil.IsNotNull(matches))
            {
                // Creating a one-time usage NSArray binder, no need to use the factory.
                using (var nsArray = new NSArray <GKTurnBasedMatch>(matches))
                {
                    gkMatches = nsArray.ToArray(ptr => InteropObjectFactory <GKTurnBasedMatch> .FromPointer(ptr, p => new GKTurnBasedMatch(p)));
                }
            }

            // A new NSError object is always created on native side, so no need
            // to check the binder pool for reusing an existing one.
            NSError nsError = PInvokeUtil.IsNotNull(error) ? new NSError(error) : null;

            // Invoke consumer callback.
            PInvokeCallbackUtil.PerformInternalCallback(
                "GKTurnBasedMatch#InternalMultipleMatchesCallback",
                PInvokeCallbackUtil.Type.Temporary,
                gkMatches, nsError, secondaryCallback);
        }
Beispiel #3
0
 /// <summary>
 /// Loads the game-specific data associated with a match, including all exchanges.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void LoadMatchData(Action <byte[], NSError> completionHandler)
 {
     C.GKTurnBasedMatch_loadMatchData(
         SelfPtr(),
         InternalLoadMatchDataCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #4
0
 /// <summary>
 /// Loads information from Game Center about a list of players.
 /// </summary>
 /// <param name="identifiers">Identifiers.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public static void LoadPlayersForIdentifiers(string[] identifiers, Action <GKPlayer[], NSError> completionHandler)
 {
     C.GKPlayer_loadPlayersForIdentifiers(
         identifiers, identifiers.Length,
         InternalLoadPlayersForIdentifiersCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #5
0
 /// <summary>
 /// Enables the matchmaking process to find nearby players through Bluetooth or WiFi (same subnet only).
 /// </summary>
 /// <param name="reachableHandler">Reachable handler.</param>
 public void StartBrowsingForNearbyPlayers(Action <GKPlayer, bool> reachableHandler)
 {
     C.GKMatchmaker_startBrowsingForNearbyPlayers(
         SelfPtr(),
         PlayerBoolCallback,
         PInvokeCallbackUtil.ToIntPtr(reachableHandler));
 }
Beispiel #6
0
 /// <summary>
 /// Initiates a search for activity in all player groups.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void QueryActivity(Action <int, NSError> completionHandler)
 {
     C.GKMatchmaker_queryActivity(
         SelfPtr(),
         IntErrorCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #7
0
 /// <summary>
 /// Programmatically removes a match from Game Center.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void Remove(Action <NSError> completionHandler)
 {
     C.GKTurnBasedMatch_remove(
         SelfPtr(),
         InternalErrorOnlyCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #8
0
        private static void InternalLoadMatchDataCallback(IntPtr matchData, IntPtr error, IntPtr secondaryCallback)
        {
            if (PInvokeUtil.IsNull(secondaryCallback))
            {
                return;
            }

            byte[] data = null;

            if (PInvokeUtil.IsNotNull(matchData))
            {
                // Creating a one-time usage NSData binder, so no need to use the factory.
                using (var nsData = new NSData(matchData))
                {
                    var length = nsData.Length;
                    if (length > 0)
                    {
                        data = nsData.GetBytes(length);
                    }
                }
            }

            // A new NSError object is always created on native side, so no need
            // to check the binder pool for reusing an existing one.
            NSError nsError = PInvokeUtil.IsNotNull(error) ? new NSError(error) : null;

            PInvokeCallbackUtil.PerformInternalCallback(
                "GKTurnBasedMatch#InternalLoadMatchDataCallback",
                PInvokeCallbackUtil.Type.Temporary,
                data, nsError, secondaryCallback);
        }
Beispiel #9
0
        /// <summary>
        /// Returns a Boolean value that indicates whether the enumeration of
        /// all contacts matching a contact fetch request executed successfully.
        /// </summary>
        /// <returns><c>true</c>, if contacts with fetch request was enumerated, <c>false</c> otherwise.</returns>
        /// <param name="fetchRequest">Fetch request.</param>
        /// <param name="error">Error.</param>
        /// <param name="block">Block.</param>
        public bool EnumerateContactsWithFetchRequest(CNContactFetchRequest fetchRequest, out NSError error, EnumerateContactsWithFetchRequestBlock block)
        {
            Util.NullArgumentTest(fetchRequest);
            Util.NullArgumentTest(block);

            IntPtr errorPtr = new IntPtr();
            bool   success  = C.CNContactStore_enumerateContactsWithFetchRequest(
                SelfPtr(),
                fetchRequest.ToPointer(),
                ref errorPtr,
                InternalEnumerateContactsBlock,
                PInvokeCallbackUtil.ToIntPtr((CNContact contact) =>
            {
                bool shouldStop;
                block(contact, out shouldStop);
                return(shouldStop);
            }));

            error = null;
            if (PInvokeUtil.IsNotNull(errorPtr))
            {
                error = new NSError(errorPtr);
                CFFunctions.CFRelease(errorPtr);     // balance out ref count of a pointer returned directly from native side.
            }

            return(success);
        }
Beispiel #10
0
 /// <summary>
 /// Returns an array of players the local player recently played with.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void LoadRecentPlayers(Action <GKPlayer[], NSError> completionHandler)
 {
     C.GKLocalPlayer_loadRecentPlayers(
         SelfPtr(),
         InternalLoadRecentPlayersCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #11
0
 /// <summary>
 /// Determines the best player in the game to act as the server for a client-server match.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void ChooseBestHostingPlayer(Action <GKPlayer> completionHandler)
 {
     C.GKMatch_chooseBestHostingPlayer(
         SelfPtr(),
         InternalChooseBestHostingPlayerCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #12
0
        internal static void InternalSaveGameData(iOSGKSavedGame savedGame, byte[] data, Action <iOSGKSavedGame, string> callback)
        {
            Util.NullArgumentTest(savedGame);
            Util.NullArgumentTest(data);
            Util.NullArgumentTest(callback);

            iOSSavedGameNative._SaveGameData(
                savedGame.ToPointer(),
                data,
                data.Length,
                InternalSaveGameDataCallback,
                PInvokeCallbackUtil.ToIntPtr <SaveGameDataResponse>(
                    response =>
            {
                string error = response.GetError();
                if (string.IsNullOrEmpty(error))
                {
                    callback(response.GetSavedGame(), error);
                }
                else
                {
                    callback(null, error);
                }
            },
                    SaveGameDataResponse.FromPointer
                    )
                );
        }
Beispiel #13
0
 /// <summary>
 /// Create a new turn-based match with the same participants as an existing match.
 /// </summary>
 /// <param name="completionHandler">Completion handler.</param>
 public void Rematch(Action <GKTurnBasedMatch, NSError> completionHandler)
 {
     C.GKTurnBasedMatch_rematch(
         SelfPtr(),
         InternalSingleMatchCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #14
0
 private static void InternalGetNotificationResponseCallback(IntPtr response, IntPtr callbackPtr)
 {
     PInvokeCallbackUtil.PerformInternalCallback(
         "iOSNotificationListener#InternalGetNotificationResponseCallback",
         PInvokeCallbackUtil.Type.Temporary,
         response,
         callbackPtr);
 }
Beispiel #15
0
 /// <summary>
 /// Resigns the player from the match when that player is not the current player. This action does not end the match.
 /// </summary>
 /// <param name="matchOutcome">Match outcome.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void ParticipantQuitOutOfTurn(GKTurnBasedParticipant.GKTurnBasedMatchOutcome matchOutcome, Action <NSError> completionHandler)
 {
     C.GKTurnBasedMatch_participantQuitOutOfTurn(
         SelfPtr(),
         ref matchOutcome,
         InternalErrorOnlyCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #16
0
 private static void InternalDeleteSavedGameCallback(IntPtr response, IntPtr callbackPtr)
 {
     PInvokeCallbackUtil.PerformInternalCallback(
         "iOSSavedGameClient#DeleteSavedGameCallback",
         PInvokeCallbackUtil.Type.Temporary,
         response,
         callbackPtr);
 }
 private static void InternalGetPendingNotificationRequestsCallback(IntPtr response, IntPtr callbackPtr)
 {
     PInvokeCallbackUtil.PerformInternalCallback(
         "iOSNotificationClient#GetPendingNotificationRequestsCallback",
         PInvokeCallbackUtil.Type.Temporary,
         response,
         callbackPtr);
 }
Beispiel #18
0
 /// <summary>
 /// Requests access to the user's contacts.
 /// </summary>
 /// <param name="entityType">Entity type.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void RequestAccessForEntityType(CNEntityType entityType, Action <bool, NSError> completionHandler)
 {
     C.CNContactStore_requestAccessForEntityType(
         SelfPtr(),
         entityType,
         InternalRequestAccessForEntityTypeCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #19
0
 private static void InternalResolveConflictingSavedGamesCallback(IntPtr response, IntPtr callbackPtr)
 {
     PInvokeCallbackUtil.PerformInternalCallback(
         "iOSSavedGameClient#ResolveConflictingSavedGamesCallback",
         PInvokeCallbackUtil.Type.Temporary,
         response,
         callbackPtr);
 }
Beispiel #20
0
 /// <summary>
 /// Loads a photo of this player from Game Center.
 /// </summary>
 /// <param name="photoSize">Photo size.</param>
 /// <param name="callback">Callback.</param>
 public void LoadPhotoForSize(GKPhotoSize photoSize, Action <UIImage, NSError> completionHandler)
 {
     C.GKPlayer_loadPhotoForSize(
         SelfPtr(),
         photoSize,
         InternalLoadPhotoForSizeCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #21
0
 /// <summary>
 /// Queries Game Center for the activity in a player group.
 /// </summary>
 /// <param name="playerGroup">Player group.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void QueryPlayerGroupActivity(uint playerGroup, Action <int, NSError> completionHandler)
 {
     C.GKMatchmaker_queryPlayerGroupActivity(
         SelfPtr(),
         playerGroup,
         IntErrorCallback,
         PInvokeCallbackUtil.ToIntPtr(completionHandler));
 }
Beispiel #22
0
        /// <summary>
        /// Programmatically searches for a new match to join.
        /// </summary>
        /// <param name="request">Request.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public static void FindMatchForRequest(GKMatchRequest request, Action <GKTurnBasedMatch, NSError> completionHandler)
        {
            Util.NullArgumentTest(request);

            C.GKTurnBasedMatch_findMatchForRequest(
                request.ToPointer(),
                InternalSingleMatchCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
 /// <summary>
 /// Dismisses the view controller that was presented modally by the view controller.
 /// </summary>
 /// <param name="animated">If set to <c>true</c> animated.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void DismissViewController(bool animated, Action completionHandler)
 {
     C.UIViewController_dismissViewController(
         SelfPtr(),
         animated,
         completionHandler == null ? (C.DismissViewControllerCallback)null : InternalDismissViewControllerCallback,
         completionHandler == null ? IntPtr.Zero : PInvokeCallbackUtil.ToIntPtr(completionHandler)
         );
 }
Beispiel #24
0
        /// <summary>
        /// Adds the specified image to the user’s Camera Roll album.
        /// </summary>
        /// <param name="image">Image.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public static void UIImageWriteToSavedPhotosAlbum(UIImage image, Action <UIImage, NSError> completionHandler)
        {
            Util.NullArgumentTest(image);

            C.UIKit_UIImageWriteToSavedPhotosAlbum(
                image.ToPointer(),
                WriteToSavedPhotosAlbumCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
 /// <summary>
 /// Presents a view controller modally.
 /// </summary>
 /// <param name="viewController">View controller.</param>
 /// <param name="animated">If set to <c>true</c> animated.</param>
 /// <param name="completionHandler">Completion handler.</param>
 public void PresentViewController(UIViewController viewController, bool animated, Action completionHandler)
 {
     C.UIViewController_presentViewController(
         SelfPtr(),
         viewController.ToPointer(),
         animated,
         completionHandler == null ? (C.PresentViewControllerCallback)null : InternalPresentViewControllerCallback,
         completionHandler == null ? IntPtr.Zero : PInvokeCallbackUtil.ToIntPtr(completionHandler)
         );
 }
 private static void InternalDismissViewControllerCallback(IntPtr secondaryCallback)
 {
     if (secondaryCallback != IntPtr.Zero)
     {
         PInvokeCallbackUtil.PerformInternalCallback(
             "UIViewController#InternalDismissViewControllerCallback",
             PInvokeCallbackUtil.Type.Temporary,
             secondaryCallback);
     }
 }
Beispiel #27
0
        /// <summary>
        /// Initiates a request to find players for a peer-to-peer match.
        /// </summary>
        /// <param name="request">Request.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public void FindMatchForRequest(GKMatchRequest request, Action <GKMatch, NSError> completionHandler)
        {
            Util.NullArgumentTest(request);

            C.GKMatchmaker_findMatchForRequest(
                SelfPtr(),
                request.ToPointer(),
                MatchErrorCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Beispiel #28
0
        /// <summary>
        /// Initiates a request to find players for a hosted match.
        /// </summary>
        /// <param name="request">Request.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public void FindPlayersForHostedRequest(GKMatchRequest request, Action <NSArray <GKPlayer>, NSError> completionHandler)
        {
            Util.NullArgumentTest(request);

            C.GKMatchmaker_findPlayersForHostedRequest(
                SelfPtr(),
                request.ToPointer(),
                PlayersErrorCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
Beispiel #29
0
        /// <summary>
        /// Creates a match from an accepted invitation.
        /// </summary>
        /// <param name="invite">Invite.</param>
        /// <param name="completionHandler">Completion handler.</param>
        public void MatchForInvite(GKInvite invite, Action <GKMatch, NSError> completionHandler)
        {
            Util.NullArgumentTest(invite);

            C.GKMatchmaker_matchForInvite(
                SelfPtr(),
                invite.ToPointer(),
                MatchErrorCallback,
                PInvokeCallbackUtil.ToIntPtr(completionHandler));
        }
 private static void InternalRequestTrackingAuthorizationCallback(ATTrackingManagerAuthorizationStatus status, IntPtr secondaryCallback)
 {
     if (secondaryCallback != IntPtr.Zero)
     {
         PInvokeCallbackUtil.PerformInternalCallback(
             "ATTrackingManager#InternalRequestTrackingAuthorizationCallback",
             PInvokeCallbackUtil.Type.Temporary,
             status,
             secondaryCallback);
     }
 }