update for beta 4

This commit is contained in:
Erik 2016-08-02 19:38:08 -04:00
parent a5db13c8b5
commit 61a20cf27e
No known key found for this signature in database
GPG Key ID: 4930B7C5FBC1A69D
7 changed files with 23 additions and 23 deletions

View File

@ -66,7 +66,7 @@ public class SSLSecurity : NSObject {
- returns: a representation security object to be used with
*/
public convenience init(usePublicKeys: Bool = false) {
let paths = Bundle.main.pathsForResources(ofType: "cer", inDirectory: ".")
let paths = Bundle.main.paths(forResourcesOfType: "cer", inDirectory: ".")
let certs = paths.reduce([SSLCert]()) { (certs: [SSLCert], path: String) -> [SSLCert] in
var certs = certs
@ -93,7 +93,7 @@ public class SSLSecurity : NSObject {
self.usePublicKeys = usePublicKeys
if self.usePublicKeys {
DispatchQueue.global(attributes: DispatchQueue.GlobalAttributes.qosDefault).async {
DispatchQueue.global(qos: .default).async {
let pubKeys = certs.reduce([SecKey]()) { (pubKeys: [SecKey], cert: SSLCert) -> [SecKey] in
var pubKeys = pubKeys
if let data = cert.certData, cert.key == nil {

View File

@ -25,9 +25,9 @@
import Foundation
public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, SocketEngineWebsocket {
public let emitQueue = DispatchQueue(label: "com.socketio.engineEmitQueue", attributes: DispatchQueueAttributes.serial)
public let handleQueue = DispatchQueue(label: "com.socketio.engineHandleQueue", attributes: DispatchQueueAttributes.serial)
public let parseQueue = DispatchQueue(label: "com.socketio.engineParseQueue", attributes: DispatchQueueAttributes.serial)
public let emitQueue = DispatchQueue(label: "com.socketio.engineEmitQueue", attributes: [])
public let handleQueue = DispatchQueue(label: "com.socketio.engineHandleQueue", attributes: [])
public let parseQueue = DispatchQueue(label: "com.socketio.engineParseQueue", attributes: [])
public var connectParams: [String: AnyObject]? {
didSet {
@ -218,8 +218,8 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll
return (URL(string: "http://localhost/")!, URL(string: "http://localhost/")!)
}
var urlPolling = URLComponents(string: url.absoluteString!)!
var urlWebSocket = URLComponents(string: url.absoluteString!)!
var urlPolling = URLComponents(string: url.absoluteString)!
var urlWebSocket = URLComponents(string: url.absoluteString)!
var queryString = ""
urlWebSocket.path = socketPath
@ -482,7 +482,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll
write("", withType: .ping, withData: [])
let time = DispatchTime.now() + Double(Int64(pingInterval * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
DispatchQueue.main.after(when: time) {[weak self] in self?.sendPing() }
DispatchQueue.main.asyncAfter(deadline: time) {[weak self] in self?.sendPing() }
}
}

View File

@ -100,7 +100,7 @@ extension SocketEnginePollable {
doLongPoll(for: req )
}
func doRequest(for req: URLRequest, callbackWith callback: (Data?, URLResponse?, NSError?) -> Void) {
func doRequest(for req: URLRequest, callbackWith callback: (Data?, URLResponse?, Error?) -> Void) {
if !polling || closed || invalidated || fastUpgrade {
return
}

View File

@ -24,7 +24,7 @@
import Foundation
enum JSONError : ErrorProtocol {
enum JSONError : Error {
case notArray
case notNSDictionary
}

View File

@ -49,10 +49,10 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
return nsp + "#" + (engine?.sid ?? "")
}
private let ackQueue = DispatchQueue(label: "com.socketio.ackQueue", attributes: .serial)
private let emitQueue = DispatchQueue(label: "com.socketio.emitQueue", attributes: .serial)
private let ackQueue = DispatchQueue(label: "com.socketio.ackQueue", attributes: [])
private let emitQueue = DispatchQueue(label: "com.socketio.emitQueue", attributes: [])
private let logType = "SocketIOClient"
private let parseQueue = DispatchQueue(label: "com.socketio.parseQueue", attributes: .serial)
private let parseQueue = DispatchQueue(label: "com.socketio.parseQueue", attributes: [])
private var anyHandler: ((SocketAnyEvent) -> Void)?
private var currentReconnectAttempt = 0
@ -71,7 +71,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
self.options = options
self.socketURL = socketURL
if socketURL.absoluteString?.hasPrefix("https://") ?? false {
if socketURL.absoluteString.hasPrefix("https://") ?? false {
self.options.insertIgnore(.secure(true))
}
@ -149,7 +149,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
let time = DispatchTime.now() + Double(Int64(timeoutAfter) * Int64(NSEC_PER_SEC)) / Double(NSEC_PER_SEC)
handleQueue.after(when: time) {[weak self] in
handleQueue.asyncAfter(deadline: time) {[weak self] in
if let this = self, this.status != .connected && this.status != .disconnected {
this.status = .disconnected
this.engine?.disconnect(reason: "Connect timeout")
@ -174,7 +174,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
if timeout != 0 {
let time = DispatchTime.now() + Double(Int64(timeout * NSEC_PER_SEC)) / Double(NSEC_PER_SEC)
this.handleQueue.after(when: time) {
this.handleQueue.asyncAfter(deadline: time) {
this.ackHandlers.timeoutAck(ack, onQueue: this.handleQueue)
}
}
@ -443,7 +443,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
let dispatchAfter = DispatchTime.now() + Double(Int64(UInt64(reconnectWait) * NSEC_PER_SEC)) / Double(NSEC_PER_SEC)
DispatchQueue.main.after(when: dispatchAfter, execute: _tryReconnect)
DispatchQueue.main.asyncAfter(deadline: dispatchAfter, execute: _tryReconnect)
}
}

View File

@ -152,7 +152,7 @@ struct SocketPacket {
if dict["_placeholder"] as? Bool ?? false {
return binary[dict["num"] as! Int]
} else {
return dict.reduce(NSMutableDictionary(), combine: {cur, keyValue in
return dict.reduce(NSMutableDictionary(), {cur, keyValue in
cur[keyValue.0 as! NSCopying] = _fillInPlaceholders(keyValue.1)
return cur
})
@ -202,7 +202,7 @@ private extension SocketPacket {
case let arr as [AnyObject]:
return arr.map({shred($0, binary: &binary)}) as AnyObject
case let dict as NSDictionary:
return dict.reduce(NSMutableDictionary(), combine: {cur, keyValue in
return dict.reduce(NSMutableDictionary(), {cur, keyValue in
cur[keyValue.0 as! NSCopying] = shred(keyValue.1, binary: &binary)
return cur
})

View File

@ -136,7 +136,7 @@ public class WebSocket : NSObject, StreamDelegate {
private var certValidated = false
private var didDisconnect = false
private var readyToWrite = false
private let mutex = Lock()
private let mutex = NSLock()
private let notificationCenter = NotificationCenter.default
private var canDispatch: Bool {
mutex.lock()
@ -145,7 +145,7 @@ public class WebSocket : NSObject, StreamDelegate {
return canWork
}
//the shared processing queue used for all websocket
private static let sharedWorkQueue = DispatchQueue(label: "com.vluxe.starscream.websocket", attributes: DispatchQueueAttributes.serial)
private static let sharedWorkQueue = DispatchQueue(label: "com.vluxe.starscream.websocket", attributes: [])
//used for setting protocols.
public init(url: URL, protocols: [String]? = nil) {
@ -176,7 +176,7 @@ public class WebSocket : NSObject, StreamDelegate {
public func disconnect(_ forceTimeout: TimeInterval? = nil) {
switch forceTimeout {
case .some(let seconds) where seconds > 0:
queue.after(when: DispatchTime.now() + Double(Int64(seconds * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)) { [weak self] in
queue.asyncAfter(deadline: DispatchTime.now() + Double(Int64(seconds * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)) { [weak self] in
self?.disconnectStream(nil)
}
fallthrough
@ -798,7 +798,7 @@ public class WebSocket : NSObject, StreamDelegate {
if len < 0 {
var error: NSError?
if let streamError = outStream.streamError {
error = streamError
error = streamError as NSError
} else {
let errCode = InternalErrorCode.outputStreamWriteError.rawValue
error = s.errorWithDetail("output stream error during write", code: errCode)