Skip to content

Commit

Permalink
fix serial queue logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lawmicha committed Nov 23, 2023
1 parent c670ab8 commit 17fc03f
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions AppSyncRealTimeClient/Websocket/Starscream/StarscreamAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,29 @@ public class StarscreamAdapter: AppSyncWebsocketProvider {
self.socket?.callbackQueue = self.callbackQueue
self.socket?.connect()
#if os(watchOS)
// On watchOS, if it takes longer than 5 seconds
// to connect, fail fast.
AppSyncLogger.debug(
"[StarscreamAdapter] Starting connectivity timer for watchOS for 3s"
"[StarscreamAdapter] Starting connectivity timer for watchOS for 3s."
)
self.watchOSConnectivityTimer.start(interval: 3) {
AppSyncLogger.debug(
"[StarscreamAdapter] watchOS connectivity timer is up."
)
if !self._isConnected {
AppSyncLogger.debug(
"[StarscreamAdapter] watchOS subscriptions not connected after 3s."
)
self.serialQueue.async {
self.serialQueue.async {
if !self._isConnected {
AppSyncLogger.debug(
"[StarscreamAdapter] watchOS subscriptions not connected after 3s."
)
AppSyncLogger.debug(
"[StarscreamAdapter] Manually send disconnect."
)
self.delegate?.websocketDidDisconnect(provider: self, error: nil)
} else {
AppSyncLogger.debug(
"[StarscreamAdapter] watchOS subscriptions are connected within 3s."
)
}
} else {
AppSyncLogger.debug(
"[StarscreamAdapter] watchOS subscriptions are connected within 3s."
)
}

}
#endif
}
Expand Down

0 comments on commit 17fc03f

Please sign in to comment.