Skip to content

Commit 0233bce

Browse files
committed
tweaks to closing
1 parent 4564064 commit 0233bce

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Methods
137137
7. `emitWithAck(event: String, withItems items: [AnyObject]) -> (UInt64, (NSArray?) -> Void) -> Void` - `emitWithAck` for Objective-C. Note: The message is not sent until you call the returned function.
138138
8. `connect()` - Establishes a connection to the server. A "connect" event is fired upon successful connection.
139139
9. `connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
140-
10. `close(fast fast: Bool)` - Closes the socket. Once a socket is closed it should not be reopened. Pass true to fast if you're closing from a background task.
140+
10. `close()` - Closes the socket. Once a socket is closed it should not be reopened.
141141
11. `reconnect()` - Causes the client to reconnect to the server.
142142
12. `joinNamespace()` - Causes the client to join nsp. Shouldn't need to be called unless you change nsp manually.
143143
13. `leaveNamespace()` - Causes the client to leave the nsp and go back to /

SocketIOClientSwift/SocketIOClient.swift

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,11 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
133133
Will turn off automatic reconnects.
134134
Pass true to fast if you're closing from a background task
135135
*/
136-
public func close(fast fast: Bool) {
136+
public func close() {
137137
Logger.log("Closing socket", type: logType)
138138

139139
reconnects = false
140-
status = SocketIOClientStatus.Closed
141-
engine?.close(fast: fast)
140+
didDisconnect("Closed")
142141
}
143142

144143
/**
@@ -151,8 +150,8 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
151150
/**
152151
Connect to the server. If we aren't connected after timeoutAfter, call handler
153152
*/
154-
public func connect(timeoutAfter timeoutAfter:Int,
155-
withTimeoutHandler handler:(() -> Void)?) {
153+
public func connect(timeoutAfter timeoutAfter: Int,
154+
withTimeoutHandler handler: (() -> Void)?) {
156155
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
157156

158157
guard status != .Connected else {
@@ -222,7 +221,6 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
222221
Logger.log("Disconnected: %@", type: logType, args: reason)
223222

224223
status = .Closed
225-
226224
reconnects = false
227225

228226
// Make sure the engine is actually dead.
@@ -241,8 +239,8 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
241239
/**
242240
Same as close
243241
*/
244-
public func disconnect(fast fast: Bool) {
245-
close(fast: fast)
242+
public func disconnect() {
243+
close()
246244
}
247245

248246
/**

0 commit comments

Comments
 (0)