From da29c5b25b659437ff5cd0a20137e2d34ca4cd23 Mon Sep 17 00:00:00 2001 From: Andrei <78256107+shalom-aviv@users.noreply.github.com> Date: Wed, 4 Dec 2024 08:05:17 +0300 Subject: [PATCH] fix: Offset Not Updated for Server-Side Subscriptions After Receiving Publications #107 (#108) https://github.com/centrifugal/centrifuge-swift/issues/107 --------- Co-authored-by: a.pochtarev --- Sources/SwiftCentrifuge/Client.swift | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftCentrifuge/Client.swift b/Sources/SwiftCentrifuge/Client.swift index 44dc1e7..d76e855 100644 --- a/Sources/SwiftCentrifuge/Client.swift +++ b/Sources/SwiftCentrifuge/Client.swift @@ -624,6 +624,9 @@ fileprivate extension CentrifugeClient { } let pubEvent = CentrifugeServerPublicationEvent(channel: channel, data: pub.data, offset: pub.offset, tags: pub.tags, info: info) self.delegate?.onPublication(self, pubEvent) + if self.serverSubs[channel]?.recoverable == true && pub.offset > 0 { + self.serverSubs[channel]?.offset = pub.offset + } } for (channel, _) in self.serverSubs { if result.subs[channel] == nil { @@ -758,7 +761,6 @@ fileprivate extension CentrifugeClient { if subs.count == 0 { subscriptionsLock.unlock() if let _ = self.serverSubs[channel] { - // self.delegateQueue.addOperation { var info: CentrifugeClientInfo? = nil; if pub.hasInfo { info = CentrifugeClientInfo(client: pub.info.client, user: pub.info.user, connInfo: pub.info.connInfo, chanInfo: pub.info.chanInfo) @@ -768,7 +770,6 @@ fileprivate extension CentrifugeClient { if self.serverSubs[channel]?.recoverable == true && pub.offset > 0 { self.serverSubs[channel]?.offset = pub.offset } - // } } return }