mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-24 16:10:38 +00:00
Fix Client
This commit is contained in:
parent
4de46610e0
commit
95aade3795
1 changed files with 7 additions and 4 deletions
|
@ -67,10 +67,13 @@ public class Client: ObservableObject, Equatable, Identifiable, Hashable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func makeURL(scheme: String = "https", endpoint: Endpoint, forceVersion: Version? = nil) -> URL {
|
private func makeURL(scheme: String = "https",
|
||||||
|
endpoint: Endpoint,
|
||||||
|
forceVersion: Version? = nil,
|
||||||
|
forceServer: String? = nil) -> URL {
|
||||||
var components = URLComponents()
|
var components = URLComponents()
|
||||||
components.scheme = scheme
|
components.scheme = scheme
|
||||||
components.host = server
|
components.host = forceServer ?? server
|
||||||
if type(of: endpoint) == Oauth.self {
|
if type(of: endpoint) == Oauth.self {
|
||||||
components.path += "/\(endpoint.path())"
|
components.path += "/\(endpoint.path())"
|
||||||
} else {
|
} else {
|
||||||
|
@ -190,8 +193,8 @@ public class Client: ObservableObject, Equatable, Identifiable, Hashable {
|
||||||
return token
|
return token
|
||||||
}
|
}
|
||||||
|
|
||||||
public func makeWebSocketTask(endpoint: Endpoint) -> URLSessionWebSocketTask {
|
public func makeWebSocketTask(endpoint: Endpoint, instanceStreamingURL: URL?) -> URLSessionWebSocketTask {
|
||||||
let url = makeURL(scheme: "wss", endpoint: endpoint)
|
let url = makeURL(scheme: "wss", endpoint: endpoint, forceServer: instanceStreamingURL?.host)
|
||||||
let request = makeURLRequest(url: url, endpoint: endpoint, httpMethod: "GET")
|
let request = makeURLRequest(url: url, endpoint: endpoint, httpMethod: "GET")
|
||||||
return urlSession.webSocketTask(with: request)
|
return urlSession.webSocketTask(with: request)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue