objc2_game_kit/generated/
GKMatchmaker.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[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#[deprecated]
55pub type GKInviteeResponse = GKInviteRecipientResponse;
56
57#[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 #[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 #[unsafe(method(minPlayers))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn minPlayers(&self) -> NSUInteger;
98
99 #[unsafe(method(setMinPlayers:))]
101 #[unsafe(method_family = none)]
102 pub unsafe fn setMinPlayers(&self, min_players: NSUInteger);
103
104 #[unsafe(method(maxPlayers))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn maxPlayers(&self) -> NSUInteger;
108
109 #[unsafe(method(setMaxPlayers:))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn setMaxPlayers(&self, max_players: NSUInteger);
113
114 #[unsafe(method(playerGroup))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn playerGroup(&self) -> NSUInteger;
118
119 #[unsafe(method(setPlayerGroup:))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn setPlayerGroup(&self, player_group: NSUInteger);
123
124 #[unsafe(method(playerAttributes))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn playerAttributes(&self) -> u32;
128
129 #[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 #[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 #[unsafe(method(setRecipients:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<GKPlayer>>);
145
146 #[unsafe(method(inviteMessage))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn inviteMessage(&self) -> Option<Retained<NSString>>;
151
152 #[unsafe(method(setInviteMessage:))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn setInviteMessage(&self, invite_message: Option<&NSString>);
158
159 #[unsafe(method(defaultNumberOfPlayers))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn defaultNumberOfPlayers(&self) -> NSUInteger;
163
164 #[unsafe(method(setDefaultNumberOfPlayers:))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn setDefaultNumberOfPlayers(&self, default_number_of_players: NSUInteger);
168
169 #[deprecated]
173 #[unsafe(method(restrictToAutomatch))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn restrictToAutomatch(&self) -> bool;
176
177 #[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 #[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 #[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 #[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 #[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 #[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 #[deprecated]
245 #[unsafe(method(setPlayersToInvite:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn setPlayersToInvite(&self, players_to_invite: Option<&NSArray<NSString>>);
248
249 #[unsafe(method(queueName))]
251 #[unsafe(method_family = none)]
252 pub unsafe fn queueName(&self) -> Option<Retained<NSString>>;
253
254 #[unsafe(method(setQueueName:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn setQueueName(&self, queue_name: Option<&NSString>);
260
261 #[cfg(feature = "GKDefines")]
262 #[unsafe(method(properties))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>;
266
267 #[cfg(feature = "GKDefines")]
268 #[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 #[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 #[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
304impl 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 #[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 #[unsafe(method(playerGroup))]
343 #[unsafe(method_family = none)]
344 pub unsafe fn playerGroup(&self) -> NSUInteger;
345
346 #[unsafe(method(playerAttributes))]
348 #[unsafe(method_family = none)]
349 pub unsafe fn playerAttributes(&self) -> u32;
350
351 #[deprecated]
353 #[unsafe(method(inviter))]
354 #[unsafe(method_family = none)]
355 pub unsafe fn inviter(&self) -> Retained<NSString>;
356 );
357}
358
359impl 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 pub unsafe trait GKInviteEventListener {
377 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
378 #[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 #[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 #[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 #[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
441impl 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 #[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 #[unsafe(method(sharedMatchmaker))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn sharedMatchmaker() -> Retained<GKMatchmaker>;
473
474 #[cfg(all(feature = "GKMatch", feature = "block2"))]
475 #[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 #[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 #[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 #[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 #[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 #[unsafe(method(cancel))]
545 #[unsafe(method_family = none)]
546 pub unsafe fn cancel(&self);
547
548 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
549 #[unsafe(method(cancelPendingInviteToPlayer:))]
551 #[unsafe(method_family = none)]
552 pub unsafe fn cancelPendingInviteToPlayer(&self, player: &GKPlayer);
553
554 #[cfg(feature = "GKMatch")]
555 #[unsafe(method(finishMatchmakingForMatch:))]
557 #[unsafe(method_family = none)]
558 pub unsafe fn finishMatchmakingForMatch(&self, r#match: &GKMatch);
559
560 #[cfg(feature = "block2")]
561 #[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 #[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 #[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 #[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 #[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 #[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 #[unsafe(method(stopGroupActivity))]
618 #[unsafe(method_family = none)]
619 pub unsafe fn stopGroupActivity(&self);
620 );
621}
622
623impl 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
636impl GKMatchmaker {
638 extern_methods!(
639 #[cfg(feature = "block2")]
640 #[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 #[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
665impl GKMatchmaker {
667 extern_methods!(
668 #[cfg(feature = "block2")]
669 #[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 #[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 #[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}