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 GKConnectionState(pub NSInteger);
impl GKConnectionState {
#[doc(alias = "GKConnectionStateNotConnected")]
pub const NotConnected: Self = Self(0);
#[doc(alias = "GKConnectionStateConnected")]
pub const Connected: Self = Self(1);
}
unsafe impl Encode for GKConnectionState {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for GKConnectionState {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct GKTransportType(pub NSInteger);
impl GKTransportType {
#[doc(alias = "GKTransportTypeUnreliable")]
pub const Unreliable: Self = Self(0);
#[doc(alias = "GKTransportTypeReliable")]
pub const Reliable: Self = Self(1);
}
unsafe impl Encode for GKTransportType {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for GKTransportType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
pub struct GKGameSession;
);
extern_conformance!(
unsafe impl NSObjectProtocol for GKGameSession {}
);
impl GKGameSession {
extern_methods!(
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(identifier))]
#[unsafe(method_family = none)]
pub unsafe fn identifier(&self) -> Retained<NSString>;
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(title))]
#[unsafe(method_family = none)]
pub unsafe fn title(&self) -> Retained<NSString>;
#[cfg(all(feature = "GKBasePlayer", feature = "GKCloudPlayer"))]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(owner))]
#[unsafe(method_family = none)]
pub unsafe fn owner(&self) -> Retained<GKCloudPlayer>;
#[cfg(all(feature = "GKBasePlayer", feature = "GKCloudPlayer"))]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(players))]
#[unsafe(method_family = none)]
pub unsafe fn players(&self) -> Retained<NSArray<GKCloudPlayer>>;
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(lastModifiedDate))]
#[unsafe(method_family = none)]
pub unsafe fn lastModifiedDate(&self) -> Retained<NSDate>;
#[cfg(all(feature = "GKBasePlayer", feature = "GKCloudPlayer"))]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(lastModifiedPlayer))]
#[unsafe(method_family = none)]
pub unsafe fn lastModifiedPlayer(&self) -> Retained<GKCloudPlayer>;
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(maxNumberOfConnectedPlayers))]
#[unsafe(method_family = none)]
pub unsafe fn maxNumberOfConnectedPlayers(&self) -> NSInteger;
#[cfg(all(feature = "GKBasePlayer", feature = "GKCloudPlayer"))]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(badgedPlayers))]
#[unsafe(method_family = none)]
pub unsafe fn badgedPlayers(&self) -> Retained<NSArray<GKCloudPlayer>>;
#[cfg(feature = "block2")]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(createSessionInContainer:withTitle:maxConnectedPlayers:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn createSessionInContainer_withTitle_maxConnectedPlayers_completionHandler(
container_name: Option<&NSString>,
title: &NSString,
max_players: NSInteger,
completion_handler: &block2::DynBlock<dyn Fn(*mut GKGameSession, *mut NSError)>,
);
#[cfg(feature = "block2")]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(loadSessionsInContainer:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadSessionsInContainer_completionHandler(
container_name: Option<&NSString>,
completion_handler: &block2::DynBlock<
dyn Fn(*mut NSArray<GKGameSession>, *mut NSError),
>,
);
#[cfg(feature = "block2")]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(loadSessionWithIdentifier:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadSessionWithIdentifier_completionHandler(
identifier: &NSString,
completion_handler: &block2::DynBlock<dyn Fn(*mut GKGameSession, *mut NSError)>,
);
#[cfg(feature = "block2")]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(removeSessionWithIdentifier:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn removeSessionWithIdentifier_completionHandler(
identifier: &NSString,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
#[cfg(feature = "block2")]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(getShareURLWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn getShareURLWithCompletionHandler(
&self,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSURL, *mut NSError)>,
);
#[cfg(feature = "block2")]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(loadDataWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn loadDataWithCompletionHandler(
&self,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
);
#[cfg(feature = "block2")]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(saveData:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn saveData_completionHandler(
&self,
data: &NSData,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSData, *mut NSError)>,
);
#[cfg(feature = "block2")]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(setConnectionState:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn setConnectionState_completionHandler(
&self,
state: GKConnectionState,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
#[cfg(all(feature = "GKBasePlayer", feature = "GKCloudPlayer"))]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(playersWithConnectionState:))]
#[unsafe(method_family = none)]
pub unsafe fn playersWithConnectionState(
&self,
state: GKConnectionState,
) -> Retained<NSArray<GKCloudPlayer>>;
#[cfg(feature = "block2")]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(sendData:withTransportType:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn sendData_withTransportType_completionHandler(
&self,
data: &NSData,
transport: GKTransportType,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
#[cfg(all(
feature = "GKBasePlayer",
feature = "GKCloudPlayer",
feature = "block2"
))]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(sendMessageWithLocalizedFormatKey:arguments:data:toPlayers:badgePlayers:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn sendMessageWithLocalizedFormatKey_arguments_data_toPlayers_badgePlayers_completionHandler(
&self,
key: &NSString,
arguments: &NSArray<NSString>,
data: Option<&NSData>,
players: &NSArray<GKCloudPlayer>,
badge_players: bool,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
#[cfg(all(
feature = "GKBasePlayer",
feature = "GKCloudPlayer",
feature = "block2"
))]
#[deprecated = "For real-time matches, use GKMatchmakerViewController. For turn-based matches, use GKTurnBasedMatchmakerViewController."]
#[unsafe(method(clearBadgeForPlayers:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn clearBadgeForPlayers_completionHandler(
&self,
players: &NSArray<GKCloudPlayer>,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
);
}
impl GKGameSession {
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>;
);
}