Skip to content

Commit 94d397a

Browse files
committed
Add reconnection event
1 parent 6c64d2c commit 94d397a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Sources/metamask-ios-sdk/Classes/Communication/SocketClient.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class SocketClient: CommunicationClient {
7171
}
7272

7373
var isConnected: Bool = false
74+
private var isReconnection = false
7475
var tearDownConnection: (() -> Void)?
7576
var onClientsTerminated: (() -> Void)?
7677

@@ -111,7 +112,11 @@ class SocketClient: CommunicationClient {
111112
guard !channel.isConnected else { return }
112113

113114
setupClient()
114-
trackEvent(.connectionRequest)
115+
if isReconnection {
116+
trackEvent(.reconnectionRequest)
117+
} else {
118+
trackEvent(.connectionRequest)
119+
}
115120
channel.connect()
116121
}
117122

@@ -129,6 +134,7 @@ class SocketClient: CommunicationClient {
129134
private func configureSession() {
130135
if let config = fetchSessionConfig(), config.isValid {
131136
channelId = config.sessionId
137+
isReconnection = true
132138
} else {
133139
// purge any existing session info
134140
store.deleteData(for: SESSION_KEY)
@@ -185,7 +191,7 @@ private extension SocketClient {
185191

186192
// MARK: Clients connected event
187193

188-
channel.on(ClientEvent.clientsConnected(on: channelId)) { [weak self] data in
194+
channel.on(ClientEvent.clientsConnected(on: channelId)) { data in
189195
Logging.log("Clients connected: \(data)")
190196

191197
// for debug purposes only

0 commit comments

Comments
 (0)