Skip to content

Commit

Permalink
downgrade version of starscream, as crash rate jumped up significantl…
Browse files Browse the repository at this point in the history
…y, and also reports of slowness and lag in connection/communication
  • Loading branch information
simonmcl committed May 27, 2024
1 parent e4a6fca commit 51b8fc7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 62 deletions.
2 changes: 1 addition & 1 deletion Kukai Mobile.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2796,7 +2796,7 @@
repositoryURL = "https://github.com/daltoniam/Starscream";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 4.0.8;
minimumVersion = 3.1.2;
};
};
C0BBD2A326A9A7980097B63A /* XCRemoteSwiftPackageReference "sentry-cocoa" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/daltoniam/Starscream",
"state" : {
"revision" : "c6bfd1af48efcc9a9ad203665db12375ba6b145a",
"version" : "4.0.8"
"revision" : "a063fda2b8145a231953c20e7a646be254365396",
"version" : "3.1.2"
}
},
{
Expand Down
61 changes: 2 additions & 59 deletions Kukai Mobile/Services/WalletConnectService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,69 +39,12 @@ public struct WalletConnectGetAccountObj: Codable {
let pubkey: String
}

class KukaiWebSocket: Starscream.WebSocket, WebSocketConnecting {
private var _isConnected = true

public var isConnected: Bool {
_isConnected
}

var onConnect: (() -> Void)?

var onDisconnect: ((Error?) -> Void)?

var onText: ((String) -> Void)?

convenience init(newRequest: URLRequest) {
self.init(request: newRequest, useCustomEngine: false)

onEvent = { [weak self] event in
guard let self else { return }

switch event {
case .connected:
_isConnected = true
onConnect?()

case .disconnected(let reason, let code):
_isConnected = false
onDisconnect?(NSError(domain: reason, code: Int(code), userInfo: nil))

case .text(let text):
onText?(text)

case .binary:
break

case .pong:
break

case .ping:
break

case .error(let error):
onDisconnect?(error)

case .viabilityChanged:
break

case .reconnectSuggested:
break

case .cancelled:
_isConnected = false

default:
break
}
}
}
}
extension WebSocket: WebSocketConnecting {}

struct DefaultSocketFactory: WebSocketFactory {

func create(with url: URL) -> WebSocketConnecting {
let socket = KukaiWebSocket(newRequest: URLRequest(url: url))
let socket = WebSocket(url: url)
let queue = DispatchQueue(label: "com.walletconnect.sdk.sockets", attributes: .concurrent)
socket.callbackQueue = queue
return socket
Expand Down

0 comments on commit 51b8fc7

Please sign in to comment.