i am making realtime multiplayer game
in cocos 2d-x
for iOS
. According to my flow i am doing following things with the help of this link iOS Game Center GameKit Programmatic Invite Matchmaking:
Step 1: Authenticate your player
Step 2: right after authentication set inviteHandler.
Step 3: Get your list of friend playerIds (not alias)
Step 4: Fourth, Setup your GKMatchRequest something like this... I am inviting all the friends.
Step 5: Fifth, Use the request to call findMatchForRequest:withCompletionHandler
.
Step 6: Sixth, this sends the request to the other player and if they accept the "inviteHandler" from the second step gets called.
Step 7: Seventh, the "inviteHandler" from the second step gets the match for the GKInvite!
Step 8: Eighth, the "inviteeResponseHandler" from the fourth step gets called which finished the match!
Till here my code is working fine after it. 3 steps after these steps are not working can please anyone help me out ?
Step 9: Ninth, create a didChangeState
from GKMatchDelegate
to handle the finalization of the match.
Step 10: Send message
Step 11: Eleventh, create a didReceiveData
from GKMatchDelegate
.
[_match sendData:data toPlayers:_currentFriends dataMode:GKMatchSendDataUnreliable error:&error];
[_match sendData:data toPlayers:_currentFriends withDataMode:GKMatchSendDataReliable error:&error];
[_match sendDataToAllPlayers:data withDataMode:GKMatchSendDataUnreliable error:&error];
And its delegate method is:
- (void)match:(GKMatch *)match didReceiveData:(NSData *)data fromPlayer:(NSString *)playerID {
NSLog(@"Received Data");
[_delegate match:match didReceiveData:data fromPlayer:playerID];
}
I have also tried:
- (void)match:(GKMatch *)match didReceiveData:(NSData *)data fromRemotePlayer:(GKPlayer *)player
{
NSLog(@"received DAta");
}