Skip to content

Commit 85b9cde

Browse files
committed
add socket configuration to default implementation
1 parent bba38b5 commit 85b9cde

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Sources/ActionCableSwift/ActionCableSwift.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11

22
import Foundation
3+
import WebSocketKit
4+
import NIOCore
35

46
public final class ACClient {
57

@@ -37,11 +39,14 @@ public final class ACClient {
3739
}
3840
}
3941

42+
/// Default websocket implementation
4043
public init(stringURL: String,
44+
configuration: WebSocketClient.Configuration = .init(),
45+
coreCount: Int = System.coreCount,
4146
headers: [String: String]? = nil,
4247
options: ACClientOptions? = nil
4348
) {
44-
self.ws = WSS(stringURL: stringURL)
49+
self.ws = WSS(stringURL: stringURL, configuration: configuration, coreCount: coreCount)
4550
self.headers = headers
4651
self.options = options ?? ACClientOptions()
4752
setupWSCallbacks()

Sources/ActionCableSwift/WebSocketClient/WS.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ open class WSS: ACWebSocketProtocol {
1818

1919
public var url: URL
2020
private var eventLoopGroup: EventLoopGroup
21+
private var configuration: WebSocketClient.Configuration
2122
var ws: WebSocket?
2223

23-
init(stringURL: String, coreCount: Int = System.coreCount) {
24+
init(stringURL: String, configuration: WebSocketClient.Configuration = .init(), coreCount: Int = System.coreCount) {
2425
url = URL(string: stringURL)!
2526
eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: coreCount)
27+
self.configuration = configuration
2628
}
2729

2830
public var onConnected: ((_ headers: [String : String]?) -> Void)?
@@ -43,6 +45,7 @@ open class WSS: ACWebSocketProtocol {
4345

4446
WebSocket.connect(to: url.absoluteString,
4547
headers: httpHeaders,
48+
configuration: configuration,
4649
on: eventLoopGroup
4750
) { ws in
4851
self.ws = ws

0 commit comments

Comments
 (0)