tweaks to closing

This commit is contained in:
Erik 2015-09-18 09:27:14 -04:00
parent 456406416a
commit 0233bce881
2 changed files with 7 additions and 9 deletions

View File

@ -137,7 +137,7 @@ Methods
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. 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.
8. `connect()` - Establishes a connection to the server. A "connect" event is fired upon successful connection. 8. `connect()` - Establishes a connection to the server. A "connect" event is fired upon successful connection.
9. `connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called. 9. `connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
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. 10. `close()` - Closes the socket. Once a socket is closed it should not be reopened.
11. `reconnect()` - Causes the client to reconnect to the server. 11. `reconnect()` - Causes the client to reconnect to the server.
12. `joinNamespace()` - Causes the client to join nsp. Shouldn't need to be called unless you change nsp manually. 12. `joinNamespace()` - Causes the client to join nsp. Shouldn't need to be called unless you change nsp manually.
13. `leaveNamespace()` - Causes the client to leave the nsp and go back to / 13. `leaveNamespace()` - Causes the client to leave the nsp and go back to /

View File

@ -133,12 +133,11 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
Will turn off automatic reconnects. Will turn off automatic reconnects.
Pass true to fast if you're closing from a background task Pass true to fast if you're closing from a background task
*/ */
public func close(fast fast: Bool) { public func close() {
Logger.log("Closing socket", type: logType) Logger.log("Closing socket", type: logType)
reconnects = false reconnects = false
status = SocketIOClientStatus.Closed didDisconnect("Closed")
engine?.close(fast: fast)
} }
/** /**
@ -151,8 +150,8 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
/** /**
Connect to the server. If we aren't connected after timeoutAfter, call handler Connect to the server. If we aren't connected after timeoutAfter, call handler
*/ */
public func connect(timeoutAfter timeoutAfter:Int, public func connect(timeoutAfter timeoutAfter: Int,
withTimeoutHandler handler:(() -> Void)?) { withTimeoutHandler handler: (() -> Void)?) {
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)") assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
guard status != .Connected else { guard status != .Connected else {
@ -222,7 +221,6 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
Logger.log("Disconnected: %@", type: logType, args: reason) Logger.log("Disconnected: %@", type: logType, args: reason)
status = .Closed status = .Closed
reconnects = false reconnects = false
// Make sure the engine is actually dead. // Make sure the engine is actually dead.
@ -241,8 +239,8 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
/** /**
Same as close Same as close
*/ */
public func disconnect(fast fast: Bool) { public func disconnect() {
close(fast: fast) close()
} }
/** /**