Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy support #968

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/Engine/Engine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public protocol EngineDelegate: class {

public protocol Engine {
func register(delegate: EngineDelegate)
func start(request: URLRequest)
func start(request: URLRequest, configuration: URLSessionConfiguration?)
func stop(closeCode: UInt16)
func forceStop()
func write(data: Data, opcode: FrameOpCode, completion: (() -> ())?)
Expand Down
5 changes: 3 additions & 2 deletions Sources/Engine/NativeEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class NativeEngine: NSObject, Engine, URLSessionDataDelegate, URLSessionW
self.delegate = delegate
}

public func start(request: URLRequest) {
let session = URLSession(configuration: URLSessionConfiguration.default, delegate: self, delegateQueue: nil)
public func start(request: URLRequest, configuration: URLSessionConfiguration?) {
let sessionConfiguration: URLSessionConfiguration = configuration ?? URLSessionConfiguration.default
let session = URLSession(configuration: sessionConfiguration, delegate: self, delegateQueue: nil)
task = session.webSocketTask(with: request)
doRead()
task?.resume()
Expand Down
2 changes: 1 addition & 1 deletion Sources/Engine/WSEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ FrameCollectorDelegate, HTTPHandlerDelegate {
self.delegate = delegate
}

public func start(request: URLRequest) {
public func start(request: URLRequest, configuration: URLSessionConfiguration?) {
mutex.wait()
let isConnected = canSend
mutex.signal()
Expand Down
3 changes: 2 additions & 1 deletion Sources/Starscream/WebSocket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ open class WebSocket: WebSocketClient, EngineDelegate {
public var onEvent: ((WebSocketEvent) -> Void)?

public var request: URLRequest
public var configuration: URLSessionConfiguration? = nil
// Where the callback is executed. It defaults to the main UI thread queue.
public var callbackQueue = DispatchQueue.main
public var respondToPingWithPong: Bool {
Expand Down Expand Up @@ -127,7 +128,7 @@ open class WebSocket: WebSocketClient, EngineDelegate {

public func connect() {
engine.register(delegate: self)
engine.start(request: request)
engine.start(request: request, configuration: self.configuration)
}

public func disconnect(closeCode: UInt16 = CloseCode.normal.rawValue) {
Expand Down
17 changes: 11 additions & 6 deletions Starscream.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,14 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MARKETING_VERSION = 4.0.4;
OTHER_LDFLAGS = "-all_load";
PRODUCT_BUNDLE_IDENTIFIER = "com.vluxe.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SKIP_INSTALL = NO;
SUPPORTS_MACCATALYST = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
Expand All @@ -467,6 +467,11 @@
33CCF0911F5DDC030099B092 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"ARCHS[sdk=iphoneos*]" = arm64;
"ARCHS[sdk=iphonesimulator*]" = (
x86_64,
arm64,
);
BITCODE_GENERATION_MODE = bitcode;
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
Expand All @@ -475,14 +480,14 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "$(SRCROOT)/Sources/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MARKETING_VERSION = 4.0.4;
OTHER_LDFLAGS = "-all_load";
PRODUCT_BUNDLE_IDENTIFIER = "com.vluxe.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SKIP_INSTALL = NO;
SUPPORTS_MACCATALYST = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
Expand Down Expand Up @@ -540,7 +545,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvos appletvsimulator watchsimulator watchos";
Expand Down Expand Up @@ -593,7 +598,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos macosx appletvos appletvsimulator watchsimulator watchos";
SWIFT_VERSION = 5.0;
Expand Down