Gamekit applications running 4.0 do not properly handle the removal of GKSession objects. Run under 3.1.3 or 3.2 if the peer connection is disconnected and the session is cleared (as in Apple demos):
[gkSession disconnectFromAllPeers]
[gkSession setAvailable:NO]
[gkSession setDelegate:nil]
[gkSession setDataReceiveHandler:nil withContext:nil]
then other peers receive state changes, and the peer table view can be updated.
In my application, one peer starts as a server and the other starts as a client. The client requests a connection to the server, and the client name appears in the server list. If the server decides to accept the request, a session connection is established and they can play the game. If the client shuts down before the server accepts the request, the client clears the session (as indicated above), and the client disappears from the list of peer servers in response (when it receives a state change). This works amazingly on 3.1-3.2.
When starting the same application running under 4.0, the server and client give an error, and it takes a lot of time for peers to receive state changes, and when they do, the application crashes without any errors (even with NSZombieEnabled = YES in the construction arguments). The server never receives a “state change” message from the client. Instead, the following errors occur:
Thu Jul 8 23:27:26 unknown com.apple.mDNSResponder[18] <Notice>: BTLocalDeviceRemoveData: 60 byte key, 18 byte value
Thu Jul 8 23:27:26 unknown MobileBluetooth[29] <Notice>: BTLocalDeviceRemoveData - BT_ERROR_INVALID_HANDLE
Thu Jul 8 23:27:26 unknown com.apple.mDNSResponder[18] <Notice>: Call to BTLocalDeviceRemoveData failed with error 7
Thu Jul 8 23:13:39 unknown mDNSResponder[18] <Error>: external_stop_advertising_service: 18 00Z1Tud0A\\.\\.Tonberry\M-b\M^@\M^Ys\\032iPhone._1htnu3uko0uvsp._udp.local. TXT txtvers=1\M-B\M-&state=A
Thu Jul 8 23:13:39 unknown MobileBluetooth[29] <Notice>: BTLocalDeviceRemoveData - BT_ERROR_INVALID_HANDLE
What I think is the key error:
Tue Jul 13 21:04:50 Tonberry com.apple.mDNSResponder[21] <Notice>: Call to BTDiscoveryAgentStopScan failed with error 400
It seems to me that the session is unavailable (error when stopping ads in the service). Actual failure:
Thread 3 Crashed:
0 GameKitServices 0x06352f90 gckSessionChangeStateCList + 411
1 GameKitServices 0x0635b49c gckSessionRecvProc + 1474
2 libSystem.B.dylib 0x981c181d _pthread_start + 345
3 libSystem.B.dylib 0x981c16a2 thread_start + 34
. 3.1.3/3.2, Gamekit 4.0 . , . - , .
, , . , .