Skip to content

Commit

Permalink
fix: dont try to send PONG message (handled by URLSessionWebSocketTask)
Browse files Browse the repository at this point in the history
  • Loading branch information
pokryfka committed Oct 26, 2023
1 parent 76efdbe commit f54fa9c
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Sources/GraphQLWebSocket/WebSocketClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,8 @@ class WebSocket: NSObject, WebSocketClient, URLSessionWebSocketDelegate {
}

func write(pong: Data, completion: (() -> ())?) {
assert(socket.state == .running)
// TODO: test, check if URLSessionWebSocketTask responds to ping
struct Pong: Encodable {
var type = "pong"
}
let data = try! JSONEncoder().encode(Pong())
write(data: data, completion: completion)
// NOTE: URLSessionWebSocketTask reponds to PINGs sent by server
completion?()
}

// MARK: URLSessionWebSocketDelegate
Expand Down

0 comments on commit f54fa9c

Please sign in to comment.