Compare commits

...
13 Commits
Author SHA1 Message Date
Erik 8320e296e9 bump version again 2015-09-08 09:30:33 -04:00
Erik 31a2079222 fix warning 2015-09-08 09:22:37 -04:00
Erik c9d26ebd65 bump version 2015-09-08 09:20:29 -04:00
Erik 77e1da2b51 fix socketio/socket.io-client-swift#166 2015-09-08 09:19:17 -04:00
Erik 17426c1432 fix socketio/socket.io-client-swift#152 2015-08-31 09:22:56 -04:00
Erik 46cea36df7 bump version 2015-08-17 00:15:39 -04:00
Erik 6ee1daeaf7 fix bug in websocket library 2015-08-17 00:09:04 -04:00
Erik 0fd8a9540b don't remove engine 2015-08-10 11:00:22 -04:00
Erik c38412cae6 bump version 2015-08-05 12:27:46 -04:00
Erik 8bde261acb fix socketio/socket.io-client-swift#137 2015-08-05 12:25:37 -04:00
Erik 9b9becebae bump version 2015-08-05 06:14:44 -04:00
Erik ffbe1e4ec4 add option for handle queue 2015-08-05 06:09:24 -04:00
Erik e792006245 change to default session config 2015-07-27 18:50:12 -04:00
7 changed files with 43 additions and 25 deletions

No files matched your search

+3 -2
View File
@@ -60,7 +60,7 @@ Carthage
-----------------
Add this line to your `Cartfile`:
```
github "socketio/socket.io-client-swift" ~> 2.4.0 # Or latest version
github "socketio/socket.io-client-swift" ~> 2.4.5 # Or latest version
```
Run `carthage update`.
@@ -79,7 +79,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Socket.IO-Client-Swift', '~> 2.4.0' # Or latest version
pod 'Socket.IO-Client-Swift', '~> 2.4.5' # Or latest version
```
Install pods:
@@ -121,6 +121,7 @@ Options
- `sessionDelegate: NSURLSessionDelegate` Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.
- `path: String` - If the server uses a custom path. ex: `"/swift"`. Default is `""`
- `extraHeaders: [String: String]?` - Adds custom headers to the initial request. Default is nil.
- `handleQueue: dispatch_queue_t` - The dispatch queue that handlers are run on. Default is the main queue.
Methods
-------
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Socket.IO-Client-Swift"
s.version = "2.4.0"
s.version = "2.4.5"
s.summary = "Socket.IO-client for iOS and OS X"
s.description = <<-DESC
Socket.IO-client for iOS and OS X.
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
s.author = { "Erik" => "nuclear.ace@gmail.com" }
s.ios.deployment_target = '8.0'
s.osx.deployment_target = '10.10'
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.4.0' }
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.4.5' }
s.source_files = "SocketIOClientSwift/**/*.swift"
s.requires_arc = true
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
+11 -3
View File
@@ -99,7 +99,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
public init(client:SocketEngineClient, sessionDelegate:NSURLSessionDelegate?) {
self.client = client
self.session = NSURLSession(configuration: NSURLSessionConfiguration.ephemeralSessionConfiguration(),
self.session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration(),
delegate: sessionDelegate, delegateQueue: workQueue)
}
@@ -414,17 +414,25 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
if let json = NSJSONSerialization.JSONObjectWithData(mesData,
options: NSJSONReadingOptions.AllowFragments,
error: &err) as? NSDictionary, sid = json["sid"] as? String {
let upgradeWs: Bool
self.sid = sid
_connected = true
if !forcePolling && !forceWebsockets {
createWebsocket(andConnect: true)
if let upgrades = json["upgrades"] as? [String] {
upgradeWs = upgrades.filter {$0 == "websocket"}.count != 0
} else {
upgradeWs = false
}
if let pingInterval = json["pingInterval"] as? Double, pingTimeout = json["pingTimeout"] as? Double {
self.pingInterval = pingInterval / 1000.0
self.pingTimeout = pingTimeout / 1000.0
}
if !forcePolling && !forceWebsockets && upgradeWs {
createWebsocket(andConnect: true)
}
} else {
client?.didError("Engine failed to handshake")
return
+1 -3
View File
@@ -40,8 +40,6 @@ final class SocketEventHandler {
func executeCallback(_ items:NSArray? = nil, withAck ack:Int? = nil, withAckType type:Int? = nil,
withSocket socket:SocketIOClient? = nil) {
dispatch_async(dispatch_get_main_queue()) {[weak self] in
self?.callback?(items, ack != nil ? emitAckCallback(socket!, ack!) : nil)
}
self.callback?(items, ack != nil ? emitAckCallback(socket!, ack!) : nil)
}
}
+22 -13
View File
@@ -46,7 +46,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
public let socketURL:String
public let handleAckQueue = dispatch_queue_create("handleAckQueue", DISPATCH_QUEUE_SERIAL)
public let handleQueue = dispatch_queue_create("handleQueue", DISPATCH_QUEUE_SERIAL)
public let handleQueue: dispatch_queue_attr_t!
public let emitQueue = dispatch_queue_create("emitQueue", DISPATCH_QUEUE_SERIAL)
public var closed:Bool {
return _closed
@@ -121,6 +121,12 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
self.reconnectWait = abs(reconnectWait)
}
if let handleQueue = opts?["handleQueue"] as? dispatch_queue_t {
self.handleQueue = handleQueue
} else {
self.handleQueue = dispatch_get_main_queue()
}
super.init()
}
@@ -157,7 +163,6 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
_connected = false
_reconnecting = false
engine?.close(fast: fast)
engine = nil
}
/**
@@ -393,7 +398,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
args: event, data ?? "")
if anyHandler != nil {
dispatch_async(dispatch_get_main_queue()) {[weak self] in
dispatch_async(handleQueue) {[weak self] in
self?.anyHandler?(SocketAnyEvent(event: event, items: data))
}
}
@@ -401,9 +406,13 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
for handler in handlers {
if handler.event == event {
if ack != nil {
handler.executeCallback(data, withAck: ack!, withSocket: self)
dispatch_async(handleQueue) {[weak self] in
handler.executeCallback(data, withAck: ack!, withSocket: self)
}
} else {
handler.executeCallback(data)
dispatch_async(handleQueue) {[weak self] in
handler.executeCallback(data)
}
}
}
}
@@ -448,14 +457,14 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
let handler = SocketEventHandler(event: event, callback: callback)
handlers.append(handler)
}
/**
Removes all handlers.
Can be used after disconnecting to break any potential remaining retain cycles.
*/
public func removeAllHandlers() {
handlers.removeAll(keepCapacity: false)
}
/**
Removes all handlers.
Can be used after disconnecting to break any potential remaining retain cycles.
*/
public func removeAllHandlers() {
handlers.removeAll(keepCapacity: false)
}
/**
Adds a handler that will be called on every event.
+3 -1
View File
@@ -73,7 +73,9 @@ final class SocketPacket: Printable {
}
func getEvent() -> String {
return data?.removeAtIndex(0) as! String
let event: AnyObject? = data?.removeAtIndex(0)
return event as? String ?? String(stringInterpolationSegment: event!)
}
func addData(data:NSData) -> Bool {
+1 -1
View File
@@ -495,7 +495,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
dataLength = UInt64(bytes[0].bigEndian)
offset += sizeof(UInt16)
}
if bufferLen < offset {
if bufferLen < offset || UInt64(bufferLen - offset) < dataLength {
fragBuffer = NSData(bytes: buffer, length: bufferLen)
return
}