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