@@ -206,8 +206,8 @@ public class SocketIOClient: NSObject {
206206 ackNum: self . currentAck, socket: self )
207207 self . ackHandlers. append ( ackHandler)
208208
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 )
211211 return
212212 }
213213
@@ -218,7 +218,7 @@ public class SocketIOClient: NSObject {
218218 return self . emitWithAck ( event, args)
219219 }
220220
221- private func _emit( event: String , _ args: [ AnyObject ] , ack: Bool = false ) {
221+ private func _emit( event: String , _ args: [ AnyObject ] , ack: Int ? = nil ) {
222222 var frame : SocketEvent
223223 var str : String
224224
@@ -229,22 +229,22 @@ public class SocketIOClient: NSObject {
229229 }
230230
231231 if hasBinary {
232- if ! ack {
232+ if ack == nil {
233233 str = SocketEvent . createMessageForEvent ( event, withArgs: items,
234234 hasBinary: true , withDatas: emitDatas. count, toNamespace: self . nsp)
235235 } else {
236236 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 )
238238 }
239239
240240 self . engine? . send ( str, datas: emitDatas)
241241 } else {
242- if ! ack {
242+ if ack == nil {
243243 str = SocketEvent . createMessageForEvent ( event, withArgs: items, hasBinary: false ,
244244 withDatas: 0 , toNamespace: self . nsp)
245245 } else {
246246 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 )
248248 }
249249
250250 self . engine? . send ( str)
0 commit comments