[Mono-bugs] [Bug 656176] New: GKMatchmakerViewController is not firing events to Delegate GKMatchmakerViewControllerDelegate

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sat Nov 27 17:09:09 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=656176

https://bugzilla.novell.com/show_bug.cgi?id=656176#c0


           Summary: GKMatchmakerViewController is not firing events to
                    Delegate GKMatchmakerViewControllerDelegate
    Classification: Mono
           Product: MonoTouch
           Version: SVN
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: Class Libraries
        AssignedTo: gnorton at novell.com
        ReportedBy: kevin_mullins at appracatappra.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-us)
AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4

Using the GKMatchmakerViewController with iOS 4.2 in MonoTouch the events
WasCancelled, DidFailWithError, DidFindMatch and DidFindPlayers are not firing
on code attached either by attaching to the events on the
GKMatchmakerViewController or by creating a subclass off of
GKMatchmakerViewControllerDelegate and attaching to the Delegate property of
the GKMatchmakerViewController object.

Example:

//Create match request
matchRequest=new GKMatchRequest();
matchRequest.MinPlayers=state.playerCount;
matchRequest.MaxPlayers=state.playerCount;

//Display matchmaking controller
Console.WriteLine("Starting Matchmaking");
matchmaker =new GKMatchmakerViewController(matchRequest);
matchmaker.Delegate=new MatchmakerDelegate(matchmaker,state);
mainView.PresentModalViewController(matchmaker,true);

If I call the above code, the Matchmaking view is displayed correctly and works
as would be expected, however if I try press the Cancel button, the
WasCancelled event is never raised on the object or it's delegate.

Reproducible: Always

Steps to Reproduce:
I've tried two methods and both have the same results, no event code is raised.
Add this code to a simple iPad application, Authenticate a Game Center player
and try to call either version of the GKMatchmakerViewController to initialize
network play.

---------------
Code to get Game Center Player for both versions
---------------
GKLocalPlayer.LocalPlayer.Authenticate(delegate(MonoTouch.Foundation.NSError
error){
                    //Did an error occur connection to the local player's
account?
                    if (error==null) {
                        //We have successfully connected to game center
                        _state.gameCenterAvailable=true;
                    } else {

                        //Not available
                        _state.gameCenterAvailable=false;
                        using(var alert = new UIAlertView("Hexo", "Game Center
Unavailable", null, "OK", null))
                        {
                            alert.Show();    
                        }
                    }
                });

---------------
Version 1
---------------
/Create match request
matchRequest=new GKMatchRequest();
matchRequest.MinPlayers=state.playerCount;
matchRequest.MaxPlayers=state.playerCount;

//Display matchmaking controller
Console.WriteLine("Starting Matchmaking");
matchmaker =new GKMatchmakerViewController(matchRequest);
matchmaker.WasCancelled+=delegate(object sender, EventArgs e){
    Console.WriteLine("Matchmaking cancelled");
    state.match=null;
    matchmaker.DismissModalViewControllerAnimated(true);
};
matchmaker.DidFailWithError+=delegate(object sender, GKErrorEventArgs e){
    state.match=null;
    matchmaker.DismissModalViewControllerAnimated(true);
    Console.WriteLine("Matchmaking failed with errors");
};
matchmaker.DidFindMatch+=delegate(object sender, GKMatchEventArgs matchArgs){
    state.match=matchArgs.Match;
    matchmaker.DismissModalViewControllerAnimated(true);
    Console.WriteLine("Matchmaking found match");
};
mainView.PresentModalViewController(matchmaker,true);



----------------
Version 2
----------------
//Create match request
matchRequest=new GKMatchRequest();
matchRequest.MinPlayers=state.playerCount;
matchRequest.MaxPlayers=state.playerCount;

//Display matchmaking controller
Console.WriteLine("Starting Matchmaking");
matchmaker =new GKMatchmakerViewController(matchRequest);
matchmaker.Delegate=new MatchmakerDelegate(matchmaker,state);
mainView.PresentModalViewController(matchmaker,true);


using System;
using System.Drawing;
using System.Collections.Generic;
using System.Collections;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using MonoTouch.CoreGraphics;
using MonoTouch.ObjCRuntime;
using MonoTouch.GameKit;

namespace Hexo
{
    public class MatchmakerDelegate : GKMatchmakerViewControllerDelegate 
    {
        //Private variable storage
        private GKMatchmakerViewController _controller;
        private GameState _state;

        //Constructors
        public MatchmakerDelegate() : base() {

        }

        public MatchmakerDelegate(NSCoder coder): base(coder){

        }

        public MatchmakerDelegate(NSObjectFlag flag): base(flag){

        }

        public MatchmakerDelegate(IntPtr pointer): base(pointer){
        }

        public MatchmakerDelegate(GKMatchmakerViewController
controller,GameState state) : base() {
            this._controller=controller;
            this._state=state;
        }

        public override void WasCancelled (GKMatchmakerViewController
viewController)
        {
            Console.WriteLine("Matchmaking cancelled");
            _state.match=null;
            _controller.DismissModalViewControllerAnimated(true);
        }

        public override void DidFailWithError (GKMatchmakerViewController
viewController, NSError error)
        {
            Console.WriteLine("Matchmaking failed with errors");
            _state.match=null;
            _controller.DismissModalViewControllerAnimated(true);
        }

        public override void DidFindMatch (GKMatchmakerViewController
viewController, GKMatch match)
        {
            Console.WriteLine("Matchmaking found match");
            _state.match=match;
            _controller.DismissModalViewControllerAnimated(true);
        }

        public override void DidFindPlayers (GKMatchmakerViewController
viewController, string[] playerIDs)
        {
            Console.WriteLine("Matchmaking found players");
        }
    }
}


Actual Results:  
Events happening on the GKMatchmakerViewController never call the code attached
to WasCancelled, DidFailWithError, DidFindMatch, or DidFindPlayers delegates.

Expected Results:  
Events happening on the GKMatchmakerViewController should raise the events
WasCancelled, DidFailWithError, DidFindMatch, or DidFindPlayers.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list