Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save jacobsapps/a865b98151ac8e3a0e6794d6cc12f173 to your computer and use it in GitHub Desktop.

Select an option

Save jacobsapps/a865b98151ac8e3a0e6794d6cc12f173 to your computer and use it in GitHub Desktop.
private var webSocketTask: URLSessionWebSocketTask?
private func setupWebSocket(url: URL) {
let session = URLSession(configuration: .default)
webSocketTask = session.webSocketTask(with: url)
webSocketTask?.resume()
Task {
while true {
try await receiveNextMessage()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment