Currently i am using the GameKit framework to establish a 2 player connection over bluetooth
Everything is working fine except the disconnect
When i disconnect, the player who hits the disconnect button disconnects fine and can connect to other devices or do what ever and its all ok
the player who didn't press the disconnect button, his app crashes, now i think what happens is it waits for the timeout to happen and disconnect themselves that way
But i would like it be kinda instant in what is happening and to disconnect immediately as well
heres some code samples:
In my recieve data method:
Neither of these works, tried to set timout period very short but seemed to make no difference and disconnectFromAllPeers makes it crash to
In my method:
- (void)session
GKSession *)session peer
NSString *)peerID didChangeState
GKPeerConnectionState)state
I have this code under disconnect:
im guessing i am missing something,
if it makes any difference in my - (void)peerPickerControllerDidCancel
GKPeerPickerController *)picker method i have:
Finally in my IBAtion for when the disconnect button is pressed i have this code:
If anyone can help that would be very good,
But i am having troubles just trying to find much information on google and no one seems to say these problems
Everything is working fine except the disconnect
When i disconnect, the player who hits the disconnect button disconnects fine and can connect to other devices or do what ever and its all ok
the player who didn't press the disconnect button, his app crashes, now i think what happens is it waits for the timeout to happen and disconnect themselves that way
But i would like it be kinda instant in what is happening and to disconnect immediately as well
heres some code samples:
In my recieve data method:
Code:
if (myNumber == 5) // this just checks they have asked to disconnect
{
[gameSession disconnectFromAllPeers];
//[gameSession setDisconnectTimeout:0.001];
}
In my method:
- (void)session
I have this code under disconnect:
Code:
case GKPeerStateDisconnected:
[self.picker dismiss];
[self.gameSession release];
peerStatus = kServer;
break;
im guessing i am missing something,
if it makes any difference in my - (void)peerPickerControllerDidCancel
Code:
[gameSession disconnectFromAllPeers];
gameSession.available = NO;
[gameSession setDataReceiveHandler: nil withContext: nil];
gameSession.delegate = nil;
[gameSession release];
Finally in my IBAtion for when the disconnect button is pressed i have this code:
Code:
[self mySendData:5];
[gameSession disconnectFromAllPeers];
If anyone can help that would be very good,
But i am having troubles just trying to find much information on google and no one seems to say these problems