Example #1
0
        private void SessionCreatorComplete_ActivateSharingScreen(AsyncLiveOperation op)
        {
            if (op.Succeeded)
            {
                SessionCreator createOp = op as SessionCreator;

                LiveManager.Session = createOp.Session;
                createOp.Session    = null; // avoid session dispose

                ActivateSharingScreen();
            }
            else
            {
                // Failed to create the session for some reason.
                // TODO: Show a message here?


                // Restart the periodic update of profiles and joinable states.
                LiveManager.FriendUpdatesEnabled   = true;
                LiveManager.JoinableUpdatesEnabled = true;

                // Re-enable the share hub menu.
                shared.grid.Active = true;
            }
        }
Example #2
0
        private void SessionCreatorComplete_StartInvitingFriend(AsyncLiveOperation op)
        {
            openingSharingRoomMessage.Deactivate();
            openingInviteGuideMessage.Deactivate();

            // We needed to create a session before sending out an invitation to our friend.
            // If we're here, then the session create process is complete.
            UIGridShareFriendElement shareHubElement = op.Param as UIGridShareFriendElement;

            if (op.Succeeded)
            {
                // Session was created, start inviting the friend.

                SessionCreator createOp = op as SessionCreator;

                LiveManager.Session = createOp.Session;
                createOp.Session    = null; // avoid session dispose

                LiveManager.Session.GamerJoined += shared.Session_GamerJoined;
                LiveManager.Session.GamerLeft   += shared.Session_GamerLeft;

                StartInvitingFriend(shareHubElement);
            }
            else
            {
                // TODO: show a message about the failure.
            }
        }
Example #3
0
        private void JoinSessionComplete_ActivateSharingScreen(AsyncLiveOperation op)
        {
            openingSharingRoomMessage.Deactivate();
            openingInviteGuideMessage.Deactivate();

            // In case we were joining by accepting an invite, clear that flag now.
            LiveManager.JoiningShareInvitation = false;

            if (op.Succeeded)
            {
                SessionJoiner joinerOp = op as SessionJoiner;

                LiveManager.Session = joinerOp.Session;
                joinerOp.Session    = null; // avoid session dispose, since we joined it.

                ActivateSharingScreen();
            }
            else
            {
                // Failed to join the session for some reason, so re-enable the share hub's periodic LIVE operations.
                LiveManager.FriendUpdatesEnabled   = true;
                LiveManager.JoinableUpdatesEnabled = true;

                shared.grid.Active = true;
            }
        }
Example #4
0
        private void FindSessionComplete_Join(AsyncLiveOperation op)
        {
            UIGridShareFriendElement friendElement = op.Param as UIGridShareFriendElement;

            if (op.Succeeded)
            {
                SessionFinder finderOp = op as SessionFinder;

                if (finderOp.AvailableSessions.Count > 0)
                {
                    // We found an available session. Before we can start joining it, we must cancel all pending LIVE
                    // operations. Some of them may be queued attempts to find joinable sessions (incompatible with
                    // joining a session), and the others will be profile updates (no longer relevant as we're leaving
                    // this screen).
                    LiveManager.ClearQueuedOperations(null);

                    openingSharingRoomMessage.Activate();

                    // Start joining the session.
                    AvailableSessionJoiner joinerOp = new AvailableSessionJoiner(finderOp.AvailableSessions[0], JoinSessionComplete_ActivateSharingScreen, op.Param, this);

                    // This operation must start before the network session updates again or
                    // the available sessions collection becomes invalid for some reason.
                    joinerOp.Queue(true);

                    finderOp.AvailableSessions = null;  // prevent dispose, since we passed the available session to the joiner.

                    // TODO: Show joining session message here..
                }
                else
                {
                    // We didn't find the session. Re-enable the share hub's periodic LIVE operations.
                    LiveManager.FriendUpdatesEnabled   = true;
                    LiveManager.JoinableUpdatesEnabled = true;

                    // Session is no longer available, so mark friend as not joinable.
                    // This may change if we detect they are joinable again.
                    if (friendElement != null)
                    {
                        friendElement.Friend.IsJoinable = false;
                    }

                    // Not leaving the share hub anymore, since we failed to join the session.
                    shared.grid.Active = true;
                    openingSharingRoomMessage.Deactivate();
                }
            }
            else
            {
                // We didn't find the session. Re-enable the share hub's periodic LIVE operations.
                LiveManager.FriendUpdatesEnabled   = true;
                LiveManager.JoinableUpdatesEnabled = true;

                // The join operation failed, so mark friend as not joinable.
                // This may change if we detect they are joinable again.
                if (friendElement != null)
                {
                    friendElement.Friend.IsJoinable = false;
                }

                // Not leaving the share hub anymore, since we failed to join the session.
                shared.grid.Active = true;
                openingSharingRoomMessage.Deactivate();
            }
        }