@@ -212,7 +212,7 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
212
212
/// - parameter event: The event to send.
213
213
/// - parameter items: The items to send with this event. May be left out.
214
214
/// - parameter completion: Callback called on transport write completion.
215
- open func emit( _ event: String , _ items: SocketData ... , completion: ( ( ) -> ( ) ) ? = nil ) {
215
+ open func emit( _ event: String , _ items: SocketData ... , completion: ( @ Sendable ( ) -> ( ) ) ? = nil ) {
216
216
emit ( event, with: items, completion: completion)
217
217
}
218
218
@@ -224,7 +224,7 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
224
224
/// - parameter event: The event to send.
225
225
/// - parameter items: The items to send with this event. May be left out.
226
226
/// - parameter completion: Callback called on transport write completion.
227
- open func emit( _ event: String , with items: [ SocketData ] , completion: ( ( ) -> ( ) ) ? ) {
227
+ open func emit( _ event: String , with items: [ SocketData ] , completion: ( @ Sendable ( ) -> ( ) ) ? ) {
228
228
229
229
do {
230
230
emit ( [ event] + ( try items. map ( { try $0. socketRepresentation ( ) } ) ) , completion: completion)
@@ -296,15 +296,21 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
296
296
ack: Int ? = nil ,
297
297
binary: Bool = true ,
298
298
isAck: Bool = false ,
299
- completion: ( ( ) -> ( ) ) ? = nil
299
+ completion: ( @ Sendable ( ) -> ( ) ) ? = nil
300
300
) {
301
301
// wrap the completion handler so it always runs async via handlerQueue
302
- let wrappedCompletion : ( ( ) -> ( ) ) ? = ( completion == nil ) ? nil : { [ weak self] in
303
- guard let this = self else { return }
304
- this. manager? . handleQueue. async {
305
- completion!( )
302
+ let wrappedCompletion : ( @Sendable ( ) -> ( ) ) ? = {
303
+ if let completion {
304
+ return completion
305
+ } else {
306
+ return { [ weak self] in
307
+ guard let this = self else { return }
308
+ this. manager? . handleQueue. async {
309
+ completion!( )
310
+ }
311
+ }
306
312
}
307
- }
313
+ } ( )
308
314
309
315
guard status == . connected else {
310
316
wrappedCompletion ? ( )
0 commit comments