From be43b0ab3c5b0ee51ac731b4e74af27f833a520f Mon Sep 17 00:00:00 2001 From: Erik Little Date: Sat, 31 Mar 2018 11:16:58 -0400 Subject: [PATCH] open engine --- CHANGELOG.md | 5 +++++ Source/SocketIO/Engine/SocketEngine.swift | 21 ++++++++++----------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfaf269..d7a3dc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# v13.2.0 + +- Add ability to bypass Data inspection in emits. [#992]((https://github.com/socketio/socket.io-client-swift/issues/992)) +- Allow `SocketEngine` to be subclassed + # v13.1.3 - Fix setting reconnectAttempts [#989]((https://github.com/socketio/socket.io-client-swift/issues/989)) diff --git a/Source/SocketIO/Engine/SocketEngine.swift b/Source/SocketIO/Engine/SocketEngine.swift index fc1c1ad..4904ee5 100644 --- a/Source/SocketIO/Engine/SocketEngine.swift +++ b/Source/SocketIO/Engine/SocketEngine.swift @@ -28,8 +28,7 @@ import Starscream /// The class that handles the engine.io protocol and transports. /// See `SocketEnginePollable` and `SocketEngineWebsocket` for transport specific methods. -public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, SocketEngineWebsocket, - ConfigSettable { +open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, SocketEngineWebsocket, ConfigSettable { // MARK: Properties private static let logType = "SocketEngine" @@ -164,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: [String: Any]?) { + public required convenience init(client: SocketEngineClient, url: URL, options: [String: Any]?) { self.init(client: client, url: url, config: options?.toSocketConfiguration() ?? []) } @@ -214,7 +213,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll } /// Starts the connection to the server. - public func connect() { + open func connect() { engineQueue.async { self._connect() } @@ -318,7 +317,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll } /// Called when an error happens during execution. Causes a disconnection. - public func didError(reason: String) { + open func didError(reason: String) { DefaultSocketLogger.Logger.error("\(reason)", type: SocketEngine.logType) client?.engineDidError(reason: reason) disconnect(reason: reason) @@ -327,7 +326,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll /// Disconnects from the server. /// /// - parameter reason: The reason for the disconnection. This is communicated up to the client. - public func disconnect(reason: String) { + open func disconnect(reason: String) { engineQueue.async { self._disconnect(reason: reason) } @@ -359,7 +358,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll /// WebSocket mode. /// /// **You shouldn't call this directly** - public func doFastUpgrade() { + open func doFastUpgrade() { if waitingForPoll { DefaultSocketLogger.Logger.error("Outstanding poll when switched to WebSockets," + "we'll probably disconnect soon. You should report this.", type: SocketEngine.logType) @@ -392,7 +391,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll /// the engine is attempting to upgrade to WebSocket it does not do any POSTing. /// /// **You shouldn't call this directly** - public func flushWaitingForPostToWebSocket() { + open func flushWaitingForPostToWebSocket() { guard let ws = self.ws else { return } for msg in postWait { @@ -474,7 +473,7 @@ public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePoll /// Parses raw binary received from engine.io. /// /// - parameter data: The data to parse. - public func parseEngineData(_ data: Data) { + open func parseEngineData(_ data: Data) { DefaultSocketLogger.Logger.log("Got binary data: \(data)", type: SocketEngine.logType) client?.parseEngineBinaryData(data.subdata(in: 1..