Skip to content

Commit e8c3e22

Browse files
committed
Merge branch 'development'
* development: fix sid bug Fix #472
2 parents c7c824c + cf12865 commit e8c3e22

File tree

3 files changed

+24
-25
lines changed

3 files changed

+24
-25
lines changed

Diff for: Socket.IO-Client-Swift.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "Socket.IO-Client-Swift"
33
s.module_name = "SocketIOClientSwift"
4-
s.version = "7.0.1"
4+
s.version = "7.0.2"
55
s.summary = "Socket.IO-client for iOS and OS X"
66
s.description = <<-DESC
77
Socket.IO-client for iOS and OS X.
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
1414
s.ios.deployment_target = '8.0'
1515
s.osx.deployment_target = '10.10'
1616
s.tvos.deployment_target = '9.0'
17-
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v7.0.1' }
17+
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v7.0.2' }
1818
s.source_files = "Source/**/*.swift"
1919
s.requires_arc = true
2020
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files

Diff for: Source/SocketEngine.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo
359359
private func handleOpen(openData: String) {
360360
do {
361361
let json = try openData.toNSDictionary()
362-
guard let sid = json[sid] as? String else {
362+
guard let sid = json["sid"] as? String else {
363363
client?.engineDidError("Open packet contained no sid")
364364
return
365365
}

Diff for: Source/SocketIOClient.swift

+21-22
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
6767
return nsp + "#" + (engine?.sid ?? "")
6868
}
6969

70-
/// Type safe way to create a new SocketIOClient. opts can be omitted
70+
/// Type safe way to create a new SocketIOClient. config can be omitted
7171
public init(socketURL: NSURL, config: SocketIOClientConfiguration = []) {
7272
self.config = config
7373
self.socketURL = socketURL
@@ -150,33 +150,33 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
150150
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
151151

152152
dispatch_after(time, handleQueue) {[weak self] in
153-
if let this = self where this.status != .Connected && this.status != .Disconnected {
154-
this.status = .Disconnected
155-
this.engine?.disconnect("Connect timeout")
156-
157-
handler?()
158-
}
153+
guard let this = self where this.status != .Connected && this.status != .Disconnected else { return }
154+
155+
this.status = .Disconnected
156+
this.engine?.disconnect("Connect timeout")
157+
158+
handler?()
159159
}
160160
}
161161

162162
private func createOnAck(items: [AnyObject]) -> OnAckCallback {
163163
currentAck += 1
164164

165165
return {[weak self, ack = currentAck] timeout, callback in
166-
if let this = self {
167-
dispatch_sync(this.ackQueue) {
168-
this.ackHandlers.addAck(ack, callback: callback)
169-
}
170-
166+
guard let this = self else { return }
167+
168+
dispatch_sync(this.ackQueue) {
169+
this.ackHandlers.addAck(ack, callback: callback)
170+
}
171+
172+
173+
this._emit(items, ack: ack)
174+
175+
if timeout != 0 {
176+
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
171177

172-
this._emit(items, ack: ack)
173-
174-
if timeout != 0 {
175-
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
176-
177-
dispatch_after(time, this.ackQueue) {
178-
this.ackHandlers.timeoutAck(ack, onQueue: this.handleQueue)
179-
}
178+
dispatch_after(time, this.ackQueue) {
179+
this.ackHandlers.timeoutAck(ack, onQueue: this.handleQueue)
180180
}
181181
}
182182
}
@@ -196,6 +196,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
196196

197197
DefaultSocketLogger.Logger.log("Disconnected: %@", type: logType, args: reason)
198198

199+
reconnecting = false
199200
status = .Disconnected
200201

201202
// Make sure the engine is actually dead.
@@ -205,8 +206,6 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
205206

206207
/// Disconnects the socket.
207208
public func disconnect() {
208-
assert(status != .NotConnected, "Tried closing a NotConnected client")
209-
210209
DefaultSocketLogger.Logger.log("Closing socket", type: logType)
211210

212211
didDisconnect("Disconnect")

0 commit comments

Comments
 (0)