Skip to content

Commit

Permalink
Merge pull request #330 from socketio/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
nuclearace committed Mar 22, 2016
2 parents 5976ef1 + a53b716 commit 2919d4a
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 100 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url options:@
- Can be used from Objective-C
##Installation
Requires Swift 2/Xcode 7
Requires Swift 2.2/Xcode 7.3
If you need Swift 2.1/Xcode 7.2 use v5.5.0 (Pre-Swift 2.2 support is no longer maintained)
If you need Swift 1.2/Xcode 6.3/4 use v2.4.5 (Pre-Swift 2 support is no longer maintained)
Expand Down Expand Up @@ -86,7 +88,7 @@ Carthage
-----------------
Add this line to your `Cartfile`:
```
github "socketio/socket.io-client-swift" ~> 5.5.0 # Or latest version
github "socketio/socket.io-client-swift" ~> 6.0.0 # Or latest version
```

Run `carthage update --platform ios,macosx`.
Expand All @@ -100,7 +102,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'Socket.IO-Client-Swift', '~> 5.5.0' # Or latest version
pod 'Socket.IO-Client-Swift', '~> 6.0.0' # Or latest version
```

Install pods:
Expand Down Expand Up @@ -128,7 +130,7 @@ CocoaSeeds
Add this line to your `Seedfile`:

```
github "socketio/socket.io-client-swift", "v5.5.0", :files => "Source/*.swift" # Or latest version
github "socketio/socket.io-client-swift", "v6.0.0", :files => "Source/*.swift" # Or latest version
```

Run `seed install`.
Expand Down
4 changes: 2 additions & 2 deletions Socket.IO-Client-Swift.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "Socket.IO-Client-Swift"
s.module_name = "SocketIOClientSwift"
s.version = "5.5.0"
s.version = "6.0.0"
s.summary = "Socket.IO-client for iOS and OS X"
s.description = <<-DESC
Socket.IO-client for iOS and OS X.
Expand All @@ -14,7 +14,7 @@ Pod::Spec.new do |s|
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.tvos.deployment_target = '9.0'
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v5.5.0' }
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.0.0' }
s.source_files = "Source/**/*.swift"
s.requires_arc = true
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
Expand Down
2 changes: 1 addition & 1 deletion SocketIO-MacTests/SocketParserTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class SocketParserTest: XCTestCase {
func validateParseResult(message: String) {
let validValues = SocketParserTest.packetTypes[message]!
let packet = testSocket.parseString(message)
let type = message.substringWithRange(Range<String.Index>(start: message.startIndex, end: message.startIndex.advancedBy(1)))
let type = message.substringWithRange(Range<String.Index>(message.startIndex..<message.startIndex.advancedBy(1)))
if case let .Right(packet) = packet {
XCTAssertEqual(packet.type, SocketPacket.PacketType(rawValue: Int(type) ?? -1)!)
XCTAssertEqual(packet.nsp, validValues.0)
Expand Down
6 changes: 5 additions & 1 deletion Source/SocketEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,10 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb

DefaultSocketLogger.Logger.log("Engine is being closed.", type: logType)

if closed {
return postSendClose(nil, nil, nil)
}

if websocket {
sendWebSocketMessage("", withType: .Close, withData: [])
postSendClose(nil, nil, nil)
Expand Down Expand Up @@ -502,7 +506,7 @@ public final class SocketEngine: NSObject, SocketEnginePollable, SocketEngineWeb

dispatch_async(dispatch_get_main_queue()) {
self.pingTimer = NSTimer.scheduledTimerWithTimeInterval(pingInterval, target: self,
selector: Selector("sendPing"), userInfo: nil, repeats: true)
selector: #selector(SocketEngine.sendPing), userInfo: nil, repeats: true)
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions Source/SocketEnginePollable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,19 @@ extension SocketEnginePollable {
}

func doRequest(req: NSURLRequest, withCallback callback: (NSData?, NSURLResponse?, NSError?) -> Void) {
if !polling || closed || invalidated {
DefaultSocketLogger.Logger.error("Tried to do polling request when not supposed to", type: "SocketEnginePolling")
return
}
DefaultSocketLogger.Logger.log("Doing polling request", type: "SocketEnginePolling")
session?.dataTaskWithRequest(req, completionHandler: callback).resume()
if !polling || closed || invalidated || fastUpgrade {
DefaultSocketLogger.Logger.error("Tried to do polling request when not supposed to", type: "SocketEnginePolling")
return
}

DefaultSocketLogger.Logger.log("Doing polling request", type: "SocketEnginePolling")

session?.dataTaskWithRequest(req, completionHandler: callback).resume()
}

func doLongPoll(req: NSURLRequest) {
doRequest(req) {[weak self] data, res, err in
guard let this = self else { return }
guard let this = self where this.polling else { return }

if err != nil || data == nil {
DefaultSocketLogger.Logger.error(err?.localizedDescription ?? "Error", type: "SocketEnginePolling")
Expand All @@ -123,7 +123,7 @@ extension SocketEnginePollable {

return
}

DefaultSocketLogger.Logger.log("Got polling response", type: "SocketEnginePolling")

if let str = String(data: data!, encoding: NSUTF8StringEncoding) {
Expand Down
Loading

0 comments on commit 2919d4a

Please sign in to comment.