Skip to content

Commit 3abb265

Browse files
committed
tweak closing engine
1 parent d7d1da7 commit 3abb265

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Methods
109109
5. `emitWithAck(event:String, _ items:AnyObject...) -> (timeout:UInt64, callback:(NSArray?) -> Void) -> Void` - Sends a message that requests an acknowledgement from the server. Returns a function which you can use to add a handler. See example. Note: The message is not sent until you call the returned function.
110110
6. `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.
111111
7. `connect()` - Establishes a connection to the server. A "connect" event is fired upon successful connection.
112-
8. `connect(#timeoutAfter:Int, withTimeoutHandler handler:(() -> Void)?)` - Connect to the server. If it isn't connect after timeoutAfter seconds, the handler is called.
112+
8. `connect(#timeoutAfter:Int, withTimeoutHandler handler:(() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
113113
9. `close(#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.
114114
10. `reconnect()` - Causes the client to reconnect to the server.
115115

SocketIOClientSwift/SocketEngine.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,14 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
119119
self.pingTimer?.invalidate()
120120
self.closed = true
121121

122-
self.write("", withType: PacketType.CLOSE, withData: nil)
123122
self.ws?.disconnect()
124-
self.stopPolling()
125123

126124
if fast || self.polling {
125+
self.write("", withType: PacketType.CLOSE, withData: nil)
127126
self.client?.engineDidClose("Disconnect")
128127
}
128+
129+
self.stopPolling()
129130
}
130131

131132
private func createBinaryDataForSend(data:NSData) -> (NSData?, String?) {

0 commit comments

Comments
 (0)