use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;
use crate::*;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKInviteRecipientResponse(pub NSInteger);
impl GKInviteRecipientResponse {
#[doc(alias = "GKInviteRecipientResponseAccepted")]
pub const Accepted: Self = Self(0);
#[doc(alias = "GKInviteRecipientResponseDeclined")]
pub const Declined: Self = Self(1);
#[doc(alias = "GKInviteRecipientResponseFailed")]
pub const Failed: Self = Self(2);
#[doc(alias = "GKInviteRecipientResponseIncompatible")]
pub const Incompatible: Self = Self(3);
#[doc(alias = "GKInviteRecipientResponseUnableToConnect")]
pub const UnableToConnect: Self = Self(4);
#[doc(alias = "GKInviteRecipientResponseNoAnswer")]
pub const NoAnswer: Self = Self(5);
#[deprecated]
pub const GKInviteeResponseAccepted: Self = Self(GKInviteRecipientResponse::Accepted.0);
#[deprecated]
pub const GKInviteeResponseDeclined: Self = Self(GKInviteRecipientResponse::Declined.0);
#[deprecated]
pub const GKInviteeResponseFailed: Self = Self(GKInviteRecipientResponse::Failed.0);
#[deprecated]
pub const GKInviteeResponseIncompatible: Self = Self(GKInviteRecipientResponse::Incompatible.0);
#[deprecated]
pub const GKInviteeResponseUnableToConnect: Self =
Self(GKInviteRecipientResponse::UnableToConnect.0);
#[deprecated]
pub const GKInviteeResponseNoAnswer: Self = Self(GKInviteRecipientResponse::NoAnswer.0);
}
unsafe impl Encode for GKInviteRecipientResponse {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for GKInviteRecipientResponse {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[deprecated]
pub type GKInviteeResponse = GKInviteRecipientResponse;
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKMatchType(pub NSUInteger);
impl GKMatchType {
#[doc(alias = "GKMatchTypePeerToPeer")]
pub const PeerToPeer: Self = Self(0);
#[doc(alias = "GKMatchTypeHosted")]
pub const Hosted: Self = Self(1);
#[doc(alias = "GKMatchTypeTurnBased")]
pub const TurnBased: Self = Self(2);
}
unsafe impl Encode for GKMatchType {
const ENCODING: Encoding = NSUInteger::ENCODING;
}
unsafe impl RefEncode for GKMatchType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GKMatchRequest;
);
extern_conformance!(
unsafe impl NSObjectProtocol for GKMatchRequest {}
);
impl GKMatchRequest {
extern_methods!(
#[unsafe(method(minPlayers))]
#[unsafe(method_family = none)]
pub unsafe fn minPlayers(&self) -> NSUInteger;
#[unsafe(method(setMinPlayers:))]
#[unsafe(method_family = none)]
pub unsafe fn setMinPlayers(&self, min_players: NSUInteger);
#[unsafe(method(maxPlayers))]
#[unsafe(method_family = none)]
pub unsafe fn maxPlayers(&self) -> NSUInteger;
#[unsafe(method(setMaxPlayers:))]
#[unsafe(method_family = none)]
pub unsafe fn setMaxPlayers(&self, max_players: NSUInteger);
#[unsafe(method(playerGroup))]
#[unsafe(method_family = none)]
pub unsafe fn playerGroup(&self) -> NSUInteger;
#[unsafe(method(setPlayerGroup:))]
#[unsafe(method_family = none)]
pub unsafe fn setPlayerGroup(&self, player_group: NSUInteger);
#[unsafe(method(playerAttributes))]
#[unsafe(method_family = none)]
pub unsafe fn playerAttributes(&self) -> u32;
#[unsafe(method(setPlayerAttributes:))]
#[unsafe(method_family = none)]
pub unsafe fn setPlayerAttributes(&self, player_attributes: u32);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
#[unsafe(method(recipients))]
#[unsafe(method_family = none)]
pub unsafe fn recipients(&self) -> Option<Retained<NSArray<GKPlayer>>>;
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
#[unsafe(method(setRecipients:))]
#[unsafe(method_family = none)]
pub unsafe fn setRecipients(&self, recipients: Option<&NSArray<GKPlayer>>);
#[unsafe(method(inviteMessage))]
#[unsafe(method_family = none)]
pub unsafe fn inviteMessage(&self) -> Option<Retained<NSString>>;
#[unsafe(method(setInviteMessage:))]
#[unsafe(method_family = none)]
pub unsafe fn setInviteMessage(&self, invite_message: Option<&NSString>);
#[unsafe(method(defaultNumberOfPlayers))]
#[unsafe(method_family = none)]
pub unsafe fn defaultNumberOfPlayers(&self) -> NSUInteger;
#[unsafe(method(setDefaultNumberOfPlayers:))]
#[unsafe(method_family = none)]
pub unsafe fn setDefaultNumberOfPlayers(&self, default_number_of_players: NSUInteger);
#[deprecated]
#[unsafe(method(restrictToAutomatch))]
#[unsafe(method_family = none)]
pub unsafe fn restrictToAutomatch(&self) -> bool;
#[deprecated]
#[unsafe(method(setRestrictToAutomatch:))]
#[unsafe(method_family = none)]
pub unsafe fn setRestrictToAutomatch(&self, restrict_to_automatch: bool);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
#[unsafe(method(recipientResponseHandler))]
#[unsafe(method_family = none)]
pub unsafe fn recipientResponseHandler(
&self,
) -> *mut block2::DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>;
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
#[unsafe(method(setRecipientResponseHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setRecipientResponseHandler(
&self,
recipient_response_handler: Option<
&block2::DynBlock<dyn Fn(NonNull<GKPlayer>, GKInviteRecipientResponse)>,
>,
);
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(inviteeResponseHandler))]
#[unsafe(method_family = none)]
pub unsafe fn inviteeResponseHandler(
&self,
) -> *mut block2::DynBlock<dyn Fn(NonNull<NSString>, GKInviteeResponse)>;
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(setInviteeResponseHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setInviteeResponseHandler(
&self,
invitee_response_handler: Option<
&block2::DynBlock<dyn Fn(NonNull<NSString>, GKInviteeResponse)>,
>,
);
#[unsafe(method(maxPlayersAllowedForMatchOfType:))]
#[unsafe(method_family = none)]
pub unsafe fn maxPlayersAllowedForMatchOfType(match_type: GKMatchType) -> NSUInteger;
#[deprecated]
#[unsafe(method(playersToInvite))]
#[unsafe(method_family = none)]
pub unsafe fn playersToInvite(&self) -> Option<Retained<NSArray<NSString>>>;
#[deprecated]
#[unsafe(method(setPlayersToInvite:))]
#[unsafe(method_family = none)]
pub unsafe fn setPlayersToInvite(&self, players_to_invite: Option<&NSArray<NSString>>);
#[unsafe(method(queueName))]
#[unsafe(method_family = none)]
pub unsafe fn queueName(&self) -> Option<Retained<NSString>>;
#[unsafe(method(setQueueName:))]
#[unsafe(method_family = none)]
pub unsafe fn setQueueName(&self, queue_name: Option<&NSString>);
#[cfg(feature = "GKDefines")]
#[unsafe(method(properties))]
#[unsafe(method_family = none)]
pub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>;
#[cfg(feature = "GKDefines")]
#[unsafe(method(setProperties:))]
#[unsafe(method_family = none)]
pub unsafe fn setProperties(&self, properties: Option<&GKMatchProperties>);
#[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
#[unsafe(method(recipientProperties))]
#[unsafe(method_family = none)]
pub unsafe fn recipientProperties(
&self,
) -> Option<Retained<NSDictionary<GKPlayer, GKMatchProperties>>>;
#[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
#[unsafe(method(setRecipientProperties:))]
#[unsafe(method_family = none)]
pub unsafe fn setRecipientProperties(
&self,
recipient_properties: Option<&NSDictionary<GKPlayer, GKMatchProperties>>,
);
);
}
impl GKMatchRequest {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GKInvite;
);
extern_conformance!(
unsafe impl NSObjectProtocol for GKInvite {}
);
impl GKInvite {
extern_methods!(
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
#[unsafe(method(sender))]
#[unsafe(method_family = none)]
pub unsafe fn sender(&self) -> Retained<GKPlayer>;
#[unsafe(method(isHosted))]
#[unsafe(method_family = none)]
pub unsafe fn isHosted(&self) -> bool;
#[unsafe(method(playerGroup))]
#[unsafe(method_family = none)]
pub unsafe fn playerGroup(&self) -> NSUInteger;
#[unsafe(method(playerAttributes))]
#[unsafe(method_family = none)]
pub unsafe fn playerAttributes(&self) -> u32;
#[deprecated]
#[unsafe(method(inviter))]
#[unsafe(method_family = none)]
pub unsafe fn inviter(&self) -> Retained<NSString>;
);
}
impl GKInvite {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_protocol!(
pub unsafe trait GKInviteEventListener {
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
#[optional]
#[unsafe(method(player:didAcceptInvite:))]
#[unsafe(method_family = none)]
unsafe fn player_didAcceptInvite(&self, player: &GKPlayer, invite: &GKInvite);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
#[optional]
#[unsafe(method(player:didRequestMatchWithRecipients:))]
#[unsafe(method_family = none)]
unsafe fn player_didRequestMatchWithRecipients(
&self,
player: &GKPlayer,
recipient_players: &NSArray<GKPlayer>,
);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
#[deprecated]
#[optional]
#[unsafe(method(player:didRequestMatchWithPlayers:))]
#[unsafe(method_family = none)]
unsafe fn player_didRequestMatchWithPlayers(
&self,
player: &GKPlayer,
player_i_ds_to_invite: &NSArray<NSString>,
);
}
);
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GKMatchedPlayers;
);
extern_conformance!(
unsafe impl NSObjectProtocol for GKMatchedPlayers {}
);
impl GKMatchedPlayers {
extern_methods!(
#[cfg(feature = "GKDefines")]
#[unsafe(method(properties))]
#[unsafe(method_family = none)]
pub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>;
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
#[unsafe(method(players))]
#[unsafe(method_family = none)]
pub unsafe fn players(&self) -> Retained<NSArray<GKPlayer>>;
#[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
#[unsafe(method(playerProperties))]
#[unsafe(method_family = none)]
pub unsafe fn playerProperties(
&self,
) -> Option<Retained<NSDictionary<GKPlayer, GKMatchProperties>>>;
);
}
impl GKMatchedPlayers {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct GKMatchmaker;
);
extern_conformance!(
unsafe impl NSObjectProtocol for GKMatchmaker {}
);
impl GKMatchmaker {
extern_methods!(
#[unsafe(method(sharedMatchmaker))]
#[unsafe(method_family = none)]
pub unsafe fn sharedMatchmaker() -> Retained<GKMatchmaker>;
#[cfg(all(feature = "GKMatch", feature = "block2"))]
#[unsafe(method(matchForInvite:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn matchForInvite_completionHandler(
&self,
invite: &GKInvite,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut GKMatch, *mut NSError)>>,
);
#[cfg(all(feature = "GKMatch", feature = "block2"))]
#[unsafe(method(findMatchForRequest:withCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn findMatchForRequest_withCompletionHandler(
&self,
request: &GKMatchRequest,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut GKMatch, *mut NSError)>>,
);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
#[unsafe(method(findPlayersForHostedRequest:withCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn findPlayersForHostedRequest_withCompletionHandler(
&self,
request: &GKMatchRequest,
completion_handler: Option<
&block2::DynBlock<dyn Fn(*mut NSArray<GKPlayer>, *mut NSError)>,
>,
);
#[cfg(feature = "block2")]
#[unsafe(method(findMatchedPlayers:withCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn findMatchedPlayers_withCompletionHandler(
&self,
request: &GKMatchRequest,
completion_handler: &block2::DynBlock<dyn Fn(*mut GKMatchedPlayers, *mut NSError)>,
);
#[cfg(all(feature = "GKMatch", feature = "block2"))]
#[unsafe(method(addPlayersToMatch:matchRequest:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn addPlayersToMatch_matchRequest_completionHandler(
&self,
r#match: &GKMatch,
match_request: &GKMatchRequest,
completion_handler: Option<&block2::DynBlock<dyn Fn(*mut NSError)>>,
);
#[unsafe(method(cancel))]
#[unsafe(method_family = none)]
pub unsafe fn cancel(&self);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
#[unsafe(method(cancelPendingInviteToPlayer:))]
#[unsafe(method_family = none)]
pub unsafe fn cancelPendingInviteToPlayer(&self, player: &GKPlayer);
#[cfg(feature = "GKMatch")]
#[unsafe(method(finishMatchmakingForMatch:))]
#[unsafe(method_family = none)]
pub unsafe fn finishMatchmakingForMatch(&self, r#match: &GKMatch);
#[cfg(feature = "block2")]
#[unsafe(method(queryPlayerGroupActivity:withCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn queryPlayerGroupActivity_withCompletionHandler(
&self,
player_group: NSUInteger,
completion_handler: Option<&block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>>,
);
#[cfg(feature = "block2")]
#[unsafe(method(queryActivityWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn queryActivityWithCompletionHandler(
&self,
completion_handler: Option<&block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>>,
);
#[cfg(feature = "block2")]
#[unsafe(method(queryQueueActivity:withCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn queryQueueActivity_withCompletionHandler(
&self,
queue_name: &NSString,
completion_handler: Option<&block2::DynBlock<dyn Fn(NSInteger, *mut NSError)>>,
);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
#[unsafe(method(startBrowsingForNearbyPlayersWithHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn startBrowsingForNearbyPlayersWithHandler(
&self,
reachable_handler: Option<&block2::DynBlock<dyn Fn(NonNull<GKPlayer>, Bool)>>,
);
#[unsafe(method(stopBrowsingForNearbyPlayers))]
#[unsafe(method_family = none)]
pub unsafe fn stopBrowsingForNearbyPlayers(&self);
#[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
#[unsafe(method(startGroupActivityWithPlayerHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn startGroupActivityWithPlayerHandler(
&self,
handler: &block2::DynBlock<dyn Fn(NonNull<GKPlayer>)>,
);
#[unsafe(method(stopGroupActivity))]
#[unsafe(method_family = none)]
pub unsafe fn stopGroupActivity(&self);
);
}
impl GKMatchmaker {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
impl GKMatchmaker {
extern_methods!(
#[cfg(feature = "block2")]
#[deprecated = "Use the ``GKLocalPlayer/register(_:)`` method instead."]
#[unsafe(method(inviteHandler))]
#[unsafe(method_family = none)]
pub unsafe fn inviteHandler(
&self,
) -> *mut block2::DynBlock<dyn Fn(NonNull<GKInvite>, *mut NSArray)>;
#[cfg(feature = "block2")]
#[deprecated = "Use the ``GKLocalPlayer/register(_:)`` method instead."]
#[unsafe(method(setInviteHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setInviteHandler(
&self,
invite_handler: Option<&block2::DynBlock<dyn Fn(NonNull<GKInvite>, *mut NSArray)>>,
);
);
}
impl GKMatchmaker {
extern_methods!(
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(startBrowsingForNearbyPlayersWithReachableHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn startBrowsingForNearbyPlayersWithReachableHandler(
&self,
reachable_handler: Option<&block2::DynBlock<dyn Fn(NonNull<NSString>, Bool)>>,
);
#[deprecated]
#[unsafe(method(cancelInviteToPlayer:))]
#[unsafe(method_family = none)]
pub unsafe fn cancelInviteToPlayer(&self, player_id: &NSString);
#[cfg(feature = "block2")]
#[deprecated]
#[unsafe(method(findPlayersForHostedMatchRequest:withCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn findPlayersForHostedMatchRequest_withCompletionHandler(
&self,
request: &GKMatchRequest,
completion_handler: Option<
&block2::DynBlock<dyn Fn(*mut NSArray<NSString>, *mut NSError)>,
>,
);
);
}