Frage

I am occasionally receiving the following error when I try to send a turn in a Sandbox Game Center turn based play game.

Error Domain=GKErrorDomain Code=23 "The requested operation could not be completed because the specified participant does not have the required turn state." UserInfo=0x209e5110 {GKServerStatusCode=5103, NSUnderlyingError=0x209e56b0 "The operation couldn’t be completed. status = 5103, Session: 4d278ed6-d546-4d31-bb6f-0a4ae89873aa current turn: 8 isn't as expected: 1", NSLocalizedDescription=The requested operation could not be completed because the specified participant does not have the required turn state.

The 'current turn' and 'expected' numbers differ. I am sending between two devices, one with iOS5 and one with iOS6. I have accounted for the depreciation of the old call using the following line:

if([match respondsToSelector:@selector(endTurnWithNextParticipants:turnTimeout:matchData:completionHandler:)]){
        [match endTurnWithNextParticipants:@[nextParticipant] turnTimeout:inval matchData:data completionHandler:completeEndTurn];
    }
    else{
        [match endTurnWithNextParticipant:nextParticipant matchData:data completionHandler:completeEndTurn];
    }

The input parameters 'look' to be correct i.e I can't see any clear errors. However, I don't really understand the error message. I have attempted to find more via searching but can't find anything that explains the error. Apple docs just has the text that is given in the message. Can anyone point me to a place which explains the error in more detail? Also, does the 'state' mean the participant 'status' on the other device?

Thanks.

War es hilfreich?

Lösung

In my case this error was due to me using an incorrect (old) match object to end the turn. Apparently, this object changes during the game, and you need to renew your stored match instance with what you get in handleTurnEventForMatch every time it gets called. Like Ray said,

- (void) handleTurnEventForMatch:(GKTurnBasedMatch *)match 
{
    NSLog(@"Turn has happened");
    if ([match.matchID isEqualToString:currentMatch.matchID]) 
    {
    ...
        self.currentMatch = match; // <-- renew your instance!
    ...
    }
}

So, when I started to use the up-to-date currentMatch to end turns - the error went away.

I also found the same solution in this comment, but it took some time to realize that it was what I'd needed)

Hope this helps, cheers!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top