objc2_game_kit/generated/
GKMatchmaker.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// Possible invitee responses
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkinviterecipientresponse?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct GKInviteRecipientResponse(pub NSInteger);
17impl GKInviteRecipientResponse {
18    #[doc(alias = "GKInviteRecipientResponseAccepted")]
19    pub const Accepted: Self = Self(0);
20    #[doc(alias = "GKInviteRecipientResponseDeclined")]
21    pub const Declined: Self = Self(1);
22    #[doc(alias = "GKInviteRecipientResponseFailed")]
23    pub const Failed: Self = Self(2);
24    #[doc(alias = "GKInviteRecipientResponseIncompatible")]
25    pub const Incompatible: Self = Self(3);
26    #[doc(alias = "GKInviteRecipientResponseUnableToConnect")]
27    pub const UnableToConnect: Self = Self(4);
28    #[doc(alias = "GKInviteRecipientResponseNoAnswer")]
29    pub const NoAnswer: Self = Self(5);
30    #[deprecated]
31    pub const GKInviteeResponseAccepted: Self = Self(GKInviteRecipientResponse::Accepted.0);
32    #[deprecated]
33    pub const GKInviteeResponseDeclined: Self = Self(GKInviteRecipientResponse::Declined.0);
34    #[deprecated]
35    pub const GKInviteeResponseFailed: Self = Self(GKInviteRecipientResponse::Failed.0);
36    #[deprecated]
37    pub const GKInviteeResponseIncompatible: Self = Self(GKInviteRecipientResponse::Incompatible.0);
38    #[deprecated]
39    pub const GKInviteeResponseUnableToConnect: Self =
40        Self(GKInviteRecipientResponse::UnableToConnect.0);
41    #[deprecated]
42    pub const GKInviteeResponseNoAnswer: Self = Self(GKInviteRecipientResponse::NoAnswer.0);
43}
44
45unsafe impl Encode for GKInviteRecipientResponse {
46    const ENCODING: Encoding = NSInteger::ENCODING;
47}
48
49unsafe impl RefEncode for GKInviteRecipientResponse {
50    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
51}
52
53/// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkinviteeresponse?language=objc)
54#[deprecated]
55pub type GKInviteeResponse = GKInviteRecipientResponse;
56
57/// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchtype?language=objc)
58// NS_ENUM
59#[repr(transparent)]
60#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
61pub struct GKMatchType(pub NSUInteger);
62impl GKMatchType {
63    #[doc(alias = "GKMatchTypePeerToPeer")]
64    pub const PeerToPeer: Self = Self(0);
65    #[doc(alias = "GKMatchTypeHosted")]
66    pub const Hosted: Self = Self(1);
67    #[doc(alias = "GKMatchTypeTurnBased")]
68    pub const TurnBased: Self = Self(2);
69}
70
71unsafe impl Encode for GKMatchType {
72    const ENCODING: Encoding = NSUInteger::ENCODING;
73}
74
75unsafe impl RefEncode for GKMatchType {
76    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
77}
78
79extern_class!(
80    /// GKMatchRequest represents the parameters needed to create the match.
81    ///
82    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchrequest?language=objc)
83    #[unsafe(super(NSObject))]
84    #[derive(Debug, PartialEq, Eq, Hash)]
85    pub struct GKMatchRequest;
86);
87
88extern_conformance!(
89    unsafe impl NSObjectProtocol for GKMatchRequest {}
90);
91
92impl GKMatchRequest {
93    extern_methods!(
94        /// Minimum number of players for the match
95        #[unsafe(method(minPlayers))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn minPlayers(&self) -> NSUInteger;
98
99        /// Setter for [`minPlayers`][Self::minPlayers].
100        #[unsafe(method(setMinPlayers:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn setMinPlayers(&self, min_players: NSUInteger);
103
104        /// Maximum number of players for the match
105        #[unsafe(method(maxPlayers))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn maxPlayers(&self) -> NSUInteger;
108
109        /// Setter for [`maxPlayers`][Self::maxPlayers].
110        #[unsafe(method(setMaxPlayers:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn setMaxPlayers(&self, max_players: NSUInteger);
113
114        /// The player group identifier. Matchmaking will only take place between players in the same group.
115        #[unsafe(method(playerGroup))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn playerGroup(&self) -> NSUInteger;
118
119        /// Setter for [`playerGroup`][Self::playerGroup].
120        #[unsafe(method(setPlayerGroup:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setPlayerGroup(&self, player_group: NSUInteger);
123
124        /// optional mask that specifies the role that the local player would like to play in the game.  If this value is 0, it will be set to 0xFFFFFFFF (the default), and this property will be ignored. If the value is nonzero, then automatching uses the value as a mask that restricts the role the player can play in the group. Automatching with player attributes matches new players into the game so that the bitwise OR of the masks of all the players in the resulting match equals 0xFFFFFFFF.
125        #[unsafe(method(playerAttributes))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn playerAttributes(&self) -> u32;
128
129        /// Setter for [`playerAttributes`][Self::playerAttributes].
130        #[unsafe(method(setPlayerAttributes:))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn setPlayerAttributes(&self, player_attributes: u32);
133
134        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
135        /// Array of GKPlayers to invite, or nil if none. This array can also include local guest players.
136        #[unsafe(method(recipients))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn recipients(&self) -> Option<Retained<NSArray<GKPlayer>>>;
139
140        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
141        /// Setter for [`recipients`][Self::recipients].
142        #[unsafe(method(setRecipients:))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<GKPlayer>>);
145
146        /// Message sent to invited players, may be modified if using GKMatchmakerViewController
147        /// Will return nil if the player is underage or restricted.
148        #[unsafe(method(inviteMessage))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn inviteMessage(&self) -> Option<Retained<NSString>>;
151
152        /// Setter for [`inviteMessage`][Self::inviteMessage].
153        ///
154        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
155        #[unsafe(method(setInviteMessage:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setInviteMessage(&self, invite_message: Option<&NSString>);
158
159        /// Default number of players to use during matchmaking. If not set we will default to the number that the player previously set for this game, or maxPlayers.
160        #[unsafe(method(defaultNumberOfPlayers))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn defaultNumberOfPlayers(&self) -> NSUInteger;
163
164        /// Setter for [`defaultNumberOfPlayers`][Self::defaultNumberOfPlayers].
165        #[unsafe(method(setDefaultNumberOfPlayers:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn setDefaultNumberOfPlayers(&self, default_number_of_players: NSUInteger);
168
169        /// Whether or not a match will be created only using automatch.  If YES, then a player will not be able to
170        /// invite anyone (including contacts, friends, and nearby players) to the match, but rely on automatching to
171        /// find players for the match.  Default is NO.
172        #[deprecated]
173        #[unsafe(method(restrictToAutomatch))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn restrictToAutomatch(&self) -> bool;
176
177        /// Setter for [`restrictToAutomatch`][Self::restrictToAutomatch].
178        #[deprecated]
179        #[unsafe(method(setRestrictToAutomatch:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setRestrictToAutomatch(&self, restrict_to_automatch: bool);
182
183        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
184        /// An recipientResponseHandler can be set in order to receive responses from programmatically invited players.
185        ///
186        /// # Safety
187        ///
188        /// The returned block's argument 1 must be a valid pointer.
189        #[unsafe(method(recipientResponseHandler))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn recipientResponseHandler(
192            &self,
193        ) -> *mut block2::DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>;
194
195        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
196        /// Setter for [`recipientResponseHandler`][Self::recipientResponseHandler].
197        ///
198        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
199        #[unsafe(method(setRecipientResponseHandler:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn setRecipientResponseHandler(
202            &self,
203            recipient_response_handler: Option<
204                &block2::DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>,
205            >,
206        );
207
208        #[cfg(feature = "block2")]
209        /// # Safety
210        ///
211        /// The returned block's argument 1 must be a valid pointer.
212        #[deprecated]
213        #[unsafe(method(inviteeResponseHandler))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn inviteeResponseHandler(
216            &self,
217        ) -> *mut block2::DynBlock<dyn Fn(NonNull<NSString>, GKInviteeResponse)>;
218
219        #[cfg(feature = "block2")]
220        /// Setter for [`inviteeResponseHandler`][Self::inviteeResponseHandler].
221        ///
222        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
223        #[deprecated]
224        #[unsafe(method(setInviteeResponseHandler:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn setInviteeResponseHandler(
227            &self,
228            invitee_response_handler: Option<
229                &block2::DynBlock<dyn Fn(NonNull<NSString>, GKInviteeResponse)>,
230            >,
231        );
232
233        /// To determine the maximum allowed players for each type of match supported.
234        #[unsafe(method(maxPlayersAllowedForMatchOfType:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn maxPlayersAllowedForMatchOfType(match_type: GKMatchType) -> NSUInteger;
237
238        #[deprecated]
239        #[unsafe(method(playersToInvite))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn playersToInvite(&self) -> Option<Retained<NSArray<NSString>>>;
242
243        /// Setter for [`playersToInvite`][Self::playersToInvite].
244        #[deprecated]
245        #[unsafe(method(setPlayersToInvite:))]
246        #[unsafe(method_family = none)]
247        pub unsafe fn setPlayersToInvite(&self, players_to_invite: Option<&NSArray<NSString>>);
248
249        /// The name of the queue, if rule-based matchmaking is used.
250        #[unsafe(method(queueName))]
251        #[unsafe(method_family = none)]
252        pub unsafe fn queueName(&self) -> Option<Retained<NSString>>;
253
254        /// Setter for [`queueName`][Self::queueName].
255        ///
256        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
257        #[unsafe(method(setQueueName:))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn setQueueName(&self, queue_name: Option<&NSString>);
260
261        #[cfg(feature = "GKDefines")]
262        /// The match properties, if rule-based matchmaking is used.
263        #[unsafe(method(properties))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>;
266
267        #[cfg(feature = "GKDefines")]
268        /// Setter for [`properties`][Self::properties].
269        ///
270        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
271        ///
272        /// # Safety
273        ///
274        /// `properties` generic should be of the correct type.
275        #[unsafe(method(setProperties:))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn setProperties(&self, properties: Option<&GKMatchProperties>);
278
279        #[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
280        /// The recipient specific match properties, if rule-based matchmaking is used when inviting players.
281        #[unsafe(method(recipientProperties))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn recipientProperties(
284            &self,
285        ) -> Option<Retained<NSDictionary<GKPlayer, GKMatchProperties>>>;
286
287        #[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
288        /// Setter for [`recipientProperties`][Self::recipientProperties].
289        ///
290        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
291        ///
292        /// # Safety
293        ///
294        /// `recipient_properties` generic generic should be of the correct type.
295        #[unsafe(method(setRecipientProperties:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn setRecipientProperties(
298            &self,
299            recipient_properties: Option<&NSDictionary<GKPlayer, GKMatchProperties>>,
300        );
301    );
302}
303
304/// Methods declared on superclass `NSObject`.
305impl GKMatchRequest {
306    extern_methods!(
307        #[unsafe(method(init))]
308        #[unsafe(method_family = init)]
309        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
310
311        #[unsafe(method(new))]
312        #[unsafe(method_family = new)]
313        pub unsafe fn new() -> Retained<Self>;
314    );
315}
316
317extern_class!(
318    /// GKInvite represents an accepted game invite, it is used to create a GKMatchmakerViewController
319    ///
320    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkinvite?language=objc)
321    #[unsafe(super(NSObject))]
322    #[derive(Debug, PartialEq, Eq, Hash)]
323    pub struct GKInvite;
324);
325
326extern_conformance!(
327    unsafe impl NSObjectProtocol for GKInvite {}
328);
329
330impl GKInvite {
331    extern_methods!(
332        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
333        #[unsafe(method(sender))]
334        #[unsafe(method_family = none)]
335        pub unsafe fn sender(&self) -> Retained<GKPlayer>;
336
337        #[unsafe(method(isHosted))]
338        #[unsafe(method_family = none)]
339        pub unsafe fn isHosted(&self) -> bool;
340
341        /// player group from inviter's match request
342        #[unsafe(method(playerGroup))]
343        #[unsafe(method_family = none)]
344        pub unsafe fn playerGroup(&self) -> NSUInteger;
345
346        /// player attributes from inviter's match request
347        #[unsafe(method(playerAttributes))]
348        #[unsafe(method_family = none)]
349        pub unsafe fn playerAttributes(&self) -> u32;
350
351        /// * This property is obsolete. **
352        #[deprecated]
353        #[unsafe(method(inviter))]
354        #[unsafe(method_family = none)]
355        pub unsafe fn inviter(&self) -> Retained<NSString>;
356    );
357}
358
359/// Methods declared on superclass `NSObject`.
360impl GKInvite {
361    extern_methods!(
362        #[unsafe(method(init))]
363        #[unsafe(method_family = init)]
364        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
365
366        #[unsafe(method(new))]
367        #[unsafe(method_family = new)]
368        pub unsafe fn new() -> Retained<Self>;
369    );
370}
371
372extern_protocol!(
373    /// GKInviteEventListener uses the GKLocalPlayerListener mechanism on GKLocalPlayer to listen to the two kinds of invite events that a game must respond to
374    ///
375    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkinviteeventlistener?language=objc)
376    pub unsafe trait GKInviteEventListener {
377        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
378        /// player:didAcceptInvite: gets called when another player accepts the invite from the local player
379        #[optional]
380        #[unsafe(method(player:didAcceptInvite:))]
381        #[unsafe(method_family = none)]
382        unsafe fn player_didAcceptInvite(&self, player: &GKPlayer, invite: &GKInvite);
383
384        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
385        /// didRequestMatchWithRecipients: gets called when the player chooses to play with another player from Game Center and it launches the game to start matchmaking
386        #[optional]
387        #[unsafe(method(player:didRequestMatchWithRecipients:))]
388        #[unsafe(method_family = none)]
389        unsafe fn player_didRequestMatchWithRecipients(
390            &self,
391            player: &GKPlayer,
392            recipient_players: &NSArray<GKPlayer>,
393        );
394
395        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
396        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
397        #[deprecated]
398        #[optional]
399        #[unsafe(method(player:didRequestMatchWithPlayers:))]
400        #[unsafe(method_family = none)]
401        unsafe fn player_didRequestMatchWithPlayers(
402            &self,
403            player: &GKPlayer,
404            player_i_ds_to_invite: &NSArray<NSString>,
405        );
406    }
407);
408
409extern_class!(
410    /// [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchedplayers?language=objc)
411    #[unsafe(super(NSObject))]
412    #[derive(Debug, PartialEq, Eq, Hash)]
413    pub struct GKMatchedPlayers;
414);
415
416extern_conformance!(
417    unsafe impl NSObjectProtocol for GKMatchedPlayers {}
418);
419
420impl GKMatchedPlayers {
421    extern_methods!(
422        #[cfg(feature = "GKDefines")]
423        #[unsafe(method(properties))]
424        #[unsafe(method_family = none)]
425        pub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>;
426
427        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
428        #[unsafe(method(players))]
429        #[unsafe(method_family = none)]
430        pub unsafe fn players(&self) -> Retained<NSArray<GKPlayer>>;
431
432        #[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
433        #[unsafe(method(playerProperties))]
434        #[unsafe(method_family = none)]
435        pub unsafe fn playerProperties(
436            &self,
437        ) -> Option<Retained<NSDictionary<GKPlayer, GKMatchProperties>>>;
438    );
439}
440
441/// Methods declared on superclass `NSObject`.
442impl GKMatchedPlayers {
443    extern_methods!(
444        #[unsafe(method(init))]
445        #[unsafe(method_family = init)]
446        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
447
448        #[unsafe(method(new))]
449        #[unsafe(method_family = new)]
450        pub unsafe fn new() -> Retained<Self>;
451    );
452}
453
454extern_class!(
455    /// GKMatchmaker is a singleton object to manage match creation from invites and automatching.
456    ///
457    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gkmatchmaker?language=objc)
458    #[unsafe(super(NSObject))]
459    #[derive(Debug, PartialEq, Eq, Hash)]
460    pub struct GKMatchmaker;
461);
462
463extern_conformance!(
464    unsafe impl NSObjectProtocol for GKMatchmaker {}
465);
466
467impl GKMatchmaker {
468    extern_methods!(
469        /// The shared matchmaker
470        #[unsafe(method(sharedMatchmaker))]
471        #[unsafe(method_family = none)]
472        pub unsafe fn sharedMatchmaker() -> Retained<GKMatchmaker>;
473
474        #[cfg(all(feature = "GKMatch", feature = "block2"))]
475        /// Get a match for an accepted invite
476        /// Possible reasons for error:
477        /// 1. Communications failure
478        /// 2. Invite cancelled
479        #[unsafe(method(matchForInvite:completionHandler:))]
480        #[unsafe(method_family = none)]
481        pub unsafe fn matchForInvite_completionHandler(
482            &self,
483            invite: &GKInvite,
484            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut GKMatch, *mut NSError)>>,
485        );
486
487        #[cfg(all(feature = "GKMatch", feature = "block2"))]
488        /// Automatching or invites to find a peer-to-peer match for the specified request. Error will be nil on success:
489        /// Possible reasons for error:
490        /// 1. Communications failure
491        /// 2. Unauthenticated player
492        /// 3. Timeout
493        /// Note that the players property on the returned GKMatch instance will only contain connected players. It will initially be empty as players are connecting. Implement the GKMatchDelegate method match:player:didChangeConnectionState: to listen for updates to the GKMatch instance's players property.
494        #[unsafe(method(findMatchForRequest:withCompletionHandler:))]
495        #[unsafe(method_family = none)]
496        pub unsafe fn findMatchForRequest_withCompletionHandler(
497            &self,
498            request: &GKMatchRequest,
499            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut GKMatch, *mut NSError)>>,
500        );
501
502        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
503        /// Automatching or invites for host-client match request. This returns a list of player identifiers to be included in the match. Determination and communication with the host is not part of this API.
504        /// When inviting, no player identifiers will be returned. Player responses will be reported via the inviteeResponseHandler.
505        /// Possible reasons for error:
506        /// 1. Communications failure
507        /// 2. Unauthenticated player
508        /// 3. Timeout
509        #[unsafe(method(findPlayersForHostedRequest:withCompletionHandler:))]
510        #[unsafe(method_family = none)]
511        pub unsafe fn findPlayersForHostedRequest_withCompletionHandler(
512            &self,
513            request: &GKMatchRequest,
514            completion_handler: Option<
515                &block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
516            >,
517        );
518
519        #[cfg(feature = "block2")]
520        /// Automatching or invites for host-client rule-based match request.
521        #[unsafe(method(findMatchedPlayers:withCompletionHandler:))]
522        #[unsafe(method_family = none)]
523        pub unsafe fn findMatchedPlayers_withCompletionHandler(
524            &self,
525            request: &GKMatchRequest,
526            completion_handler: &block2::DynBlock<dyn Fn(*mut GKMatchedPlayers, *mut NSError)>,
527        );
528
529        #[cfg(all(feature = "GKMatch", feature = "block2"))]
530        /// Automatching or invites to add additional players to a peer-to-peer match for the specified request. Error will be nil on success:
531        /// Possible reasons for error:
532        /// 1. Communications failure
533        /// 2. Timeout
534        #[unsafe(method(addPlayersToMatch:matchRequest:completionHandler:))]
535        #[unsafe(method_family = none)]
536        pub unsafe fn addPlayersToMatch_matchRequest_completionHandler(
537            &self,
538            r#match: &GKMatch,
539            match_request: &GKMatchRequest,
540            completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
541        );
542
543        /// Cancel matchmaking and any pending invites
544        #[unsafe(method(cancel))]
545        #[unsafe(method_family = none)]
546        pub unsafe fn cancel(&self);
547
548        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
549        /// Cancel a pending invitation to a player
550        #[unsafe(method(cancelPendingInviteToPlayer:))]
551        #[unsafe(method_family = none)]
552        pub unsafe fn cancelPendingInviteToPlayer(&self, player: &GKPlayer);
553
554        #[cfg(feature = "GKMatch")]
555        /// Call this when finished with all programmatic P2P invites/matchmaking, for compatability with connected players using GKMatchmakerViewController.
556        #[unsafe(method(finishMatchmakingForMatch:))]
557        #[unsafe(method_family = none)]
558        pub unsafe fn finishMatchmakingForMatch(&self, r#match: &GKMatch);
559
560        #[cfg(feature = "block2")]
561        /// Query the server for recent activity in the specified player group. A larger value indicates that a given group has seen more recent activity. Error will be nil on success.
562        /// Possible reasons for error:
563        /// 1. Communications failure
564        #[unsafe(method(queryPlayerGroupActivity:withCompletionHandler:))]
565        #[unsafe(method_family = none)]
566        pub unsafe fn queryPlayerGroupActivity_withCompletionHandler(
567            &self,
568            player_group: NSUInteger,
569            completion_handler: Option<&block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>>,
570        );
571
572        #[cfg(feature = "block2")]
573        /// Query the server for recent activity for all the player groups of that game. Error will be nil on success.
574        /// Possible reasons for error:
575        /// 1. Communications failure
576        #[unsafe(method(queryActivityWithCompletionHandler:))]
577        #[unsafe(method_family = none)]
578        pub unsafe fn queryActivityWithCompletionHandler(
579            &self,
580            completion_handler: Option<&block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>>,
581        );
582
583        #[cfg(feature = "block2")]
584        /// Query the server for recent activity for the specified queue.
585        #[unsafe(method(queryQueueActivity:withCompletionHandler:))]
586        #[unsafe(method_family = none)]
587        pub unsafe fn queryQueueActivity_withCompletionHandler(
588            &self,
589            queue_name: &NSString,
590            completion_handler: Option<&block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>>,
591        );
592
593        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
594        /// Start browsing for nearby players that can be invited to a match. The reachableHandler will be called for each player found with a compatible game. It may be called more than once for the same player if that player ever becomes unreachable (e.g. moves out of range). You should call stopBrowsingForNearbyPlayers when finished browsing.
595        #[unsafe(method(startBrowsingForNearbyPlayersWithHandler:))]
596        #[unsafe(method_family = none)]
597        pub unsafe fn startBrowsingForNearbyPlayersWithHandler(
598            &self,
599            reachable_handler: Option<&block2::DynBlock<dyn Fn(NonNull<GKPlayer>, Bool)>>,
600        );
601
602        /// Stop browsing for nearby players.
603        #[unsafe(method(stopBrowsingForNearbyPlayers))]
604        #[unsafe(method_family = none)]
605        pub unsafe fn stopBrowsingForNearbyPlayers(&self);
606
607        #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
608        /// Activate  a  group activity by Game Center for your game, which allows people in the FaceTime call to join the local player's game. The handler will be called for each player who joined from the activity.
609        #[unsafe(method(startGroupActivityWithPlayerHandler:))]
610        #[unsafe(method_family = none)]
611        pub unsafe fn startGroupActivityWithPlayerHandler(
612            &self,
613            handler: &block2::DynBlock<dyn Fn(NonNull<GKPlayer>)>,
614        );
615
616        /// End the group activity created by Game Center for your game, which was activated by the local player.
617        #[unsafe(method(stopGroupActivity))]
618        #[unsafe(method_family = none)]
619        pub unsafe fn stopGroupActivity(&self);
620    );
621}
622
623/// Methods declared on superclass `NSObject`.
624impl GKMatchmaker {
625    extern_methods!(
626        #[unsafe(method(init))]
627        #[unsafe(method_family = init)]
628        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
629
630        #[unsafe(method(new))]
631        #[unsafe(method_family = new)]
632        pub unsafe fn new() -> Retained<Self>;
633    );
634}
635
636/// GKDeprecated.
637impl GKMatchmaker {
638    extern_methods!(
639        #[cfg(feature = "block2")]
640        /// # Safety
641        ///
642        /// - The returned block's argument 1 must be a valid pointer.
643        /// - The returned block's argument 2 must be a valid pointer or null.
644        #[deprecated = "Use the ``GKLocalPlayer/register(_:)`` method instead."]
645        #[unsafe(method(inviteHandler))]
646        #[unsafe(method_family = none)]
647        pub unsafe fn inviteHandler(
648            &self,
649        ) -> *mut block2::DynBlock<dyn Fn(NonNull<GKInvite>, *mut NSArray)>;
650
651        #[cfg(feature = "block2")]
652        /// Setter for [`inviteHandler`][Self::inviteHandler].
653        ///
654        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
655        #[deprecated = "Use the ``GKLocalPlayer/register(_:)`` method instead."]
656        #[unsafe(method(setInviteHandler:))]
657        #[unsafe(method_family = none)]
658        pub unsafe fn setInviteHandler(
659            &self,
660            invite_handler: Option<&block2::DynBlock<dyn Fn(NonNull<GKInvite>, *mut NSArray)>>,
661        );
662    );
663}
664
665/// Obsoleted.
666impl GKMatchmaker {
667    extern_methods!(
668        #[cfg(feature = "block2")]
669        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
670        #[deprecated]
671        #[unsafe(method(startBrowsingForNearbyPlayersWithReachableHandler:))]
672        #[unsafe(method_family = none)]
673        pub unsafe fn startBrowsingForNearbyPlayersWithReachableHandler(
674            &self,
675            reachable_handler: Option<&block2::DynBlock<dyn Fn(NonNull<NSString>, Bool)>>,
676        );
677
678        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
679        #[deprecated]
680        #[unsafe(method(cancelInviteToPlayer:))]
681        #[unsafe(method_family = none)]
682        pub unsafe fn cancelInviteToPlayer(&self, player_id: &NSString);
683
684        #[cfg(feature = "block2")]
685        /// * This method is obsolete. It will never be invoked and its implementation does nothing**
686        #[deprecated]
687        #[unsafe(method(findPlayersForHostedMatchRequest:withCompletionHandler:))]
688        #[unsafe(method_family = none)]
689        pub unsafe fn findPlayersForHostedMatchRequest_withCompletionHandler(
690            &self,
691            request: &GKMatchRequest,
692            completion_handler: Option<
693                &block2::DynBlock<dyn Fn(*mut NSArray<NSString>, *mut NSError)>,
694            >,
695        );
696    );
697}