Skip to content

Commit 88c139e

Browse files
committed
clean up
1 parent fdfd4db commit 88c139e

File tree

3 files changed

+25
-38
lines changed

3 files changed

+25
-38
lines changed

SocketIOClientSwift/SocketEngine.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,11 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
493493
}
494494
} else if type == PacketType.NOOP {
495495
self.doPoll()
496-
return
497496
} else if type == PacketType.PONG {
498497
// We should upgrade
499498
if message == "3probe" {
500499
self.upgradeTransport()
501-
return
502500
}
503-
504-
return
505501
} else if type == PacketType.OPEN {
506502
var err:NSError?
507503

@@ -531,8 +527,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
531527
if !self.forceWebsockets {
532528
self.doPoll()
533529
}
534-
535-
return
536530
} else if type == PacketType.CLOSE {
537531
if self.client == nil {
538532
return
@@ -541,8 +535,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
541535
if self.polling {
542536
self.client!.engineDidClose("Disconnect")
543537
}
544-
545-
return
546538
} else if message.hasPrefix("b4") {
547539
// binary in base64 string
548540
message.removeRange(Range<String.Index>(start: message.startIndex,

SocketIOClientSwift/SocketIOClient.swift

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -89,40 +89,36 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
8989
self.opts = opts
9090

9191
// Set options
92-
if opts != nil {
93-
if let sessionDelegate = opts!["sessionDelegate"] as? NSURLSessionDelegate {
94-
self.sessionDelegate = sessionDelegate
95-
}
96-
97-
if let log = opts!["log"] as? Bool {
98-
self.log = log
99-
}
100-
101-
if var nsp = opts!["nsp"] as? String {
102-
if nsp != "/" && nsp.hasPrefix("/") {
103-
nsp.removeAtIndex(nsp.startIndex)
104-
}
105-
106-
self.nsp = nsp
107-
}
108-
109-
if let reconnects = opts!["reconnects"] as? Bool {
110-
self.reconnects = reconnects
111-
}
112-
113-
if let reconnectAttempts = opts!["reconnectAttempts"] as? Int {
114-
self.reconnectAttempts = reconnectAttempts
115-
} else {
116-
self.reconnectAttempts = -1
92+
if let sessionDelegate = opts?["sessionDelegate"] as? NSURLSessionDelegate {
93+
self.sessionDelegate = sessionDelegate
94+
}
95+
96+
if let log = opts?["log"] as? Bool {
97+
self.log = log
98+
}
99+
100+
if var nsp = opts?["nsp"] as? String {
101+
if nsp != "/" && nsp.hasPrefix("/") {
102+
nsp.removeAtIndex(nsp.startIndex)
117103
}
118104

119-
if let reconnectWait = opts!["reconnectWait"] as? Int {
120-
self.reconnectWait = abs(reconnectWait)
121-
}
105+
self.nsp = nsp
106+
}
107+
108+
if let reconnects = opts?["reconnects"] as? Bool {
109+
self.reconnects = reconnects
110+
}
111+
112+
if let reconnectAttempts = opts?["reconnectAttempts"] as? Int {
113+
self.reconnectAttempts = reconnectAttempts
122114
} else {
123115
self.reconnectAttempts = -1
124116
}
125117

118+
if let reconnectWait = opts?["reconnectWait"] as? Int {
119+
self.reconnectWait = abs(reconnectWait)
120+
}
121+
126122
super.init()
127123
}
128124

SocketIOClientSwift/SocketPacket.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ final class SocketPacket: Printable {
9494

9595
func createMessageForEvent(event:String) -> String {
9696
let message:String
97-
var jsonSendError:NSError?
9897

9998
if self.binary.count == 0 {
10099
self.type = PacketType.EVENT
@@ -157,7 +156,7 @@ final class SocketPacket: Printable {
157156
return self.completeMessage(msg, ack: true)
158157
}
159158

160-
func completeMessage(var message:String, ack:Bool = false) -> String {
159+
private func completeMessage(var message:String, ack:Bool = false) -> String {
161160
var err:NSError?
162161

163162
if self.data == nil || self.data!.count == 0 {

0 commit comments

Comments
 (0)