Created
October 24, 2018 16:26
-
-
Save mischa-hildebrand/8d656ce68bb4797dc45b8afdcebcb71a to your computer and use it in GitHub Desktop.
Connect to Web Socket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func connectWebSocket() { | |
let url = URL(string: "ws://localhost:8080/api/echo")! | |
var urlRequest = URLRequest(url: url) | |
guard let tokens = LoginSessionManager.shared.tokens else { | |
// Handle connection failure | |
return | |
} | |
urlRequest.setValue("Bearer \(tokens.access_token)", forHTTPHeaderField: "Authorization") | |
webSocket = WebSocket(request: urlRequest) | |
webSocket?.delegate = self | |
webSocket?.connect() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment