Skip to content

Commit 11441bf

Browse files
authored
Merge pull request #815 from zlmr/fix-apple-realtime
Fix apple realtime socket cleanup
2 parents 7689f69 + cf0ab89 commit 11441bf

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

templates/swift/Sources/Services/Realtime.swift.twig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ open class Realtime : Service {
2323

2424
private func createSocket() {
2525
guard activeChannels.count > 0 else {
26+
reconnect = false
27+
closeSocket()
2628
return
2729
}
2830

@@ -137,7 +139,7 @@ open class Realtime : Service {
137139
let subsWithChannel = activeSubscriptions.filter { callback in
138140
return callback.value.channels.contains(channel)
139141
}
140-
return subsWithChannel.isEmpty
142+
return !subsWithChannel.isEmpty
141143
}
142144
}
143145
}

templates/swift/Sources/WebSockets/WebSocketClient.swift.twig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,5 +408,9 @@ public class WebSocketClient {
408408
} else {
409409
channel.write(frame, promise: nil)
410410
}
411+
412+
if opcode == .connectionClose {
413+
channel.close(mode: .all, promise: nil)
414+
}
411415
}
412416
}

0 commit comments

Comments
 (0)