Class: GKMatchmaker
Overview
The GKMatchmaker class is used to programmatically create matches to other players and to receive match invitations sent by other players.
Class Method Summary (collapse)
-
+ sharedMatchmaker
Returns the singleton matchmaker instance.
Instance Method Summary (collapse)
-
- addPlayersToMatch:matchRequest:completionHandler:
Adds players to an existing match.
-
- cancel
Cancels a pending matchmaking request.
-
- cancelInviteToPlayer:
Cancels a pending invitation to another player.
-
- findMatchForRequest:withCompletionHandler:
Initiates a request to find players for a peer-to-peer match.
-
- findPlayersForHostedMatchRequest:withCompletionHandler:
Initiates a request to find players for a hosted match.
-
- finishMatchmakingForMatch:
Informs Game Center that programmatic matchmaking has finished.
-
- matchForInvite:completionHandler:
Creates a match from an accepted invitation.
-
- queryActivityWithCompletionHandler:
Initiates a search for activity in all player groups.
-
- queryPlayerGroupActivity:withCompletionHandler:
Queries Game Center for the activity in a player group.
-
- startBrowsingForNearbyPlayersWithReachableHandler:
Enables the matchmaking process to find nearby players.
-
- stopBrowsingForNearbyPlayers
Ends the search for nearby players.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Class Method Details
+ (GKMatchmaker) sharedMatchmaker
Returns the singleton matchmaker instance. Games do not create a GKMatchmaker object. Instead, they retrieve the shared singleton by calling this method.
Instance Method Details
- (Object) addPlayersToMatch(match, matchRequest:matchRequest, completionHandler:completionHandler)
Adds players to an existing match. This method updates an existing match object by adding additional players.When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a different thread than the thread originally used to invoke the method. This means that the code in your block needs to be thread safe.
- (Object) cancel
Cancels a pending matchmaking request. The completion handler receives a callback with a GKErrorCancelled error.
- (Object) cancelInviteToPlayer(playerID)
Cancels a pending invitation to another player.
- (Object) findMatchForRequest(request, withCompletionHandler:completionHandler)
Initiates a request to find players for a peer-to-peer match. When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a different thread than the thread originally used to invoke the method. This means that the code in your block needs to be thread safe.On iOS 6, if the match request’s playersToInvite property is non-NIL, Game Center sends invitations only out to the players listed in the property. If the playersToInvite property is NIL, then it searches for any waiting players that match the request. If your game wants to perform programmatic matchmaking for the remaining slots, it should call the addPlayersToMatch:matchRequest:completionHandler: method with a match request whose playersToInvite property is NIL.Prior to iOS 6, the match request’s playersToInvite property is ignored and this method only searches for available players.
- (Object) findPlayersForHostedMatchRequest(request, withCompletionHandler:completionHandler)
Initiates a request to find players for a hosted match. When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a different thread than the thread originally used to invoke the method. This means that the code in your block needs to be thread safe. When your completion handler is called, your game should connect those players to your own server.On iOS 6, if the match request’s playersToInvite property is non-NIL, Game Center sends invitations only out to the players listed in the property. If the playersToInvite property is NIL, then it searches for any waiting players that match the request. Prior to iOS 6, the match request’s playersToInvite property is ignored and this method only searches for available players.
- (Object) finishMatchmakingForMatch(match)
Informs Game Center that programmatic matchmaking has finished. If your game uses programmatic matchmaking, it makes a series of calls to the findMatchForRequest:withCompletionHandler: and addPlayersToMatch:matchRequest:completionHandler: methods to fill a match with players. When the match has the proper number of players, call thefinishMatchmakingForMatch: method before starting the match.
- (Object) matchForInvite(invite, completionHandler:completionHandler)
Creates a match from an accepted invitation. When using this method to create a match, your game should display its own user interface to inform the player that he or she has been connected to a match.When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a different thread than the thread originally used to invoke the method. This means that the code in your block needs to be thread safe.
- (Object) queryActivityWithCompletionHandler(completionHandler)
Initiates a search for activity in all player groups. A query allows your game to see how many players have recently searched for a match, across all player groups.When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a different thread than the thread originally used to invoke the method. This means that the code in your block needs to be thread safe.
- (Object) queryPlayerGroupActivity(playerGroup, withCompletionHandler:completionHandler)
Queries Game Center for the activity in a player group. A query allows your game to see how many players have recently searched for a match. As a result, you can present a user interface that shows the relative activity in each player group. For example, if one group sees less activity than others, you might display a warning so that players are aware that finding a match may take longer.When this method is called, it creates a new background task to handle the request. The method then returns control to your game. Later, when the task is complete, Game Kit calls your completion handler. Keep in mind that the completion handler may be called on a different thread than the thread originally used to invoke the method. This means that the code in your block needs to be thread safe.
- (Object) startBrowsingForNearbyPlayersWithReachableHandler(reachableHandler)
Enables the matchmaking process to find nearby players. You only use this method when you are implementing programmatic matchmaking. After enabling browsing for nearby players, use the responses to populate your user interface with information about nearby players. If a player wants to invite a player to a game, add that player’s player identifier to a match request and call either the findMatchForRequest:withCompletionHandler: to create a match or addPlayersToMatch:matchRequest:completionHandler: method to update a match.
- (Object) stopBrowsingForNearbyPlayers
Ends the search for nearby players.