Skip to content

Commit

Permalink
ArtemisStompClient: Use same queue for onConnect and subscribe func…
Browse files Browse the repository at this point in the history
…tions (#102)

* Use same queue for onConnect as in subscribe

* Use queue for onDisconnect
  • Loading branch information
anian03 authored Nov 14, 2024
1 parent c3cd7a5 commit 03f85a1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Sources/APIClient/StompClient/ArtemisStompClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,21 @@ extension ArtemisStompClient: SwiftStompDelegate {

public func onConnect(swiftStomp: SwiftStomp, connectType: StompConnectType) {
log.debug("Stomp: Connect")
let topicKeys = Array(topics.keys)
topicKeys.forEach { topic in
subscribeWithoutStream(to: topic)
queue.async { [weak self] in
let topicKeys = self?.topics.keys
topicKeys?.forEach { topic in
self?.subscribeWithoutStream(to: topic)
}
}
}

public func onDisconnect(swiftStomp: SwiftStomp, disconnectType: StompDisconnectType) {
log.debug("Stomp: Disconnect")
stompClient = nil
if !topics.isEmpty {
setup()
queue.async { [weak self] in
if self?.topics.isEmpty == false {
self?.setup()
}
}
}

Expand Down

0 comments on commit 03f85a1

Please sign in to comment.