objc2_game_kit/generated/
GKSession.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
10extern_class!(
11    /// The GKSession handles networking between peers for a game, which includes establishing and maintaining connections over a game network, and network data transport.
12    ///
13    /// This a not a Game Center feature. To support Game Center and online play, see GKMatch.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/gamekit/gksession?language=objc)
16    #[unsafe(super(NSObject))]
17    #[derive(Debug, PartialEq, Eq, Hash)]
18    #[deprecated]
19    pub struct GKSession;
20);
21
22extern_conformance!(
23    unsafe impl NSObjectProtocol for GKSession {}
24);
25
26impl GKSession {
27    extern_methods!(
28        #[cfg(feature = "GKPublicConstants")]
29        /// # Safety
30        ///
31        /// - `session_id` might not allow `None`.
32        /// - `name` might not allow `None`.
33        #[deprecated = "No longer available"]
34        #[unsafe(method(initWithSessionID:displayName:sessionMode:))]
35        #[unsafe(method_family = init)]
36        pub unsafe fn initWithSessionID_displayName_sessionMode(
37            this: Allocated<Self>,
38            session_id: Option<&NSString>,
39            name: Option<&NSString>,
40            mode: GKSessionMode,
41        ) -> Option<Retained<Self>>;
42
43        #[cfg(feature = "GKPublicProtocols")]
44        #[deprecated = "No longer supported."]
45        #[unsafe(method(delegate))]
46        #[unsafe(method_family = none)]
47        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn GKSessionDelegate>>>;
48
49        #[cfg(feature = "GKPublicProtocols")]
50        /// Setter for [`delegate`][Self::delegate].
51        ///
52        /// This is a [weak property][objc2::topics::weak_property].
53        ///
54        /// # Safety
55        ///
56        /// `delegate` might not allow `None`.
57        #[deprecated = "No longer supported."]
58        #[unsafe(method(setDelegate:))]
59        #[unsafe(method_family = none)]
60        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn GKSessionDelegate>>);
61
62        #[deprecated]
63        #[unsafe(method(sessionID))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn sessionID(&self) -> Option<Retained<NSString>>;
66
67        #[deprecated]
68        #[unsafe(method(displayName))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn displayName(&self) -> Option<Retained<NSString>>;
71
72        #[cfg(feature = "GKPublicConstants")]
73        #[deprecated = "No longer supported."]
74        #[unsafe(method(sessionMode))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn sessionMode(&self) -> GKSessionMode;
77
78        #[deprecated]
79        #[unsafe(method(peerID))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn peerID(&self) -> Option<Retained<NSString>>;
82
83        /// Toggle availability on the network based on session mode and search criteria.  Delegate will get a callback -session:didReceiveConnectionRequestFromPeer: when a peer attempts a connection.
84        #[deprecated]
85        #[unsafe(method(isAvailable))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn isAvailable(&self) -> bool;
88
89        /// Setter for [`isAvailable`][Self::isAvailable].
90        #[deprecated]
91        #[unsafe(method(setAvailable:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn setAvailable(&self, available: bool);
94
95        /// The timeout for disconnecting a peer if it appears that the peer has lost connection to the game network
96        #[deprecated]
97        #[unsafe(method(disconnectTimeout))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn disconnectTimeout(&self) -> NSTimeInterval;
100
101        /// Setter for [`disconnectTimeout`][Self::disconnectTimeout].
102        #[deprecated]
103        #[unsafe(method(setDisconnectTimeout:))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn setDisconnectTimeout(&self, disconnect_timeout: NSTimeInterval);
106
107        /// Return the application chosen name of a specific peer
108        ///
109        /// # Safety
110        ///
111        /// `peer_id` might not allow `None`.
112        #[deprecated]
113        #[unsafe(method(displayNameForPeer:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn displayNameForPeer(
116            &self,
117            peer_id: Option<&NSString>,
118        ) -> Option<Retained<NSString>>;
119
120        #[cfg(feature = "GKPublicConstants")]
121        /// Asynchronous delivery of data to one or more peers.  Returns YES if delivery started, NO if unable to start sending, and error will be set.  Delivery will be reliable or unreliable as set by mode.
122        ///
123        /// # Safety
124        ///
125        /// - `data` might not allow `None`.
126        /// - `peers` generic should be of the correct type.
127        /// - `peers` might not allow `None`.
128        /// - `error` might not allow `None`.
129        #[deprecated = "No longer supported."]
130        #[unsafe(method(sendData:toPeers:withDataMode:error:))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn sendData_toPeers_withDataMode_error(
133            &self,
134            data: Option<&NSData>,
135            peers: Option<&NSArray>,
136            mode: GKSendDataMode,
137            error: Option<&mut Option<Retained<NSError>>>,
138        ) -> bool;
139
140        #[cfg(feature = "GKPublicConstants")]
141        /// Asynchronous delivery to all peers.  Returns YES if delivery started, NO if unable to start sending, and error will be set.  Delivery will be reliable or unreliable as set by mode.
142        ///
143        /// # Safety
144        ///
145        /// - `data` might not allow `None`.
146        /// - `error` might not allow `None`.
147        #[deprecated = "No longer supported."]
148        #[unsafe(method(sendDataToAllPeers:withDataMode:error:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn sendDataToAllPeers_withDataMode_error(
151            &self,
152            data: Option<&NSData>,
153            mode: GKSendDataMode,
154            error: Option<&mut Option<Retained<NSError>>>,
155        ) -> bool;
156
157        /// Set the handler to receive data sent from remote peers.
158        ///
159        /// # Safety
160        ///
161        /// - `handler` should be of the correct type.
162        /// - `handler` might not allow `None`.
163        /// - `context` must be a valid pointer.
164        #[deprecated]
165        #[unsafe(method(setDataReceiveHandler:withContext:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn setDataReceiveHandler_withContext(
168            &self,
169            handler: Option<&AnyObject>,
170            context: *mut c_void,
171        );
172
173        /// Attempt connection to a remote peer.  Remote peer gets a callback to -session:didReceiveConnectionRequestFromPeer:.
174        ///
175        /// Success results in a call to delegate -session:peer:didChangeState: GKPeerStateConnected
176        /// Failure results in a call to delegate -session:connectionWithPeerFailed:withError:
177        ///
178        /// # Safety
179        ///
180        /// `peer_id` might not allow `None`.
181        #[deprecated]
182        #[unsafe(method(connectToPeer:withTimeout:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn connectToPeer_withTimeout(
185            &self,
186            peer_id: Option<&NSString>,
187            timeout: NSTimeInterval,
188        );
189
190        /// # Safety
191        ///
192        /// `peer_id` might not allow `None`.
193        #[deprecated]
194        #[unsafe(method(cancelConnectToPeer:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn cancelConnectToPeer(&self, peer_id: Option<&NSString>);
197
198        /// Methods to accept or deny a prior connection request from -session:didReceiveConnectionRequestFromPeer:
199        ///
200        /// # Safety
201        ///
202        /// - `peer_id` might not allow `None`.
203        /// - `error` might not allow `None`.
204        #[deprecated]
205        #[unsafe(method(acceptConnectionFromPeer:error:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn acceptConnectionFromPeer_error(
208            &self,
209            peer_id: Option<&NSString>,
210            error: Option<&mut Option<Retained<NSError>>>,
211        ) -> bool;
212
213        /// # Safety
214        ///
215        /// `peer_id` might not allow `None`.
216        #[deprecated]
217        #[unsafe(method(denyConnectionFromPeer:))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn denyConnectionFromPeer(&self, peer_id: Option<&NSString>);
220
221        /// Disconnect a peer from the session (the peer gets disconnected from all connected peers).
222        ///
223        /// # Safety
224        ///
225        /// `peer_id` might not allow `None`.
226        #[deprecated]
227        #[unsafe(method(disconnectPeerFromAllPeers:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn disconnectPeerFromAllPeers(&self, peer_id: Option<&NSString>);
230
231        /// Disconnect local peer
232        #[deprecated]
233        #[unsafe(method(disconnectFromAllPeers))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn disconnectFromAllPeers(&self);
236
237        #[cfg(feature = "GKPublicConstants")]
238        /// Returns peers according to connection state
239        #[deprecated = "No longer supported."]
240        #[unsafe(method(peersWithConnectionState:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn peersWithConnectionState(
243            &self,
244            state: GKPeerConnectionState,
245        ) -> Option<Retained<NSArray>>;
246    );
247}
248
249/// Methods declared on superclass `NSObject`.
250impl GKSession {
251    extern_methods!(
252        #[unsafe(method(init))]
253        #[unsafe(method_family = init)]
254        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
255
256        #[unsafe(method(new))]
257        #[unsafe(method_family = new)]
258        pub unsafe fn new() -> Retained<Self>;
259    );
260}