1

I am developing a 3D bluetooth multiplayer game for iPhone and iPad without using any game engine. I am using GKSession class to send data between devices over Bluetooth using Peer to Peer mode. If I continue to play the game for some time there is no performance drop issue, but when I disconnect (even without exiting the game) and reconnect the game again via Bluetooth game mode, then I am facing the performance drop (game lag) issue.

I tried profiling my code (when the game lags) and found that the data packets require more time (approx. 10 ms) to transfer to the other device which usually takes 2 ms when the game runs without lag.

I have three questions:

  1. I am assuming that the increase in data transfer time can be the cause for the lag issue. If yes, how to fix such issue?

  2. I am testing my game on iPad and iPhone running on iOS 7 and 8 respectively. As GKSession is deprecated with iOS 7, will this affect the game performance?

  3. Are there any other parts of the code which can cause such performance issue?

I’d appreciate any suggestions on this issue. Thank you in advance.

Code snippets:

Code to disconnect two devices

     if(session!=nil)
        {
            [session disconnectFromAllPeers];
            [session setAvailable:NO];
            [session setDataReceiveHandler:NULL withContext:NULL];
            session.delegate = nil;
            [session release];
       } 
  1. Code to create session

    (GKSession *) peerPickerController:(GKPeerPickerController *)picker sessionForConnectionType:(GKPeerPickerConnectionType)type {

    session = [[GKSession alloc] initWithSessionID:@"XYZ" displayName:nil sessionMode:GKSessionModePeer];
    session.delegate = self;
    session.available = YES;
    return session;
    

    }

  2. Definition of session in header file

    @property (nonatomic, retain) GKSession *session;

0 Answers0