File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
templates/swift/Sources/Services Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ open class Realtime : Service {
2525
2626 private var onErrorCallbacks: [((Swift.Error?, HTTPResponseStatus?) -> Void)] = []
2727 private var onCloseCallbacks: [(() -> Void)] = []
28+ private var onOpenCallbacks: [(() -> Void)] = []
2829
2930 public func onError(_ callback: @escaping (Swift.Error?, HTTPResponseStatus?) -> Void) {
3031 self.onErrorCallbacks.append(callback)
@@ -33,6 +34,10 @@ open class Realtime : Service {
3334 public func onClose(_ callback: @escaping () -> Void) {
3435 self.onCloseCallbacks.append(callback)
3536 }
37+
38+ public func onOpen(_ callback: @escaping () -> Void) {
39+ self.onOpenCallbacks.append(callback)
40+ }
3641
3742 private func startHeartbeat() {
3843 stopHeartbeat()
@@ -202,6 +207,7 @@ extension Realtime: WebSocketClientDelegate {
202207
203208 public func onOpen(channel: Channel) {
204209 self.reconnectAttempts = 0
210+ onOpenCallbacks.forEach { $0() }
205211 startHeartbeat()
206212 }
207213
You can’t perform that action at this time.
0 commit comments