ios - GKTurnBasedMatch how to accept a new match invitation -
what correct way programmatically accept match invitation gamekit's standard user interface?
i seeing expectedstate="invited" foundstate="active" exception
optional(error domain=gkerrordomain code=22 "the requested operation not completed because specified participant invalid." userinfo={gkserverstatuscode=5097, nslocalizeddescription=the requested operation not completed because specified participant invalid., nsunderlyingerror=0x14fa2cf70 { error domain=gkservererrordomain code=5097 "status = 5097, unexpected slot state expectedstate="invited" foundstate="active"
the exception occurs under following scenario:
player 1 - creates new match player 2
player 1 - makes first move
player 2 - attempts load data turn based match & accept match invitation.
i using ios' standard user interface match making. gkturnbasedmatchmakerviewcontroller
requesting new match
let matchrequest = gkmatchrequest() matchrequest.minplayers = 2 matchrequest.maxplayers = 2 matchrequest.defaultnumberofplayers = 2 matchrequest.invitemessage = "play boxthedots me" matchrequest.recipientresponsehandler = self.matchmaker?.recipientresponse let matchview = gkturnbasedmatchmakerviewcontroller(matchrequest: matchrequest) self.presentviewcontroller(matchview, animated: true, completion: nil) matchview.turnbasedmatchmakerdelegate = self.matchmaker?.matchviewcontroller
i accepting match invitation programmatically, causing , printing error.
the code flow starts gkturnbasedmatchmakerviewcontrollerdelegate didfindmatch method
func turnbasedmatchmakerviewcontroller(viewcontroller: gkturnbasedmatchmakerviewcontroller, didfindmatch match: gkturnbasedmatch){ match.loadmatchdatawithcompletionhandler(self.matchdataloaded) match.acceptinvitewithcompletionhandler(self.acceptinvite) } private func acceptinvite(match:gkturnbasedmatch?, error:nserror?){ guard error == nil else { logutil.log(.critical, sub: .error, o: self, method: method, msg: "could not accept match invite. \(error)") return } }
i answered question entirely-programmatically-handled turn-based matches here, , though question on this page using standard gkturnbasedmatchmakerviewcontroller
, belive information in post helpful.
what 1 wants, of course, simple delegate function named localplayerdidacceptinvitation(...)
. absent that, information available @ link might helpful in kludging works.
Comments
Post a Comment