Game Development Reference
In-Depth Information
-(void) addPlayersToMatch:(GKMatchRequest*)request
{
if (isGameCenterAvailable == NO)
return;
if (currentMatch == nil)
return;
[[GKMatchmaker sharedMatchmaker] addPlayersToMatch:currentMatch
matchRequest:request
completionHandler:←
^(NSError* error)
{
[self setLastError:error];
BOOL success = (error == nil);
if ([delegate respondsToSelector:@selector(onPlayersAddedToMatch:)])
{
[delegate onPlayersAddedToMatch:success];
}
}];
}
Sending and Receiving Data
Once all players are connected, and the match has officially started, you can start send-
ing and subsequently receiving data. The easiest way to do that is to send data to all
players, as shown in Listing 14-24 .
Listing 14-24 . Sending and Receiving Data
-(void) sendDataToAllPlayers:(void*)data sizeInBytes:(NSUInteger)length
{
if (isGameCenterAvailable == NO)
return;
NSError* error = nil;
NSData* packet = [NSData dataWithBytes:data length:length];
 
 
Search Nedrilad ::




Custom Search