Skip to content

Commit 1ef8aac

Browse files
Merge pull request #223 from openbitapp/master
Added option that allows to specify path
2 parents 33acb9c + d3182e1 commit 1ef8aac

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Sources/Models/PusherClientOptions.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public enum AuthMethod {
2727
public let autoReconnect: Bool
2828
public let host: String
2929
public let port: Int
30+
public let path: String?
3031
public let useTLS: Bool
3132
public let activityTimeout: TimeInterval?
3233

@@ -36,13 +37,15 @@ public enum AuthMethod {
3637
autoReconnect: Bool = true,
3738
host: PusherHost = .host(Constants.API.defaultHost),
3839
port: Int? = nil,
40+
path: String? = nil,
3941
useTLS: Bool = true,
4042
activityTimeout: TimeInterval? = nil
4143
) {
4244
self.authMethod = authMethod
4345
self.attemptToReturnJSONObject = attemptToReturnJSONObject
4446
self.autoReconnect = autoReconnect
4547
self.host = host.stringValue
48+
self.path = path
4649
self.port = port ?? (useTLS ? 443 : 80)
4750
self.useTLS = useTLS
4851
self.activityTimeout = activityTimeout

Sources/PusherSwift.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ let CLIENT_NAME = "pusher-websocket-swift"
180180
*/
181181
func constructUrl(key: String, options: PusherClientOptions) -> String {
182182
var url = ""
183-
183+
let additionalPathComponents = options.path ?? ""
184184
if options.useTLS {
185-
url = "wss://\(options.host):\(options.port)/app/\(key)"
185+
url = "wss://\(options.host):\(options.port)\(additionalPathComponents)/app/\(key)"
186186
} else {
187-
url = "ws://\(options.host):\(options.port)/app/\(key)"
187+
url = "ws://\(options.host):\(options.port)\(additionalPathComponents)/app/\(key)"
188188
}
189189
return "\(url)?client=\(CLIENT_NAME)&version=\(VERSION)&protocol=\(PROTOCOL)"
190190
}

0 commit comments

Comments
 (0)