Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add handler for WebSocket peer closed event #229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/metaplex-foundation/beet-swift.git",
"state": {
"branch": null,
"revision": "05657fa3511b8b72ea8da77745373215445c9885",
"version": "1.0.2"
"revision": "e4708bf28b55ce42727006c1cb7882f069d07bd8",
"version": "1.0.7"
}
},
{
Expand All @@ -24,16 +24,25 @@
"repositoryURL": "https://github.com/daltoniam/Starscream.git",
"state": {
"branch": null,
"revision": "df8d82047f6654d8e4b655d1b1525c64e1059d21",
"version": "4.0.4"
"revision": "c6bfd1af48efcc9a9ad203665db12375ba6b145a",
"version": "4.0.8"
}
},
{
"package": "SwiftDocCPlugin",
"repositoryURL": "https://github.com/apple/swift-docc-plugin",
"state": {
"branch": null,
"revision": "3303b164430d9a7055ba484c8ead67a52f7b74f6",
"revision": "85e4bb4e1cd62cec64a4b8e769dcefdf0c5b9d64",
"version": "1.4.3"
}
},
{
"package": "SymbolKit",
"repositoryURL": "https://github.com/swiftlang/swift-docc-symbolkit",
"state": {
"branch": null,
"revision": "b45d1f2ed151d057b54504d653e0da5552844e34",
"version": "1.0.0"
}
},
Expand Down
8 changes: 5 additions & 3 deletions Sources/Solana/Networking/Socket/SolanaSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ public class SolanaSocket {
}

extension SolanaSocket: WebSocketDelegate {

public func didReceive(event: WebSocketEvent, client: WebSocket) {
public func didReceive(event: WebSocketEvent, client: any WebSocketClient) {
log(event: event)
switch event {
case .connected:
Expand All @@ -142,6 +141,7 @@ extension SolanaSocket: WebSocketDelegate {
case .viabilityChanged: break
case .reconnectSuggested: break
case .cancelled: break
case .peerClosed: break
case .error(let error): break
self.delegate?.error(error: error)
}
Expand All @@ -150,7 +150,7 @@ extension SolanaSocket: WebSocketDelegate {
private func log(event: WebSocketEvent) {
switch event {
case .connected(let headers):
if enableDebugLogs { debugPrint("conected with headers \(headers)") }
if enableDebugLogs { debugPrint("connected with headers \(headers)") }
case .disconnected(let reason, let code):
if enableDebugLogs { debugPrint("disconnected with reason \(reason) \(code)") }
case .text(let string):
Expand All @@ -167,6 +167,8 @@ extension SolanaSocket: WebSocketDelegate {
if enableDebugLogs { debugPrint("reconnectSuggested \(reconnect)") }
case .cancelled:
if enableDebugLogs { debugPrint("cancelled") }
case .peerClosed:
if enableDebugLogs { debugPrint("peer closed")}
case .error(let error):
if enableDebugLogs { debugPrint("error \(error?.localizedDescription ?? "")") }
}
Expand Down