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 url: The url 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() ?? [])
|
||||
}
|
||||
|
||||
|
||||
@ -90,7 +90,7 @@ import Starscream
|
||||
/// - parameter client: The client for this engine.
|
||||
/// - parameter url: The url 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.
|
||||
func connect()
|
||||
|
||||
@ -150,8 +150,8 @@ open class SocketManager : NSObject, SocketManagerSpec, SocketParsable, SocketDa
|
||||
/// - parameter socketURL: The url of the socket.io server.
|
||||
/// - parameter config: The config for this socket.
|
||||
@objc
|
||||
public convenience init(socketURL: NSURL, config: NSDictionary?) {
|
||||
self.init(socketURL: socketURL as URL, config: config?.toSocketConfiguration() ?? [])
|
||||
public convenience init(socketURL: URL, config: [String: Any]?) {
|
||||
self.init(socketURL: socketURL, config: config?.toSocketConfiguration() ?? [])
|
||||
}
|
||||
|
||||
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? {
|
||||
switch (key, value) {
|
||||
case let ("connectParams", params as [String: Any]):
|
||||
@ -90,7 +90,7 @@ extension NSDictionary {
|
||||
var options = [] as SocketIOClientConfiguration
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@ -463,7 +463,7 @@ class TestEngine : SocketEngineSpec {
|
||||
private(set) var websocket = false
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,13 @@
|
||||
|
||||
@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 {
|
||||
XCTAssertNotNil(self.manager.defaultSocket);
|
||||
XCTAssertNil(self.manager.engine);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user