4

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.

4

1 回答 1

3

在我的情况下,这个错误是由于我使用了不正确的(旧)匹配对象来结束回合。显然,这个对象在游戏过程中会发生变化,您需要在每次调用它时使用您在 handleTurnEventForMatch 中获得的内容更新您存储的匹配实例。就像雷的,

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

因此,当我开始使用最新的 currentMatch 结束转弯时 - 错误消失了。

我还在此评论中找到了相同的解决方案,但花了一些时间才意识到这是我所需要的)

希望这会有所帮助,干杯!

于 2013-07-27T00:27:19.730 回答