示例#1
0
        internal void HandleInvitation(Types.MultiplayerEvent eventType, string invitationId,
                                       MultiplayerInvitation invitation)
        {
            // Stash a reference to the invitation handler in case it is updated while we're handling
            // this callback.
            var currentHandler = mInvitationDelegate;

            if (currentHandler == null)
            {
                GooglePlayGames.OurUtils.Logger.d("Received " + eventType + " for invitation "
                                                  + invitationId + " but no handler was registered.");
                return;
            }

            if (eventType == Types.MultiplayerEvent.REMOVED)
            {
                GooglePlayGames.OurUtils.Logger.d("Ignoring REMOVED for invitation " + invitationId);
                return;
            }

            bool shouldAutolaunch = eventType == Types.MultiplayerEvent.UPDATED_FROM_APP_LAUNCH;

            // Copy the invitation into managed memory.
            Invitation invite = invitation.AsInvitation();

            PlayGamesHelperObject.RunOnGameThread(() =>
                                                  currentHandler(invite, shouldAutolaunch));
        }
示例#2
0
        internal void HandleMatchEvent(Types.MultiplayerEvent eventType, string matchId,
                                       NativeTurnBasedMatch match)
        {
            // Capture the current value of the delegate to protect against racing updates.
            var currentDelegate = mMatchDelegate;

            if (currentDelegate == null)
            {
                return;
            }

            // Ignore REMOVED events - this plugin has no use for them.
            if (eventType == Types.MultiplayerEvent.REMOVED)
            {
                Logger.d("Ignoring REMOVE event for match " + matchId);
                return;
            }

            bool shouldAutolaunch = eventType == Types.MultiplayerEvent.UPDATED_FROM_APP_LAUNCH;

            match.ReferToMe();
            Callbacks.AsCoroutine(WaitForLogin(() =>
                                               { currentDelegate(match.AsTurnBasedMatch(mNativeClient.GetUserId()), shouldAutolaunch);
                                                 match.ForgetMe(); }));
        }
        private static void InternalOnTurnBasedMatchEventCallback(Types.MultiplayerEvent eventType,
                                                                  string matchId, IntPtr match, IntPtr userData)
        {
            var callback = Callbacks.IntPtrToPermanentCallback
                           <Action <Types.MultiplayerEvent, string, NativeTurnBasedMatch> >(userData);

            using (var nativeMatch = NativeTurnBasedMatch.FromPointer(match)) {
                try {
                    if (callback != null)
                    {
                        callback(eventType, matchId, nativeMatch);
                    }
                } catch (Exception e) {
                    Logger.e("Error encountered executing InternalOnTurnBasedMatchEventCallback. " +
                             "Smothering to avoid passing exception into Native: " + e);
                }
            }
        }
示例#4
0
        internal void HandleInvitation(Types.MultiplayerEvent eventType, string invitationId,
                                       MultiplayerInvitation invitation)
        {
            // Stash a reference to the invitation handler in case it is updated while we're handling
            // this callback.
            var currentHandler = mInvitationDelegate;

            if (currentHandler == null)
            {
                Logger.d("Received " + eventType + " for invitation "
                         + invitationId + " but no handler was registered.");
                return;
            }

            if (eventType == Types.MultiplayerEvent.REMOVED)
            {
                Logger.d("Ignoring REMOVED for invitation " + invitationId);
                return;
            }

            bool shouldAutolaunch = eventType == Types.MultiplayerEvent.UPDATED_FROM_APP_LAUNCH;

            currentHandler(invitation.AsInvitation(), shouldAutolaunch);
        }