@@ -78,11 +78,7 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
7878 /// The id of this socket.io connect. This is different from the sid of the engine.io connection.
7979 public private( set) var sid : String ?
8080 /// The id of this socket.io connect for connection state recovery.
81- public private( set) var pid : String ? {
82- didSet {
83- recovered = pid != nil && pid == oldValue
84- }
85- }
81+ public private( set) var pid : String ?
8682
8783 /// Offset of last socket.io event for connection state recovery.
8884 public private( set) var lastEventOffset : String ?
@@ -195,8 +191,9 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
195191 /// - parameter toNamespace: The namespace that was connected to.
196192 open func didConnect( toNamespace namespace: String , payload: [ String : Any ] ? ) {
197193 guard status != . connected else { return }
198-
199- pid = payload ? [ " pid " ] as? String
194+ let pid = payload ? [ " pid " ] as? String
195+ recovered = self . pid != nil && self . pid == pid
196+ self . pid = pid
200197 sid = payload ? [ " sid " ] as? String
201198
202199 DefaultSocketLogger . Logger. log ( " Socket connected " , type: logType)
@@ -386,18 +383,18 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
386383 open func handleEvent( _ event: String , data: [ Any ] , isInternalMessage: Bool , withAck ack: Int = - 1 ) {
387384 guard status == . connected || isInternalMessage else { return }
388385
389- if !isInternalMessage && ack < 0 && pid != nil ,
390- let eventOffset = data. last as? String {
391- self . lastEventOffset = eventOffset
392- }
393-
394386 DefaultSocketLogger . Logger. log ( " Handling event: \( event) with data: \( data) " , type: logType)
395387
396388 anyHandler ? ( SocketAnyEvent ( event: event, items: data) )
397389
398390 for handler in handlers where handler. event == event {
399391 handler. executeCallback ( with: data, withAck: ack, withSocket: self )
400392 }
393+
394+ if !isInternalMessage && ack < 0 && pid != nil ,
395+ let eventOffset = data. last as? String {
396+ self . lastEventOffset = eventOffset
397+ }
401398 }
402399
403400 /// Causes a client to handle a socket.io packet. The namespace for the packet must match the namespace of the
0 commit comments