Skip to content

Commit 17fc03f

Browse files
committed
fix serial queue logic
1 parent c670ab8 commit 17fc03f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

AppSyncRealTimeClient/Websocket/Starscream/StarscreamAdapter.swift

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,29 @@ public class StarscreamAdapter: AppSyncWebsocketProvider {
5353
self.socket?.callbackQueue = self.callbackQueue
5454
self.socket?.connect()
5555
#if os(watchOS)
56-
// On watchOS, if it takes longer than 5 seconds
57-
// to connect, fail fast.
5856
AppSyncLogger.debug(
59-
"[StarscreamAdapter] Starting connectivity timer for watchOS for 3s"
57+
"[StarscreamAdapter] Starting connectivity timer for watchOS for 3s."
6058
)
6159
self.watchOSConnectivityTimer.start(interval: 3) {
6260
AppSyncLogger.debug(
6361
"[StarscreamAdapter] watchOS connectivity timer is up."
6462
)
65-
if !self._isConnected {
66-
AppSyncLogger.debug(
67-
"[StarscreamAdapter] watchOS subscriptions not connected after 3s."
68-
)
69-
self.serialQueue.async {
63+
self.serialQueue.async {
64+
if !self._isConnected {
65+
AppSyncLogger.debug(
66+
"[StarscreamAdapter] watchOS subscriptions not connected after 3s."
67+
)
68+
AppSyncLogger.debug(
69+
"[StarscreamAdapter] Manually send disconnect."
70+
)
7071
self.delegate?.websocketDidDisconnect(provider: self, error: nil)
72+
} else {
73+
AppSyncLogger.debug(
74+
"[StarscreamAdapter] watchOS subscriptions are connected within 3s."
75+
)
7176
}
72-
} else {
73-
AppSyncLogger.debug(
74-
"[StarscreamAdapter] watchOS subscriptions are connected within 3s."
75-
)
7677
}
78+
7779
}
7880
#endif
7981
}

0 commit comments

Comments
 (0)