Skip to content

Commit 1f05bde

Browse files
committedMar 13, 2015
small tweaks
1 parent 5b019a9 commit 1f05bde

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed
 

‎SwiftIO/SocketEngine.swift

+1-5
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ public class SocketEngine: NSObject, WebSocketDelegate {
180180

181181
if let str = NSString(data: data, encoding: NSUTF8StringEncoding) as? String {
182182
// println(str)
183-
184-
185183
dispatch_async(self!.parseQueue) {callback(str)}
186184
}
187185

@@ -196,8 +194,6 @@ public class SocketEngine: NSObject, WebSocketDelegate {
196194
}.resume()
197195
}
198196

199-
200-
201197
private func flushProbeWait() {
202198
// println("flushing probe wait")
203199
dispatch_async(self.emitQueue) {[weak self] in
@@ -464,7 +460,7 @@ public class SocketEngine: NSObject, WebSocketDelegate {
464460
}
465461
}
466462

467-
func send(msg:String, datas:[NSData]? = nil) {
463+
public func send(msg:String, datas:[NSData]? = nil) {
468464
let _send = {[weak self] (msg:String, datas:[NSData]?) -> () -> Void in
469465
return {
470466
if self == nil || !self!.connected {

‎SwiftIO/SocketEvent.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class SocketEvent {
226226
// We have multiple items
227227
// Do it live
228228
let argsAsArray = "[\(self.args)]"
229-
if let parsedArr = SocketIOClient.parseData(argsAsArray) as? NSArray {
229+
if let parsedArr = SocketParser.parseData(argsAsArray) as? NSArray {
230230
var returnArr = [AnyObject](count: parsedArr.count, repeatedValue: 0)
231231

232232
for i in 0..<parsedArr.count {

‎SwiftIO/SocketIOClient.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ public class SocketIOClient: NSObject {
160160
self.reconnectTimer = nil
161161
self._sid = self.engine?.sid
162162

163+
// Don't handle as internal because something crazy could happen where
164+
// we disconnect before it's handled
163165
self.handleEvent("connect", data: nil, isInternalMessage: false)
164166
}
165167

@@ -247,7 +249,7 @@ public class SocketIOClient: NSObject {
247249
}
248250

249251
// If the server wants to know that the client received data
250-
internal func emitAck(ack:Int, withData data:[AnyObject]?, withAckType ackType:Int) {
252+
func emitAck(ack:Int, withData data:[AnyObject]?, withAckType ackType:Int) {
251253
dispatch_async(self.ackQueue) {[weak self] in
252254
if self == nil || !self!.connected || data == nil {
253255
return
@@ -281,7 +283,7 @@ public class SocketIOClient: NSObject {
281283
}
282284

283285
// Called when the socket gets an ack for something it sent
284-
internal func handleAck(ack:Int, data:AnyObject?) {
286+
func handleAck(ack:Int, data:AnyObject?) {
285287
self.ackHandlers = self.ackHandlers.filter {handler in
286288
if handler.ackNum != ack {
287289
return true
@@ -373,7 +375,7 @@ public class SocketIOClient: NSObject {
373375
}
374376

375377
// Something happened while polling
376-
internal func pollingDidFail(err:NSError?) {
378+
func pollingDidFail(err:NSError?) {
377379
if !self.reconnecting {
378380
self._connected = false
379381
self.handleEvent("reconnect", data: err?.localizedDescription, isInternalMessage: true)
@@ -382,7 +384,7 @@ public class SocketIOClient: NSObject {
382384
}
383385

384386
// We lost connection and should attempt to reestablish
385-
internal func tryReconnect() {
387+
func tryReconnect() {
386388
if self.reconnectAttempts != -1 && self.currentReconnectAttempt + 1 > self.reconnectAttempts {
387389
self.didForceClose()
388390
return

‎SwiftIO/SocketParser.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ class SocketParser {
202202
socket.joinNamespace()
203203
return
204204
} else {
205-
// Don't handle as internal because something crazy could happen where
206-
// we disconnect before it's handled
207205
socket.didConnect()
208206
return
209207
}
@@ -225,7 +223,8 @@ class SocketParser {
225223
if messageGroups[3] != "" {
226224
ackNum = messageGroups[3]
227225
} else {
228-
let range = Range<String.Index>(start: mesNum.startIndex, end: advance(mesNum.startIndex, 1))
226+
let range = Range<String.Index>(start: mesNum.startIndex,
227+
end: advance(mesNum.startIndex, 1))
229228
mesNum.replaceRange(range, with: "")
230229
ackNum = mesNum
231230
}

0 commit comments

Comments
 (0)
Please sign in to comment.