Skip to content

Commit

Permalink
style(IRC): fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinrpb committed Oct 31, 2024
1 parent 2ae83ba commit bedbbe3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions Sources/TwitchWebsocketKit/WebsocketKitTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public final class WebsocketKitTask: WebsocketTask {
private let url: URL
private let eventLoopGroup: EventLoopGroup

private var websocket: WebSocket? = nil
private var websocket: WebSocket?
private var stream: AsyncThrowingStream<String, Error>?
private var iterator: AsyncThrowingStream<String, Error>.Iterator?
private var continuation: AsyncThrowingStream<String, Error>.Continuation?
Expand All @@ -33,22 +33,22 @@ public final class WebsocketKitTask: WebsocketTask {
self.iterator = stream.makeAsyncIterator()
self.continuation = continuation

try WebSocket.connect(to: url, on: eventLoopGroup) { [weak self] ws in
try WebSocket.connect(to: url, on: eventLoopGroup) { [weak self] socket in
guard let self else {
_ = ws.close(code: .goingAway)
_ = socket.close(code: .goingAway)
return
}
self.websocket = ws
self.websocket = socket

_ = ws.onClose.map {
_ = socket.onClose.map {
self.continuation?.finish()
}

ws.onPing { ws, buffer in
socket.onPing { _, _ in
self.continuation?.yield("PING :")
}

ws.onPong { ws, buffer in
socket.onPong { _, _ in
// Skip first pong coming from our connection ping
guard self.connected else {
self.connected = true
Expand All @@ -57,12 +57,12 @@ public final class WebsocketKitTask: WebsocketTask {
self.continuation?.yield("PONG :")
}

ws.onText { ws, text in
socket.onText { _, _ in
self.continuation?.yield(text)
}

// Kickoff the connectiong with a ping
ws.sendPing()
socket.sendPing()
}.wait()
}

Expand Down

0 comments on commit bedbbe3

Please sign in to comment.