Don't use NSDictionary in definitions
This commit is contained in:
parent
846e7cb0aa
commit
cf597ae09d
@ -163,7 +163,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll
|
|||||||
/// - parameter client: The client for this engine.
|
/// - parameter client: The client for this engine.
|
||||||
/// - parameter url: The url for this engine.
|
/// - parameter url: The url for this engine.
|
||||||
/// - parameter options: The options for this engine.
|
/// - parameter options: The options for this engine.
|
||||||
public convenience init(client: SocketEngineClient, url: URL, options: NSDictionary?) {
|
public convenience init(client: SocketEngineClient, url: URL, options: [String: Any]?) {
|
||||||
self.init(client: client, url: url, config: options?.toSocketConfiguration() ?? [])
|
self.init(client: client, url: url, config: options?.toSocketConfiguration() ?? [])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,7 @@ import Starscream
|
|||||||
/// - parameter client: The client for this engine.
|
/// - parameter client: The client for this engine.
|
||||||
/// - parameter url: The url for this engine.
|
/// - parameter url: The url for this engine.
|
||||||
/// - parameter options: The options for this engine.
|
/// - parameter options: The options for this engine.
|
||||||
init(client: SocketEngineClient, url: URL, options: NSDictionary?)
|
init(client: SocketEngineClient, url: URL, options: [String: Any]?)
|
||||||
|
|
||||||
/// Starts the connection to the server.
|
/// Starts the connection to the server.
|
||||||
func connect()
|
func connect()
|
||||||
|
|||||||
@ -150,8 +150,8 @@ open class SocketManager : NSObject, SocketManagerSpec, SocketParsable, SocketDa
|
|||||||
/// - parameter socketURL: The url of the socket.io server.
|
/// - parameter socketURL: The url of the socket.io server.
|
||||||
/// - parameter config: The config for this socket.
|
/// - parameter config: The config for this socket.
|
||||||
@objc
|
@objc
|
||||||
public convenience init(socketURL: NSURL, config: NSDictionary?) {
|
public convenience init(socketURL: URL, config: [String: Any]?) {
|
||||||
self.init(socketURL: socketURL as URL, config: config?.toSocketConfiguration() ?? [])
|
self.init(socketURL: socketURL, config: config?.toSocketConfiguration() ?? [])
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
|
|||||||
@ -42,7 +42,7 @@ extension CharacterSet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension NSDictionary {
|
extension Dictionary where Key == String, Value == Any {
|
||||||
private static func keyValueToSocketIOClientOption(key: String, value: Any) -> SocketIOClientOption? {
|
private static func keyValueToSocketIOClientOption(key: String, value: Any) -> SocketIOClientOption? {
|
||||||
switch (key, value) {
|
switch (key, value) {
|
||||||
case let ("connectParams", params as [String: Any]):
|
case let ("connectParams", params as [String: Any]):
|
||||||
@ -90,7 +90,7 @@ extension NSDictionary {
|
|||||||
var options = [] as SocketIOClientConfiguration
|
var options = [] as SocketIOClientConfiguration
|
||||||
|
|
||||||
for (rawKey, value) in self {
|
for (rawKey, value) in self {
|
||||||
if let key = rawKey as? String, let opt = NSDictionary.keyValueToSocketIOClientOption(key: key, value: value) {
|
if let opt = Dictionary.keyValueToSocketIOClientOption(key: rawKey, value: value) {
|
||||||
options.insert(opt)
|
options.insert(opt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -463,7 +463,7 @@ class TestEngine : SocketEngineSpec {
|
|||||||
private(set) var websocket = false
|
private(set) var websocket = false
|
||||||
private(set) var ws: WebSocket? = nil
|
private(set) var ws: WebSocket? = nil
|
||||||
|
|
||||||
required init(client: SocketEngineClient, url: URL, options: NSDictionary?) {
|
required init(client: SocketEngineClient, url: URL, options: [String: Any]?) {
|
||||||
self.client = client
|
self.client = client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,6 +11,13 @@
|
|||||||
|
|
||||||
@implementation ManagerObjectiveCTest
|
@implementation ManagerObjectiveCTest
|
||||||
|
|
||||||
|
- (void)testSettingConfig {
|
||||||
|
NSURL* url = [[NSURL alloc] initWithString:@"http://localhost"];
|
||||||
|
self.manager = [[TestManager alloc] initWithSocketURL:url config:@{@"forceNew": @YES}];
|
||||||
|
|
||||||
|
XCTAssertTrue(self.manager.forceNew);
|
||||||
|
}
|
||||||
|
|
||||||
- (void)testManagerProperties {
|
- (void)testManagerProperties {
|
||||||
XCTAssertNotNil(self.manager.defaultSocket);
|
XCTAssertNotNil(self.manager.defaultSocket);
|
||||||
XCTAssertNil(self.manager.engine);
|
XCTAssertNil(self.manager.engine);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user