Skip to content

Commit 047600e

Browse files
feat engine add force close without message
1 parent 1b2247e commit 047600e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Source/SocketIO/Engine/SocketEngine.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,15 @@ open class SocketEngine: NSObject, WebSocketDelegate, URLSessionDelegate,
335335
}
336336
}
337337

338+
/// Force close engine.
339+
///
340+
/// - parameter reason: The reason for the disconnection. This is communicated up to the client.
341+
open func close(reason: String) {
342+
guard connected && !closed else { return closeOutEngine(reason: reason) }
343+
DefaultSocketLogger.Logger.log("Engine is being foce closed.", type: SocketEngine.logType)
344+
closeOutEngine(reason: reason)
345+
}
346+
338347
private func _disconnect(reason: String) {
339348
guard connected && !closed else { return closeOutEngine(reason: reason) }
340349

Source/SocketIO/Engine/SocketEngineSpec.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ public protocol SocketEngineSpec: AnyObject {
113113
/// - parameter reason: The reason for the disconnection. This is communicated up to the client.
114114
func disconnect(reason: String)
115115

116+
/// Force close engine.
117+
///
118+
/// - parameter reason: The reason for the disconnection. This is communicated up to the client.
119+
func close(reason: String)
120+
116121
/// Called to switch from HTTP long-polling to WebSockets. After calling this method the engine will be in
117122
/// WebSocket mode.
118123
///

0 commit comments

Comments
 (0)