objc2_game_kit/generated/
GKMatch.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct GKMatchSendDataMode(pub NSInteger);
15impl GKMatchSendDataMode {
16 #[doc(alias = "GKMatchSendDataReliable")]
17 pub const Reliable: Self = Self(0);
18 #[doc(alias = "GKMatchSendDataUnreliable")]
20 pub const Unreliable: Self = Self(1);
21}
22
23unsafe impl Encode for GKMatchSendDataMode {
24 const ENCODING: Encoding = NSInteger::ENCODING;
25}
26
27unsafe impl RefEncode for GKMatchSendDataMode {
28 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
29}
30
31#[repr(transparent)]
34#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
35pub struct GKPlayerConnectionState(pub NSInteger);
36impl GKPlayerConnectionState {
37 #[doc(alias = "GKPlayerStateUnknown")]
38 pub const StateUnknown: Self = Self(0);
39 #[doc(alias = "GKPlayerStateConnected")]
41 pub const StateConnected: Self = Self(1);
42 #[doc(alias = "GKPlayerStateDisconnected")]
44 pub const StateDisconnected: Self = Self(2);
45}
46
47unsafe impl Encode for GKPlayerConnectionState {
48 const ENCODING: Encoding = NSInteger::ENCODING;
49}
50
51unsafe impl RefEncode for GKPlayerConnectionState {
52 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
53}
54
55extern_class!(
56 #[unsafe(super(NSObject))]
60 #[derive(Debug, PartialEq, Eq, Hash)]
61 pub struct GKMatch;
62);
63
64extern_conformance!(
65 unsafe impl NSObjectProtocol for GKMatch {}
66);
67
68impl GKMatch {
69 extern_methods!(
70 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
71 #[unsafe(method(players))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn players(&self) -> Retained<NSArray<GKPlayer>>;
74
75 #[unsafe(method(delegate))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn GKMatchDelegate>>>;
79
80 #[unsafe(method(setDelegate:))]
84 #[unsafe(method_family = none)]
85 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn GKMatchDelegate>>);
86
87 #[unsafe(method(expectedPlayerCount))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn expectedPlayerCount(&self) -> NSUInteger;
90
91 #[cfg(feature = "GKDefines")]
92 #[unsafe(method(properties))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn properties(&self) -> Option<Retained<GKMatchProperties>>;
95
96 #[cfg(all(feature = "GKBasePlayer", feature = "GKDefines", feature = "GKPlayer"))]
97 #[unsafe(method(playerProperties))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn playerProperties(
100 &self,
101 ) -> Option<Retained<NSDictionary<GKPlayer, GKMatchProperties>>>;
102
103 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
104 #[unsafe(method(sendData:toPlayers:dataMode:error:_))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn sendData_toPlayers_dataMode_error(
108 &self,
109 data: &NSData,
110 players: &NSArray<GKPlayer>,
111 mode: GKMatchSendDataMode,
112 ) -> Result<(), Retained<NSError>>;
113
114 #[unsafe(method(sendDataToAllPlayers:withDataMode:error:_))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn sendDataToAllPlayers_withDataMode_error(
118 &self,
119 data: &NSData,
120 mode: GKMatchSendDataMode,
121 ) -> Result<(), Retained<NSError>>;
122
123 #[unsafe(method(disconnect))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn disconnect(&self);
127
128 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer", feature = "block2"))]
129 #[unsafe(method(chooseBestHostingPlayerWithCompletionHandler:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn chooseBestHostingPlayerWithCompletionHandler(
133 &self,
134 completion_handler: &block2::DynBlock<dyn Fn(*mut GKPlayer)>,
135 );
136
137 #[cfg(feature = "block2")]
138 #[unsafe(method(rematchWithCompletionHandler:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn rematchWithCompletionHandler(
145 &self,
146 completion_handler: Option<&block2::DynBlock<dyn Fn(*mut GKMatch, *mut NSError)>>,
147 );
148
149 #[cfg(feature = "GKVoiceChat")]
150 #[deprecated = "No longer supported"]
152 #[unsafe(method(voiceChatWithName:))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn voiceChatWithName(&self, name: &NSString) -> Option<Retained<GKVoiceChat>>;
155 );
156}
157
158impl GKMatch {
160 extern_methods!(
161 #[unsafe(method(init))]
162 #[unsafe(method_family = init)]
163 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
164
165 #[unsafe(method(new))]
166 #[unsafe(method_family = new)]
167 pub unsafe fn new() -> Retained<Self>;
168 );
169}
170
171extern_protocol!(
172 pub unsafe trait GKMatchDelegate: NSObjectProtocol {
174 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
175 #[optional]
177 #[unsafe(method(match:didReceiveData:fromRemotePlayer:))]
178 #[unsafe(method_family = none)]
179 unsafe fn match_didReceiveData_fromRemotePlayer(
180 &self,
181 r#match: &GKMatch,
182 data: &NSData,
183 player: &GKPlayer,
184 );
185
186 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
187 #[optional]
188 #[unsafe(method(match:didReceiveData:forRecipient:fromRemotePlayer:))]
189 #[unsafe(method_family = none)]
190 unsafe fn match_didReceiveData_forRecipient_fromRemotePlayer(
191 &self,
192 r#match: &GKMatch,
193 data: &NSData,
194 recipient: &GKPlayer,
195 player: &GKPlayer,
196 );
197
198 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
199 #[optional]
201 #[unsafe(method(match:player:didChangeConnectionState:))]
202 #[unsafe(method_family = none)]
203 unsafe fn match_player_didChangeConnectionState(
204 &self,
205 r#match: &GKMatch,
206 player: &GKPlayer,
207 state: GKPlayerConnectionState,
208 );
209
210 #[optional]
212 #[unsafe(method(match:didFailWithError:))]
213 #[unsafe(method_family = none)]
214 unsafe fn match_didFailWithError(&self, r#match: &GKMatch, error: Option<&NSError>);
215
216 #[cfg(all(feature = "GKBasePlayer", feature = "GKPlayer"))]
217 #[optional]
219 #[unsafe(method(match:shouldReinviteDisconnectedPlayer:))]
220 #[unsafe(method_family = none)]
221 unsafe fn match_shouldReinviteDisconnectedPlayer(
222 &self,
223 r#match: &GKMatch,
224 player: &GKPlayer,
225 ) -> bool;
226
227 #[deprecated]
229 #[optional]
230 #[unsafe(method(match:didReceiveData:fromPlayer:))]
231 #[unsafe(method_family = none)]
232 unsafe fn match_didReceiveData_fromPlayer(
233 &self,
234 r#match: &GKMatch,
235 data: &NSData,
236 player_id: &NSString,
237 );
238
239 #[deprecated]
240 #[optional]
241 #[unsafe(method(match:player:didChangeState:))]
242 #[unsafe(method_family = none)]
243 unsafe fn match_player_didChangeState(
244 &self,
245 r#match: &GKMatch,
246 player_id: &NSString,
247 state: GKPlayerConnectionState,
248 );
249
250 #[deprecated]
251 #[optional]
252 #[unsafe(method(match:shouldReinvitePlayer:))]
253 #[unsafe(method_family = none)]
254 unsafe fn match_shouldReinvitePlayer(
255 &self,
256 r#match: &GKMatch,
257 player_id: &NSString,
258 ) -> bool;
259 }
260);
261
262impl GKMatch {
264 extern_methods!(
265 #[cfg(feature = "block2")]
266 #[deprecated]
268 #[unsafe(method(chooseBestHostPlayerWithCompletionHandler:))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn chooseBestHostPlayerWithCompletionHandler(
271 &self,
272 completion_handler: &block2::DynBlock<dyn Fn(*mut NSString)>,
273 );
274
275 #[deprecated]
277 #[unsafe(method(sendData:toPlayers:withDataMode:error:_))]
278 #[unsafe(method_family = none)]
279 pub unsafe fn sendData_toPlayers_withDataMode_error(
280 &self,
281 data: &NSData,
282 player_i_ds: &NSArray<NSString>,
283 mode: GKMatchSendDataMode,
284 ) -> Result<(), Retained<NSError>>;
285
286 #[deprecated]
288 #[unsafe(method(playerIDs))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn playerIDs(&self) -> Option<Retained<NSArray<NSString>>>;
291 );
292}