Skip to content

Commit

Permalink
Merge pull request #83 from soramitsu/FLW-2460-Nodes-not-switching-vi…
Browse files Browse the repository at this point in the history
…a-network-issues

FLW-2460 Nodes not switching via network issues
  • Loading branch information
DRadmir authored Nov 25, 2022
2 parents e68069f + 229c21e commit 606bbd0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions FearlessUtils/Classes/Network/JSONRPCEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public protocol JSONRPCEngine: AnyObject {
func generateRequestId() -> UInt16
func addSubscription(_ subscription: JSONRPCSubscribing)
func connect(with pendingRequests: [JSONRPCRequest])
func reconnect(url: URL)
}

public extension JSONRPCEngine {
Expand Down
15 changes: 15 additions & 0 deletions FearlessUtils/Classes/Network/WebSocketEngine+Protocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,19 @@ extension WebSocketEngine: JSONRPCEngine {
updateConnectionForRequest($0)
}
}

public func reconnect(url: URL) {
self.connection.delegate = nil

self.url = url
let request = URLRequest(url: url, timeoutInterval: 10)
let engine = self.connection.engine

let connection = WebSocket(request: request, engine: engine)
self.connection = connection

connection.callbackQueue = Self.sharedProcessingQueue
connection.delegate = self
}
}

0 comments on commit 606bbd0

Please sign in to comment.