Compare commits
1 Commits
main
...
fix/serial
Author | SHA1 | Date |
---|---|---|
![]() |
63d2cac4c1 |
|
@ -32,6 +32,7 @@ extension AppSyncSubscriptionConnection {
|
||||||
let connectionError = error as? ConnectionProviderError
|
let connectionError = error as? ConnectionProviderError
|
||||||
else {
|
else {
|
||||||
subscriptionItem.subscriptionEventHandler(.failed(error), subscriptionItem)
|
subscriptionItem.subscriptionEventHandler(.failed(error), subscriptionItem)
|
||||||
|
connectionProvider?.removeListener(identifier: subscriptionItem.identifier)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,6 +44,7 @@ extension AppSyncSubscriptionConnection {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
subscriptionItem.subscriptionEventHandler(.failed(error), subscriptionItem)
|
subscriptionItem.subscriptionEventHandler(.failed(error), subscriptionItem)
|
||||||
|
connectionProvider?.removeListener(identifier: subscriptionItem.identifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,10 @@ public class AppSyncSubscriptionConnection: SubscriptionConnection, RetryableCon
|
||||||
/// Retry logic to handle
|
/// Retry logic to handle
|
||||||
var retryHandler: ConnectionRetryHandler?
|
var retryHandler: ConnectionRetryHandler?
|
||||||
|
|
||||||
|
let serialQueue = DispatchQueue(
|
||||||
|
label: "com.amazonaws.AppSyncSubscriptionConnection.serialQueue"
|
||||||
|
)
|
||||||
|
|
||||||
public init(provider: ConnectionProvider) {
|
public init(provider: ConnectionProvider) {
|
||||||
self.connectionProvider = provider
|
self.connectionProvider = provider
|
||||||
}
|
}
|
||||||
|
@ -84,6 +88,7 @@ public class AppSyncSubscriptionConnection: SubscriptionConnection, RetryableCon
|
||||||
AppSyncLogger.debug("[AppSyncSubscriptionConnection] \(#function): Self is nil, listener is not called.")
|
AppSyncLogger.debug("[AppSyncSubscriptionConnection] \(#function): Self is nil, listener is not called.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
self.serialQueue.async {
|
||||||
switch event {
|
switch event {
|
||||||
case .connection(let state):
|
case .connection(let state):
|
||||||
self.handleConnectionEvent(connectionState: state)
|
self.handleConnectionEvent(connectionState: state)
|
||||||
|
@ -94,6 +99,7 @@ public class AppSyncSubscriptionConnection: SubscriptionConnection, RetryableCon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public func addRetryHandler(handler: ConnectionRetryHandler) {
|
public func addRetryHandler(handler: ConnectionRetryHandler) {
|
||||||
retryHandler = handler
|
retryHandler = handler
|
||||||
|
|
Loading…
Reference in New Issue