forked from apollographql/apollo-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApolloWebSocket.swift
More file actions
29 lines (22 loc) · 1005 Bytes
/
ApolloWebSocket.swift
File metadata and controls
29 lines (22 loc) · 1005 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import Starscream
import Foundation
// MARK: - Client protocol
/// Protocol allowing alternative implementations of web sockets beyond `ApolloWebSocket`. Extends `Starscream`'s `WebSocketClient` protocol.
public protocol ApolloWebSocketClient: WebSocketClient {
/// Required initializer
///
/// - Parameter request: The URLRequest to use on connection.
/// - Parameter protocols: The supported protocols
init(request: URLRequest, protocols: [String]?)
/// The URLRequest used on connection.
var request: URLRequest { get set }
/// Queue where the callbacks are executed
var callbackQueue: DispatchQueue { get set }
}
// MARK: - WebSocket
/// Included implementation of an `ApolloWebSocketClient`, based on `Starscream`'s `WebSocket`.
public class ApolloWebSocket: WebSocket, ApolloWebSocketClient {
required public convenience init(request: URLRequest, protocols: [String]? = nil) {
self.init(request: request, protocols: protocols, stream: FoundationStream())
}
}