File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -4,15 +4,17 @@ import PackageDescription
4
4
let package = Package (
5
5
name: " websocket-kit " ,
6
6
platforms: [
7
- . macOS( . v10_15) ,
8
- . iOS( . v11)
7
+ . macOS( . v10_15) ,
8
+ . iOS( . v13) ,
9
+ . tvOS( . v13) ,
9
10
] ,
10
11
products: [
11
12
. library( name: " WebSocketKit " , targets: [ " WebSocketKit " ] ) ,
12
13
] ,
13
14
dependencies: [
14
15
. package ( url: " https://github.com/apple/swift-nio.git " , from: " 2.33.0 " ) ,
15
16
. package ( url: " https://github.com/apple/swift-nio-ssl.git " , from: " 2.14.0 " ) ,
17
+ . package ( url: " https://github.com/apple/swift-nio-transport-services.git " , from: " 1.11.4 " ) ,
16
18
] ,
17
19
targets: [
18
20
. target( name: " WebSocketKit " , dependencies: [
@@ -23,6 +25,7 @@ let package = Package(
23
25
. product( name: " NIOHTTP1 " , package : " swift-nio " ) ,
24
26
. product( name: " NIOSSL " , package : " swift-nio-ssl " ) ,
25
27
. product( name: " NIOWebSocket " , package : " swift-nio " ) ,
28
+ . product( name: " NIOTransportServices " , package : " swift-nio-transport-services " ) ,
26
29
] ) ,
27
30
. testTarget( name: " WebSocketKitTests " , dependencies: [
28
31
. target( name: " WebSocketKit " ) ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import NIOConcurrencyHelpers
4
4
import NIOHTTP1
5
5
import NIOWebSocket
6
6
import NIOSSL
7
+ import NIOTransportServices
7
8
8
9
public final class WebSocketClient {
9
10
public enum Error : Swift . Error , LocalizedError {
@@ -60,7 +61,7 @@ public final class WebSocketClient {
60
61
) -> EventLoopFuture < Void > {
61
62
assert ( [ " ws " , " wss " ] . contains ( scheme) )
62
63
let upgradePromise = self . group. next ( ) . makePromise ( of: Void . self)
63
- let bootstrap = ClientBootstrap ( group : self . group)
64
+ let bootstrap = WebSocketClient . makeBootstrap ( on : self . group)
64
65
. channelOption ( ChannelOptions . socket ( SocketOptionLevel ( IPPROTO_TCP) , TCP_NODELAY) , value: 1 )
65
66
. channelInitializer { channel in
66
67
let httpHandler = HTTPInitialRequestHandler (
@@ -141,6 +142,20 @@ public final class WebSocketClient {
141
142
}
142
143
}
143
144
}
145
+
146
+ private static func makeBootstrap( on eventLoop: EventLoopGroup ) -> NIOClientTCPBootstrapProtocol {
147
+ #if canImport(Network)
148
+ if let tsBootstrap = NIOTSConnectionBootstrap ( validatingGroup: eventLoop) {
149
+ return tsBootstrap
150
+ }
151
+ #endif
152
+
153
+ if let nioBootstrap = ClientBootstrap ( validatingGroup: eventLoop) {
154
+ return nioBootstrap
155
+ }
156
+
157
+ fatalError ( " No matching bootstrap found " )
158
+ }
144
159
145
160
deinit {
146
161
switch self . eventLoopGroupProvider {
You can’t perform that action at this time.
0 commit comments