@@ -206,8 +206,8 @@ public class SocketIOClient: NSObject {
206
206
ackNum: self . currentAck, socket: self )
207
207
self . ackHandlers. append ( ackHandler)
208
208
209
- dispatch_async ( self . emitQueue) { [ weak self] in
210
- self ? . _emit ( event, args, ack: true )
209
+ dispatch_async ( self . emitQueue) { [ weak self, ack = self . currentAck ] in
210
+ self ? . _emit ( event, args, ack: ack )
211
211
return
212
212
}
213
213
@@ -218,7 +218,7 @@ public class SocketIOClient: NSObject {
218
218
return self . emitWithAck ( event, args)
219
219
}
220
220
221
- private func _emit( event: String , _ args: [ AnyObject ] , ack: Bool = false ) {
221
+ private func _emit( event: String , _ args: [ AnyObject ] , ack: Int ? = nil ) {
222
222
var frame : SocketEvent
223
223
var str : String
224
224
@@ -229,22 +229,22 @@ public class SocketIOClient: NSObject {
229
229
}
230
230
231
231
if hasBinary {
232
- if ! ack {
232
+ if ack == nil {
233
233
str = SocketEvent . createMessageForEvent ( event, withArgs: items,
234
234
hasBinary: true , withDatas: emitDatas. count, toNamespace: self . nsp)
235
235
} else {
236
236
str = SocketEvent . createMessageForEvent ( event, withArgs: items,
237
- hasBinary: true , withDatas: emitDatas. count, toNamespace: self . nsp, wantsAck: self . currentAck )
237
+ hasBinary: true , withDatas: emitDatas. count, toNamespace: self . nsp, wantsAck: ack )
238
238
}
239
239
240
240
self . engine? . send ( str, datas: emitDatas)
241
241
} else {
242
- if ! ack {
242
+ if ack == nil {
243
243
str = SocketEvent . createMessageForEvent ( event, withArgs: items, hasBinary: false ,
244
244
withDatas: 0 , toNamespace: self . nsp)
245
245
} else {
246
246
str = SocketEvent . createMessageForEvent ( event, withArgs: items, hasBinary: false ,
247
- withDatas: 0 , toNamespace: self . nsp, wantsAck: self . currentAck )
247
+ withDatas: 0 , toNamespace: self . nsp, wantsAck: ack )
248
248
}
249
249
250
250
self . engine? . send ( str)
0 commit comments