iWizard
iWizard

Reputation: 7094

Game center issue with sending data

I'm working on a iOS multiplayer game which use Game Center.

When users login in Game Center and tap "play now" GC connect 4 players and game starts. The problem is that game is frequently freezing because some of the data are lost (I think this is the reason). Game usually works fine but sometimes data which are sent by server (server is some of the players) is lost and game freeze.

I use this function for sending data:

- (void)sendDataNSData *)data {
    NSError *error;

    BOOL success = [[GCHelper sharedInstance].match sendDataToAllPlayers:data withDataMode:GKMatchSendDataReliable errorerror];

    if (!success) {

        //NSLog(@"Error sending init packet");
        [self matchEnded];

    }
}

The problem is that matchend is not called so I believe that data is sent but it is lost.

Does anyone have similar issues and know how to fix it?

Upvotes: 1

Views: 262

Answers (1)

Yan
Yan

Reputation: 886

My users also complain that some data may be accidentally lost during the game. I wrote a test app and figured out that GKMatchSendDataReliable is not really reliable. On weak internet connection (e.g. EDGE) some packets are regularly lost without any error from the Game Center API.

So the only option is to add an extra transport layer for truly reliable delivery.

I wrote a simple lib for this purpose: RoUTP. It saves all sent messages until acknowledgement for each received, resends lost and buffers received messages in case of broken sequence. In my tests combination "RoUTP + GKMatchSendDataUnreliable" works even beter than "RoUTP + GKMatchSendDataReliable" (and of course better than pure GKMatchSendDataReliable which is not really reliable).

Upvotes: 2

Related Questions