Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bba966a125 | ||
|
|
0579e7ec19 | ||
|
|
aee0382cbc | ||
|
|
9abf2e77e0 | ||
|
|
0dd3def2e4 | ||
|
|
c5d70b4888 | ||
|
|
ee38630468 | ||
|
|
5a65efe526 | ||
|
|
02971e14c2 | ||
|
|
ea7e60cde2 | ||
|
|
83cee796d8 | ||
|
|
86bd271a9f | ||
|
|
6e31f54e88 | ||
|
|
b97574e28a | ||
|
|
ab56b58b2d | ||
|
|
8e2f478989 | ||
|
|
c99f9a6b97 | ||
|
|
45b5852e50 | ||
|
|
c608bf8286 | ||
|
|
6c6084705e | ||
|
|
885965c5bc | ||
|
|
ac228ccede | ||
|
|
7bc8cd01e8 | ||
|
|
b9e05286a2 | ||
|
|
a5db43b834 | ||
|
|
7382030dff | ||
|
|
40ac53844d | ||
|
|
7f443faf92 | ||
|
|
a6c700230d | ||
|
|
aa368f92cf | ||
|
|
28ae7a8240 | ||
|
|
e07ed93c0b | ||
|
|
17fb142083 | ||
|
|
66674aae78 | ||
|
|
395dc48287 | ||
|
|
1648a51b6f | ||
|
|
ad7043c918 | ||
|
|
48672d8df3 | ||
|
|
d657538214 | ||
|
|
a231104c15 | ||
|
|
ab8de6932c | ||
|
|
c101a04845 | ||
|
|
3d06b7dbad | ||
|
|
f57786ad5b | ||
|
|
7ff1d327de | ||
|
|
99e2da235a | ||
|
|
a20a0f14f3 | ||
|
|
0e478085a3 | ||
|
|
61eda5971e | ||
|
|
32e1f55394 | ||
|
|
a88a859750 | ||
|
|
aaefdd0a2e | ||
|
|
4c7a09cc8e | ||
|
|
90c7c9aadc | ||
|
|
84499d4c21 | ||
|
|
bfe54f8df7 | ||
|
|
18a227e591 | ||
|
|
6d49c37fb8 | ||
|
|
a0c213364d | ||
|
|
3c79bd0a75 | ||
|
|
a11533b61f | ||
|
|
8acd32324e | ||
|
|
b65dfec6b0 | ||
|
|
1e07070798 | ||
|
|
927ab155e3 | ||
|
|
de20099c07 | ||
|
|
877db516c2 | ||
|
|
4dd882b8ad | ||
|
|
ccc3745bb8 | ||
|
|
718dc27089 | ||
|
|
798d8a62ae | ||
|
|
9241bf869f | ||
|
|
7573355731 | ||
|
|
f3b4c0eba3 | ||
|
|
d2f39b163a | ||
|
|
b8ab80bdf1 | ||
|
|
66455f3e1b | ||
|
|
5d867f4f65 | ||
|
|
166d59341c | ||
|
|
1ad87bdb0d | ||
|
|
14dc5957fc | ||
|
|
c757ede90e | ||
|
|
e99030846f | ||
|
|
3f8941d35b | ||
|
|
a005646054 | ||
|
|
3025911502 | ||
|
|
3791b9c112 | ||
|
|
39135c089b | ||
|
|
bd5e2db98a | ||
|
|
4531d2e1a1 | ||
|
|
5772f8fb4f | ||
|
|
b336f0e267 | ||
|
|
d647c53122 | ||
|
|
f933b7addc | ||
|
|
288c04e629 | ||
|
|
3754cd2c2d | ||
|
|
20b28b2f43 | ||
|
|
a5d40c4479 | ||
|
|
31fbe1040d | ||
|
|
c0afc006e3 | ||
|
|
fe0d5d835f | ||
|
|
ded625aaef | ||
|
|
54e0b6c189 | ||
|
|
72ed7d4be8 | ||
|
|
b9c01ce614 | ||
|
|
faaa0473d9 | ||
|
|
195f04c982 | ||
|
|
0eeecd84ce | ||
|
|
4ae6489230 | ||
|
|
0ebbf3f0cd | ||
|
|
12b312de57 | ||
|
|
bb518ac1a4 | ||
|
|
13176f149c | ||
|
|
3e53228e36 | ||
|
|
e2cd910fa7 | ||
|
|
21ac65733f | ||
|
|
6ab7455a08 | ||
|
|
7a146bf6ac | ||
|
|
0d7d319cc3 | ||
|
|
14b0022fdc | ||
|
|
9c16ffade8 | ||
|
|
30c1a4df97 | ||
|
|
492ae89344 | ||
|
|
7bdf80d133 | ||
|
|
01b88f8e37 | ||
|
|
9860452814 | ||
|
|
835e1c2262 | ||
|
|
ba7ffe6d26 | ||
|
|
6ed90a3e60 | ||
|
|
d2d9c49414 | ||
|
|
4c033f81d6 | ||
|
|
b0cf8d2c40 | ||
|
|
1a48adb03d | ||
|
|
9a39524ba2 | ||
|
|
5b6b36a2dc | ||
|
|
198f24c684 | ||
|
|
f464eba995 | ||
|
|
0e791176bd | ||
|
|
243a750377 | ||
|
|
6cffbc2404 | ||
|
|
a56227d08a | ||
|
|
0233bce881 | ||
|
|
456406416a | ||
|
|
99ed93038f | ||
|
|
9a05f6043b | ||
|
|
70c7dacde9 | ||
|
|
a9b4193fe4 | ||
|
|
aaaf9dc451 | ||
|
|
fe8469cfc6 | ||
|
|
f5c3a2cac9 | ||
|
|
7d26bd3ee8 | ||
|
|
136847fd77 | ||
|
|
9b3f84dcd0 | ||
|
|
a72f96759e | ||
|
|
a81f925671 | ||
|
|
4997294186 | ||
|
|
ba5638a109 | ||
|
|
978bd2614e | ||
|
|
2f2bd49045 | ||
|
|
f889d37e9b | ||
|
|
67afbcbd56 | ||
|
|
d0a57ca353 | ||
|
|
9355fc5077 | ||
|
|
fd21ca00d3 | ||
|
|
f818d64405 | ||
|
|
55289d69a3 | ||
|
|
5dc0dfa9aa | ||
|
|
6a10f72443 |
No files matched your search
+9
-1
@@ -2,4 +2,12 @@ language: objective-c
|
||||
xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder
|
||||
xcode_scheme: SocketIO-iOS
|
||||
osx_image: xcode7
|
||||
script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
|
||||
before_install:
|
||||
- cd Socket.IO-Test-Server/
|
||||
- npm install
|
||||
- cd ..
|
||||
install: node Socket.IO-Test-Server/main.js &
|
||||
script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test -parallelize
|
||||
cache:
|
||||
directories:
|
||||
- Socket.IO-Test-Server/node_modules
|
||||
@@ -1,23 +1,23 @@
|
||||
[](https://travis-ci.org/socketio/socket.io-client-swift)
|
||||
[](https://travis-ci.org/socketio/socket.io-client-swift)
|
||||
|
||||
#Socket.IO-Client-Swift
|
||||
Socket.IO-client for iOS/OS X.
|
||||
|
||||
##Example
|
||||
```swift
|
||||
let socket = SocketIOClient(socketURL: "localhost:8080")
|
||||
let socket = SocketIOClient(socketURL: "localhost:8080", options: [.Log(true), .ForcePolling(true)])
|
||||
|
||||
socket.on("connect") {data, ack in
|
||||
print("socket connected")
|
||||
}
|
||||
|
||||
socket.on("currentAmount") {data, ack in
|
||||
if let cur = data?[0] as? Double {
|
||||
if let cur = data[0] as? Double {
|
||||
socket.emitWithAck("canUpdate", cur)(timeoutAfter: 0) {data in
|
||||
socket.emit("update", ["amount": cur + 2.50])
|
||||
}
|
||||
|
||||
ack?("Got your currentAmount", "dude")
|
||||
ack?.with("Got your currentAmount", "dude")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,20 +26,20 @@ socket.connect()
|
||||
|
||||
##Objective-C Example
|
||||
```objective-c
|
||||
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" options:nil];
|
||||
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" options:@{@"log": @YES, @"forcePolling": @YES}];
|
||||
|
||||
[socket onObjectiveC:@"connect" callback:^(NSArray* data, void (^ack)(NSArray*)) {
|
||||
[socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
|
||||
NSLog(@"socket connected");
|
||||
}];
|
||||
|
||||
[socket onObjectiveC:@"currentAmount" callback:^(NSArray* data, void (^ack)(NSArray*)) {
|
||||
[socket on:@"currentAmount" callback:^(NSArray* data, SocketAckEmitter* ack) {
|
||||
double cur = [[data objectAtIndex:0] floatValue];
|
||||
|
||||
[socket emitWithAck:@"canUpdate" withItems:@[@(cur)]](0, ^(NSArray* data) {
|
||||
[socket emit:@"update" withItems:@[@{@"amount": @(cur + 2.50)}]];
|
||||
});
|
||||
|
||||
ack(@[@"Got your currentAmount, ", @"dude"]);
|
||||
[ack with:@[@"Got your currentAmount, ", @"dude"]];
|
||||
}];
|
||||
|
||||
[socket connect];
|
||||
@@ -57,22 +57,23 @@ SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8
|
||||
Requires Swift 2/Xcode 7
|
||||
|
||||
If you need Swift 1.2/Xcode 6.3/4 use v2.4.5 (Pre-Swift 2 support is no longer maintained)
|
||||
|
||||
If you need Swift 1.1/Xcode 6.2 use v1.5.2. (Pre-Swift 1.2 support is no longer maintained)
|
||||
|
||||
Carthage
|
||||
-----------------
|
||||
Add this line to your `Cartfile`:
|
||||
```
|
||||
github "socketio/socket.io-client-swift" ~> 3.0.0 # Or latest version
|
||||
```
|
||||
|
||||
Run `carthage update`.
|
||||
|
||||
Manually (iOS 7+)
|
||||
-----------------
|
||||
1. Copy the SocketIOClientSwift folder into your Xcode project. (Make sure you add the files to your target(s))
|
||||
2. If you plan on using this from Objective-C, read [this](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html) on exposing Swift code to Objective-C.
|
||||
|
||||
Carthage
|
||||
-----------------
|
||||
Add this line to your `Cartfile`:
|
||||
```
|
||||
github "socketio/socket.io-client-swift" ~> 4.0.4 # Or latest version
|
||||
```
|
||||
|
||||
Run `carthage update --platform ios,macosx`.
|
||||
|
||||
CocoaPods 0.36.0 or later (iOS 8+)
|
||||
------------------
|
||||
Create `Podfile` and add `pod 'Socket.IO-Client-Swift'`:
|
||||
@@ -82,7 +83,7 @@ source 'https://github.com/CocoaPods/Specs.git'
|
||||
platform :ios, '8.0'
|
||||
use_frameworks!
|
||||
|
||||
pod 'Socket.IO-Client-Swift', '~> 3.0.0' # Or latest version
|
||||
pod 'Socket.IO-Client-Swift', '~> 4.0.4' # Or latest version
|
||||
```
|
||||
|
||||
Install pods:
|
||||
@@ -99,49 +100,68 @@ import Socket_IO_Client_Swift
|
||||
```
|
||||
|
||||
Objective-C:
|
||||
|
||||
```Objective-C
|
||||
#import <Socket_IO_Client_Swift/Socket_IO_Client_Swift-Swift.h>
|
||||
```
|
||||
|
||||
CocoaSeeds
|
||||
-----------------
|
||||
|
||||
Add this line to your `Seedfile`:
|
||||
|
||||
```
|
||||
github "socketio/socket.io-client-swift", "v4.0.4", :files => "SocketIOClientSwift/*.swift" # Or latest version
|
||||
```
|
||||
|
||||
Run `seed install`.
|
||||
|
||||
|
||||
##API
|
||||
Constructors
|
||||
-----------
|
||||
`init(socketURL: String, opts:NSDictionary? = nil)` - Constructs a new client for the given URL. opts can be omitted (will use default values)
|
||||
`init(var socketURL: String, options: Set<SocketIOClientOption>? = nil)` - Creates a new SocketIOClient. opts is a Set of SocketIOClientOption. If your socket.io server is secure, you need to specify `https` in your socketURL.
|
||||
|
||||
`convenience init(socketURL: String, options:NSDictionary?)` - Same as above, but meant for Objective-C. See Objective-C Example.
|
||||
`convenience init(socketURL: String, options: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys.
|
||||
|
||||
Options
|
||||
-------
|
||||
- `connectParams: [String: AnyObject]?` - Dictionary whose contents will be passed with the connection.
|
||||
- `reconnects: Bool` Default is `true`
|
||||
- `reconnectAttempts: Int` Default is `-1` (infinite tries)
|
||||
- `reconnectWait: Int` Default is `10`
|
||||
- `forcePolling: Bool` Default is `false`. `true` forces the client to use xhr-polling.
|
||||
- `forceWebsockets: Bool` Default is `false`. `true` forces the client to use WebSockets.
|
||||
- `nsp: String` Default is `"/"`. Connects to a namespace.
|
||||
- `cookies: [NSHTTPCookie]?` An array of NSHTTPCookies. Passed during the handshake. Default is nil.
|
||||
- `log: Bool` If `true` socket will log debug messages. Default is false.
|
||||
- `logger: SocketLogger` If you wish to implement your own logger that conforms to SocketLogger you can pass it in here. Will use the default logging defined under the protocol otherwise.
|
||||
- `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.
|
||||
All options are a case of SocketIOClientOption. To get the Objective-C Option, convert the name to lowerCamelCase.
|
||||
|
||||
```swift
|
||||
case ConnectParams([String: AnyObject]) // Dictionary whose contents will be passed with the connection.
|
||||
case Reconnects(Bool) // Whether to reconnect on server lose. Default is `true`
|
||||
case ReconnectAttempts(Int) // How many times to reconnect. Default is `-1` (infinite tries)
|
||||
case ReconnectWait(Int) // Amount of time to wait between reconnects. Default is `10`
|
||||
case ForcePolling(Bool) // `true` forces the client to use xhr-polling. Default is `false`
|
||||
case ForceWebsockets(Bool) // `true` forces the client to use WebSockets. Default is `false`
|
||||
case Nsp(String) // The namespace to connect to. Must begin with /. Default is `/`
|
||||
case Cookies([NSHTTPCookie]) // An array of NSHTTPCookies. Passed during the handshake. Default is nil.
|
||||
case Log(Bool) // If `true` socket will log debug messages. Default is false.
|
||||
case Logger(SocketLogger) // Custom logger that conforms to SocketLogger. Will use the default logging otherwise.
|
||||
case SessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.
|
||||
case Path(String) // If the server uses a custom path. ex: `"/swift"`. Default is `""`
|
||||
case ExtraHeaders([String: String]) // Adds custom headers to the initial request. Default is nil.
|
||||
case HandleQueue(dispatch_queue_t) // The dispatch queue that handlers are run on. Default is the main queue.
|
||||
case VoipEnabled(Bool) // Only use this option if you're using the client with VoIP services. Changes the way the WebSocket is created. Default is false
|
||||
```
|
||||
Methods
|
||||
-------
|
||||
1. `on(name:String, callback:((data:NSArray?, ack:AckEmitter?) -> Void))` - Adds a handler for an event. Items are passed by an array. `ack` can be used to send an ack when one is requested. See example.
|
||||
2. `onObjectiveC(name:String, callback:((data:NSArray?, ack:AckEmitter?) -> Void))` - Adds a handler for an event. Items are passed by an array. `ack` can be used to send an ack when one is requested. See example.
|
||||
3. `onAny(callback:((event:String, items:AnyObject?)) -> Void)` - Adds a handler for all events. It will be called on any received event.
|
||||
4. `emit(event:String, _ items:AnyObject...)` - Sends a message. Can send multiple items.
|
||||
5. `emit(event:String, withItems items:[AnyObject])` - `emit` for Objective-C
|
||||
6. `emitWithAck(event:String, _ items:AnyObject...) -> (timeoutAfter:UInt64, callback:(NSArray?) -> Void) -> Void` - Sends a message that requests an acknowledgement from the server. Returns a function which you can use to add a handler. See example. Note: The message is not sent until you call the returned function.
|
||||
7. `emitWithAck(event:String, withItems items:[AnyObject]) -> (UInt64, (NSArray?) -> Void) -> Void` - `emitWithAck` for Objective-C. Note: The message is not sent until you call the returned function.
|
||||
1. `on(event: String, callback: NormalCallback)` - Adds a handler for an event. Items are passed by an array. `ack` can be used to send an ack when one is requested. See example.
|
||||
2. `once(event: String, callback: NormalCallback)` - Adds a handler that will only be executed once.
|
||||
3. `onAny(callback:((event: String, items: AnyObject?)) -> Void)` - Adds a handler for all events. It will be called on any received event.
|
||||
4. `emit(event: String, _ items: AnyObject...)` - Sends a message. Can send multiple items.
|
||||
5. `emit(event: String, withItems items: [AnyObject])` - `emit` for Objective-C
|
||||
6. `emitWithAck(event: String, _ items: AnyObject...) -> (timeoutAfter: UInt64, callback: (NSArray?) -> Void) -> Void` - Sends a message that requests an acknowledgement from the server. Returns a function which you can use to add a handler. See example. Note: The message is not sent until you call the returned function.
|
||||
7. `emitWithAck(event: String, withItems items: [AnyObject]) -> (UInt64, (NSArray?) -> Void) -> Void` - `emitWithAck` for Objective-C. Note: The message is not sent until you call the returned function.
|
||||
8. `connect()` - Establishes a connection to the server. A "connect" event is fired upon successful connection.
|
||||
9. `connect(#timeoutAfter:Int, withTimeoutHandler handler:(() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
|
||||
10. `close(#fast:Bool)` - Closes the socket. Once a socket is closed it should not be reopened. Pass true to fast if you're closing from a background task.
|
||||
9. `connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
|
||||
10. `close()` - Closes the socket. Once a socket is closed it should not be reopened.
|
||||
11. `reconnect()` - Causes the client to reconnect to the server.
|
||||
12. `joinNamespace()` - Causes the client to join nsp. Shouldn't need to be called unless you change nsp manually.
|
||||
13. `leaveNamespace()` - Causes the client to leave the nsp and go back to /
|
||||
14. `off(event: String)` - Removes all event handlers for event.
|
||||
15. `removeAllHandlers()` - Removes all handlers.
|
||||
|
||||
Client Events
|
||||
------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Socket.IO-Client-Swift"
|
||||
s.version = "3.0.0"
|
||||
s.version = "4.0.4"
|
||||
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 => 'v3.0.0' }
|
||||
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v4.0.4' }
|
||||
s.source_files = "SocketIOClientSwift/**/*.swift"
|
||||
s.requires_arc = true
|
||||
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
|
||||
|
||||
@@ -11,48 +11,6 @@
|
||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
||||
572EF23D1B51F18A00EEBB58 /* SocketIO-Mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; };
|
||||
572EF24A1B51F18A00EEBB58 /* SocketIO_MacTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572EF2491B51F18A00EEBB58 /* SocketIO_MacTests.swift */; };
|
||||
57425F9C1BA3A46000BDAAC1 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||
57425F9D1BA3A46000BDAAC1 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
||||
57425F9E1BA3A46000BDAAC1 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF851B51F254004FF46E /* SocketParser.swift */; };
|
||||
57425F9F1BA3A46000BDAAC1 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
||||
57425FA01BA3A46000BDAAC1 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */; };
|
||||
57425FA11BA3A46000BDAAC1 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF801B51F254004FF46E /* SocketEventHandler.swift */; };
|
||||
57425FA21BA3A46000BDAAC1 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF811B51F254004FF46E /* SocketFixUTF8.swift */; };
|
||||
57425FA31BA3A46000BDAAC1 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF821B51F254004FF46E /* SocketIOClient.swift */; };
|
||||
57425FA41BA3A46000BDAAC1 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||
57425FA51BA3A46000BDAAC1 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF831B51F254004FF46E /* SocketLogger.swift */; };
|
||||
57425FA61BA3A46000BDAAC1 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
||||
57425FA71BA3A46000BDAAC1 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||
57425FA81BA3A46000BDAAC1 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF841B51F254004FF46E /* SocketPacket.swift */; };
|
||||
57425FA91BA3A46000BDAAC1 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||
57425FAA1BA3A46000BDAAC1 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||
57425FAD1BA3A46000BDAAC1 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
57425FDC1BA3A4F100BDAAC1 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||
57425FDD1BA3A4F100BDAAC1 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF851B51F254004FF46E /* SocketParser.swift */; };
|
||||
57425FDE1BA3A4F100BDAAC1 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF841B51F254004FF46E /* SocketPacket.swift */; };
|
||||
57425FDF1BA3A4F100BDAAC1 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF811B51F254004FF46E /* SocketFixUTF8.swift */; };
|
||||
57425FE01BA3A4F100BDAAC1 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF801B51F254004FF46E /* SocketEventHandler.swift */; };
|
||||
57425FE11BA3A4F100BDAAC1 /* SocketTestCases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */; };
|
||||
57425FE21BA3A4F100BDAAC1 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
||||
57425FE31BA3A4F100BDAAC1 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||
57425FE41BA3A4F100BDAAC1 /* TestKind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 941A4AB91B67A56C00C42318 /* TestKind.swift */; };
|
||||
57425FE51BA3A4F100BDAAC1 /* AbstractSocketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */; };
|
||||
57425FE61BA3A4F100BDAAC1 /* SocketEmitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945B65421B63D9DB0081E995 /* SocketEmitTest.swift */; };
|
||||
57425FE71BA3A4F100BDAAC1 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||
57425FE81BA3A4F100BDAAC1 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF831B51F254004FF46E /* SocketLogger.swift */; };
|
||||
57425FE91BA3A4F100BDAAC1 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */; };
|
||||
57425FEA1BA3A4F100BDAAC1 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */; };
|
||||
57425FEB1BA3A4F100BDAAC1 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||
57425FEC1BA3A4F100BDAAC1 /* SocketAcknowledgementTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */; };
|
||||
57425FED1BA3A4F100BDAAC1 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
||||
57425FEE1BA3A4F100BDAAC1 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
||||
57425FEF1BA3A4F100BDAAC1 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF821B51F254004FF46E /* SocketIOClient.swift */; };
|
||||
57425FF01BA3A4F100BDAAC1 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */; };
|
||||
57425FF11BA3A4F100BDAAC1 /* SocketNamespaceEmitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */; };
|
||||
57425FF21BA3A4F100BDAAC1 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||
57425FF31BA3A4F100BDAAC1 /* SocketNamespaceAcknowledgementTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */; };
|
||||
57425FF51BA3A4F100BDAAC1 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
||||
5764DF891B51F254004FF46E /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||
5764DF8A1B51F254004FF46E /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||
5764DF8B1B51F254004FF46E /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||
@@ -79,15 +37,53 @@
|
||||
5764DFA01B51F254004FF46E /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||
5764DFA11B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||
5764DFA21B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||
740E10441BD2C4680064FC4A /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740E10431BD2C4680064FC4A /* SocketIOClientOption.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
740E10451BD2C4680064FC4A /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740E10431BD2C4680064FC4A /* SocketIOClientOption.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
740E10461BD2C4680064FC4A /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740E10431BD2C4680064FC4A /* SocketIOClientOption.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
740E10471BD2C4680064FC4A /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740E10431BD2C4680064FC4A /* SocketIOClientOption.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
741F39EE1BD025D80026C9CC /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
745895381BB59A0A0050ACC8 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */; };
|
||||
7458953D1BB59A0A0050ACC8 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */; };
|
||||
7472A5E11BB6ECE800CD4F59 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||
7472A5E21BB6ECE800CD4F59 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||
7472A5E31BB6ECE800CD4F59 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
||||
7472A5E41BB6ECE800CD4F59 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */; };
|
||||
7472A5E51BB6ECE800CD4F59 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF801B51F254004FF46E /* SocketEventHandler.swift */; };
|
||||
7472A5E61BB6ECE800CD4F59 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF811B51F254004FF46E /* SocketFixUTF8.swift */; };
|
||||
7472A5E71BB6ECE800CD4F59 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF821B51F254004FF46E /* SocketIOClient.swift */; };
|
||||
7472A5E81BB6ECE800CD4F59 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF831B51F254004FF46E /* SocketLogger.swift */; };
|
||||
7472A5E91BB6ECE800CD4F59 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF841B51F254004FF46E /* SocketPacket.swift */; };
|
||||
7472A5EA1BB6ECE800CD4F59 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF851B51F254004FF46E /* SocketParser.swift */; };
|
||||
7472A5EB1BB6ECE800CD4F59 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||
7472A5EC1BB6ECE800CD4F59 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
||||
7472A5ED1BB6ECE800CD4F59 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||
7472A5EE1BB6ECE800CD4F59 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74781D5A1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
||||
74781D5B1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
||||
74781D5C1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
||||
74781D5D1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
||||
749A7F8B1BA9D42D00782993 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749A7F8A1BA9D42D00782993 /* SocketAckEmitter.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
749A7F8C1BA9D42D00782993 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749A7F8A1BA9D42D00782993 /* SocketAckEmitter.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
749A7F8F1BA9D42D00782993 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749A7F8A1BA9D42D00782993 /* SocketAckEmitter.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
749A7F901BA9D42D00782993 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749A7F8A1BA9D42D00782993 /* SocketAckEmitter.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74D765621B9F0D870028551C /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||
74D765631B9F0D9F0028551C /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||
74D765641B9F0DA40028551C /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||
941A4ABA1B67A56C00C42318 /* TestKind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 941A4AB91B67A56C00C42318 /* TestKind.swift */; };
|
||||
94242BB81B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */; };
|
||||
74F124E31BC5697B002966F4 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74F124E41BC5697B002966F4 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74F124E51BC5697B002966F4 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74F124E61BC5697B002966F4 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74F124E81BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74F124E91BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74F124EA1BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74F124EB1BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
945B65351B5FCEEA0081E995 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||
945B65361B5FCEEA0081E995 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||
945B65371B5FCEEA0081E995 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
||||
@@ -101,13 +97,8 @@
|
||||
945B653F1B5FCEEA0081E995 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
||||
945B65401B5FCEEA0081E995 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||
945B65411B5FCEEA0081E995 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||
945B65431B63D9DB0081E995 /* SocketEmitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945B65421B63D9DB0081E995 /* SocketEmitTest.swift */; };
|
||||
949FAE8D1B9B94E600073BE9 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */; };
|
||||
94A20D611B99E22F00BF9E44 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */; };
|
||||
94ADAC491B652D3300FD79AE /* SocketNamespaceEmitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */; };
|
||||
94ADAC4B1B6632DD00FD79AE /* SocketAcknowledgementTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */; };
|
||||
94CB8F0B1B6E48B90019ED53 /* SocketTestCases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */; };
|
||||
94CB8F0D1B6E66E60019ED53 /* AbstractSocketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -125,13 +116,6 @@
|
||||
remoteGlobalIDString = 572EF2371B51F18A00EEBB58;
|
||||
remoteInfo = "SocketIO-Mac";
|
||||
};
|
||||
57425FDA1BA3A4F100BDAAC1 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 572EF20E1B51F12F00EEBB58 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 572EF2181B51F16C00EEBB58;
|
||||
remoteInfo = "SocketIO-iOS";
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -145,9 +129,6 @@
|
||||
572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-Mac.h"; sourceTree = "<group>"; };
|
||||
572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-MacTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
572EF2481B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
572EF2491B51F18A00EEBB58 /* SocketIO_MacTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketIO_MacTests.swift; sourceTree = "<group>"; };
|
||||
57425FB21BA3A46000BDAAC1 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
57425FFA1BA3A4F100BDAAC1 /* SocketIO-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5764DF7C1B51F254004FF46E /* SocketAckManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckManager.swift; path = SocketIOClientSwift/SocketAckManager.swift; sourceTree = "<group>"; };
|
||||
5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAnyEvent.swift; path = SocketIOClientSwift/SocketAnyEvent.swift; sourceTree = "<group>"; };
|
||||
5764DF7E1B51F254004FF46E /* SocketEngine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEngine.swift; path = SocketIOClientSwift/SocketEngine.swift; sourceTree = "<group>"; };
|
||||
@@ -161,17 +142,18 @@
|
||||
5764DF861B51F254004FF46E /* SocketTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketTypes.swift; path = SocketIOClientSwift/SocketTypes.swift; sourceTree = "<group>"; };
|
||||
5764DF871B51F254004FF46E /* SwiftRegex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftRegex.swift; path = SocketIOClientSwift/SwiftRegex.swift; sourceTree = "<group>"; };
|
||||
5764DF881B51F254004FF46E /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = SocketIOClientSwift/WebSocket.swift; sourceTree = "<group>"; };
|
||||
740E10431BD2C4680064FC4A /* SocketIOClientOption.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientOption.swift; path = SocketIOClientSwift/SocketIOClientOption.swift; sourceTree = "<group>"; };
|
||||
741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketEngineTest.swift; sourceTree = "<group>"; };
|
||||
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespacePacketTest.swift; sourceTree = "<group>"; };
|
||||
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketSideEffectTest.swift; sourceTree = "<group>"; };
|
||||
74781D591B7E83930042CACA /* SocketIOClientStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientStatus.swift; path = SocketIOClientSwift/SocketIOClientStatus.swift; sourceTree = "<group>"; };
|
||||
749A7F8A1BA9D42D00782993 /* SocketAckEmitter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckEmitter.swift; path = SocketIOClientSwift/SocketAckEmitter.swift; sourceTree = "<group>"; };
|
||||
74D765611B9F0D870028551C /* SocketStringReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SocketStringReader.swift; path = SocketIOClientSwift/SocketStringReader.swift; sourceTree = "<group>"; };
|
||||
941A4AB91B67A56C00C42318 /* TestKind.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestKind.swift; sourceTree = "<group>"; };
|
||||
94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespaceAcknowledgementTest.swift; sourceTree = "<group>"; };
|
||||
945B65421B63D9DB0081E995 /* SocketEmitTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketEmitTest.swift; sourceTree = "<group>"; };
|
||||
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketParserTest.swift; sourceTree = "<group>"; };
|
||||
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketAckManagerTest.swift; sourceTree = "<group>"; };
|
||||
94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespaceEmitTest.swift; sourceTree = "<group>"; };
|
||||
94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketAcknowledgementTest.swift; sourceTree = "<group>"; };
|
||||
94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketTestCases.swift; sourceTree = "<group>"; };
|
||||
94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AbstractSocketTest.swift; sourceTree = "<group>"; };
|
||||
74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEngineSpec.swift; path = SocketIOClientSwift/SocketEngineSpec.swift; sourceTree = "<group>"; };
|
||||
74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEnginePacketType.swift; path = SocketIOClientSwift/SocketEnginePacketType.swift; sourceTree = "<group>"; };
|
||||
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = "<group>"; };
|
||||
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketParserTest.swift; path = "../SocketIO-iOSTests/SocketParserTest.swift"; sourceTree = "<group>"; };
|
||||
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckManagerTest.swift; path = "../SocketIO-iOSTests/SocketAckManagerTest.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -205,21 +187,6 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
57425FAB1BA3A46000BDAAC1 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
57425FF41BA3A4F100BDAAC1 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
57425FF51BA3A4F100BDAAC1 /* SocketIO.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
@@ -242,8 +209,6 @@
|
||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */,
|
||||
572EF2381B51F18A00EEBB58 /* SocketIO.framework */,
|
||||
572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */,
|
||||
57425FB21BA3A46000BDAAC1 /* SocketIO.framework */,
|
||||
57425FFA1BA3A4F100BDAAC1 /* SocketIO-tvOSTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@@ -268,16 +233,7 @@
|
||||
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
945B65421B63D9DB0081E995 /* SocketEmitTest.swift */,
|
||||
94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */,
|
||||
94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */,
|
||||
94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */,
|
||||
941A4AB91B67A56C00C42318 /* TestKind.swift */,
|
||||
94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */,
|
||||
94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */,
|
||||
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */,
|
||||
572EF2291B51F16C00EEBB58 /* Supporting Files */,
|
||||
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */,
|
||||
);
|
||||
path = "SocketIO-iOSTests";
|
||||
sourceTree = "<group>";
|
||||
@@ -310,7 +266,12 @@
|
||||
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF2491B51F18A00EEBB58 /* SocketIO_MacTests.swift */,
|
||||
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */,
|
||||
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */,
|
||||
741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */,
|
||||
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */,
|
||||
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */,
|
||||
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */,
|
||||
572EF2471B51F18A00EEBB58 /* Supporting Files */,
|
||||
);
|
||||
path = "SocketIO-MacTests";
|
||||
@@ -327,13 +288,17 @@
|
||||
5764DF7B1B51F24A004FF46E /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
749A7F8A1BA9D42D00782993 /* SocketAckEmitter.swift */,
|
||||
5764DF7C1B51F254004FF46E /* SocketAckManager.swift */,
|
||||
5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */,
|
||||
5764DF7E1B51F254004FF46E /* SocketEngine.swift */,
|
||||
5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */,
|
||||
74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */,
|
||||
74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */,
|
||||
5764DF801B51F254004FF46E /* SocketEventHandler.swift */,
|
||||
5764DF811B51F254004FF46E /* SocketFixUTF8.swift */,
|
||||
5764DF821B51F254004FF46E /* SocketIOClient.swift */,
|
||||
740E10431BD2C4680064FC4A /* SocketIOClientOption.swift */,
|
||||
74781D591B7E83930042CACA /* SocketIOClientStatus.swift */,
|
||||
5764DF831B51F254004FF46E /* SocketLogger.swift */,
|
||||
5764DF841B51F254004FF46E /* SocketPacket.swift */,
|
||||
@@ -365,14 +330,6 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
57425FAC1BA3A46000BDAAC1 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
57425FAD1BA3A46000BDAAC1 /* SocketIO-iOS.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@@ -448,42 +405,6 @@
|
||||
productReference = 572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
57425F9A1BA3A46000BDAAC1 /* SocketIO-tvOS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 57425FAF1BA3A46000BDAAC1 /* Build configuration list for PBXNativeTarget "SocketIO-tvOS" */;
|
||||
buildPhases = (
|
||||
57425F9B1BA3A46000BDAAC1 /* Sources */,
|
||||
57425FAB1BA3A46000BDAAC1 /* Frameworks */,
|
||||
57425FAC1BA3A46000BDAAC1 /* Headers */,
|
||||
57425FAE1BA3A46000BDAAC1 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "SocketIO-tvOS";
|
||||
productName = "SocketIO-iOS";
|
||||
productReference = 57425FB21BA3A46000BDAAC1 /* SocketIO.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
57425FD81BA3A4F100BDAAC1 /* SocketIO-tvOSTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 57425FF71BA3A4F100BDAAC1 /* Build configuration list for PBXNativeTarget "SocketIO-tvOSTests" */;
|
||||
buildPhases = (
|
||||
57425FDB1BA3A4F100BDAAC1 /* Sources */,
|
||||
57425FF41BA3A4F100BDAAC1 /* Frameworks */,
|
||||
57425FF61BA3A4F100BDAAC1 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
57425FD91BA3A4F100BDAAC1 /* PBXTargetDependency */,
|
||||
);
|
||||
name = "SocketIO-tvOSTests";
|
||||
productName = "SocketIO-iOSTests";
|
||||
productReference = 57425FFA1BA3A4F100BDAAC1 /* SocketIO-tvOSTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
@@ -521,8 +442,6 @@
|
||||
targets = (
|
||||
572EF2181B51F16C00EEBB58 /* SocketIO-iOS */,
|
||||
572EF2231B51F16C00EEBB58 /* SocketIO-iOSTests */,
|
||||
57425F9A1BA3A46000BDAAC1 /* SocketIO-tvOS */,
|
||||
57425FD81BA3A4F100BDAAC1 /* SocketIO-tvOSTests */,
|
||||
572EF2371B51F18A00EEBB58 /* SocketIO-Mac */,
|
||||
572EF2411B51F18A00EEBB58 /* SocketIO-MacTests */,
|
||||
);
|
||||
@@ -558,20 +477,6 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
57425FAE1BA3A46000BDAAC1 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
57425FF61BA3A4F100BDAAC1 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
@@ -582,6 +487,7 @@
|
||||
74D765631B9F0D9F0028551C /* SocketStringReader.swift in Sources */,
|
||||
5764DF8D1B51F254004FF46E /* SocketEngine.swift in Sources */,
|
||||
5764DF9B1B51F254004FF46E /* SocketParser.swift in Sources */,
|
||||
749A7F8B1BA9D42D00782993 /* SocketAckEmitter.swift in Sources */,
|
||||
5764DF9D1B51F254004FF46E /* SocketTypes.swift in Sources */,
|
||||
5764DF8F1B51F254004FF46E /* SocketEngineClient.swift in Sources */,
|
||||
5764DF911B51F254004FF46E /* SocketEventHandler.swift in Sources */,
|
||||
@@ -592,7 +498,10 @@
|
||||
74781D5A1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
||||
5764DFA11B51F254004FF46E /* WebSocket.swift in Sources */,
|
||||
5764DF991B51F254004FF46E /* SocketPacket.swift in Sources */,
|
||||
740E10441BD2C4680064FC4A /* SocketIOClientOption.swift in Sources */,
|
||||
74F124E31BC5697B002966F4 /* SocketEngineSpec.swift in Sources */,
|
||||
5764DF891B51F254004FF46E /* SocketAckManager.swift in Sources */,
|
||||
74F124E81BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */,
|
||||
5764DF9F1B51F254004FF46E /* SwiftRegex.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -606,25 +515,26 @@
|
||||
945B653D1B5FCEEA0081E995 /* SocketPacket.swift in Sources */,
|
||||
945B653A1B5FCEEA0081E995 /* SocketFixUTF8.swift in Sources */,
|
||||
945B65391B5FCEEA0081E995 /* SocketEventHandler.swift in Sources */,
|
||||
94CB8F0B1B6E48B90019ED53 /* SocketTestCases.swift in Sources */,
|
||||
749A7F8C1BA9D42D00782993 /* SocketAckEmitter.swift in Sources */,
|
||||
945B65371B5FCEEA0081E995 /* SocketEngine.swift in Sources */,
|
||||
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */,
|
||||
945B65351B5FCEEA0081E995 /* SocketAckManager.swift in Sources */,
|
||||
941A4ABA1B67A56C00C42318 /* TestKind.swift in Sources */,
|
||||
94CB8F0D1B6E66E60019ED53 /* AbstractSocketTest.swift in Sources */,
|
||||
945B65431B63D9DB0081E995 /* SocketEmitTest.swift in Sources */,
|
||||
945B65401B5FCEEA0081E995 /* SwiftRegex.swift in Sources */,
|
||||
945B653C1B5FCEEA0081E995 /* SocketLogger.swift in Sources */,
|
||||
94A20D611B99E22F00BF9E44 /* SocketAckManagerTest.swift in Sources */,
|
||||
74F124E41BC5697B002966F4 /* SocketEngineSpec.swift in Sources */,
|
||||
945B65381B5FCEEA0081E995 /* SocketEngineClient.swift in Sources */,
|
||||
741F39EE1BD025D80026C9CC /* SocketEngineTest.swift in Sources */,
|
||||
945B65361B5FCEEA0081E995 /* SocketAnyEvent.swift in Sources */,
|
||||
94ADAC4B1B6632DD00FD79AE /* SocketAcknowledgementTest.swift in Sources */,
|
||||
945B653F1B5FCEEA0081E995 /* SocketTypes.swift in Sources */,
|
||||
74781D5B1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
||||
945B653B1B5FCEEA0081E995 /* SocketIOClient.swift in Sources */,
|
||||
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */,
|
||||
740E10451BD2C4680064FC4A /* SocketIOClientOption.swift in Sources */,
|
||||
949FAE8D1B9B94E600073BE9 /* SocketParserTest.swift in Sources */,
|
||||
94ADAC491B652D3300FD79AE /* SocketNamespaceEmitTest.swift in Sources */,
|
||||
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */,
|
||||
945B65411B5FCEEA0081E995 /* WebSocket.swift in Sources */,
|
||||
94242BB81B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift in Sources */,
|
||||
74F124E91BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -635,6 +545,7 @@
|
||||
74D765641B9F0DA40028551C /* SocketStringReader.swift in Sources */,
|
||||
5764DF8E1B51F254004FF46E /* SocketEngine.swift in Sources */,
|
||||
5764DF9C1B51F254004FF46E /* SocketParser.swift in Sources */,
|
||||
749A7F8F1BA9D42D00782993 /* SocketAckEmitter.swift in Sources */,
|
||||
5764DF9E1B51F254004FF46E /* SocketTypes.swift in Sources */,
|
||||
5764DF901B51F254004FF46E /* SocketEngineClient.swift in Sources */,
|
||||
5764DF921B51F254004FF46E /* SocketEventHandler.swift in Sources */,
|
||||
@@ -645,7 +556,10 @@
|
||||
74781D5C1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
||||
5764DFA21B51F254004FF46E /* WebSocket.swift in Sources */,
|
||||
5764DF9A1B51F254004FF46E /* SocketPacket.swift in Sources */,
|
||||
740E10461BD2C4680064FC4A /* SocketIOClientOption.swift in Sources */,
|
||||
74F124E51BC5697B002966F4 /* SocketEngineSpec.swift in Sources */,
|
||||
5764DF8A1B51F254004FF46E /* SocketAckManager.swift in Sources */,
|
||||
74F124EA1BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */,
|
||||
5764DFA01B51F254004FF46E /* SwiftRegex.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -654,64 +568,34 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF24A1B51F18A00EEBB58 /* SocketIO_MacTests.swift in Sources */,
|
||||
7472A5E11BB6ECE800CD4F59 /* SocketAckManager.swift in Sources */,
|
||||
7472A5E21BB6ECE800CD4F59 /* SocketAnyEvent.swift in Sources */,
|
||||
74F124E61BC5697B002966F4 /* SocketEngineSpec.swift in Sources */,
|
||||
7472A5E31BB6ECE800CD4F59 /* SocketEngine.swift in Sources */,
|
||||
7472A5E41BB6ECE800CD4F59 /* SocketEngineClient.swift in Sources */,
|
||||
7472A5E51BB6ECE800CD4F59 /* SocketEventHandler.swift in Sources */,
|
||||
7472A5E61BB6ECE800CD4F59 /* SocketFixUTF8.swift in Sources */,
|
||||
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */,
|
||||
7472A5E71BB6ECE800CD4F59 /* SocketIOClient.swift in Sources */,
|
||||
7472A5E81BB6ECE800CD4F59 /* SocketLogger.swift in Sources */,
|
||||
7472A5E91BB6ECE800CD4F59 /* SocketPacket.swift in Sources */,
|
||||
7472A5EA1BB6ECE800CD4F59 /* SocketParser.swift in Sources */,
|
||||
7472A5EB1BB6ECE800CD4F59 /* SocketStringReader.swift in Sources */,
|
||||
7472A5EC1BB6ECE800CD4F59 /* SocketTypes.swift in Sources */,
|
||||
741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */,
|
||||
7472A5ED1BB6ECE800CD4F59 /* SwiftRegex.swift in Sources */,
|
||||
7472A5EE1BB6ECE800CD4F59 /* WebSocket.swift in Sources */,
|
||||
745895381BB59A0A0050ACC8 /* SocketAckManagerTest.swift in Sources */,
|
||||
7458953D1BB59A0A0050ACC8 /* SocketParserTest.swift in Sources */,
|
||||
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */,
|
||||
740E10471BD2C4680064FC4A /* SocketIOClientOption.swift in Sources */,
|
||||
74F124EB1BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */,
|
||||
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */,
|
||||
749A7F901BA9D42D00782993 /* SocketAckEmitter.swift in Sources */,
|
||||
74781D5D1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
57425F9B1BA3A46000BDAAC1 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
57425F9C1BA3A46000BDAAC1 /* SocketStringReader.swift in Sources */,
|
||||
57425F9D1BA3A46000BDAAC1 /* SocketEngine.swift in Sources */,
|
||||
57425F9E1BA3A46000BDAAC1 /* SocketParser.swift in Sources */,
|
||||
57425F9F1BA3A46000BDAAC1 /* SocketTypes.swift in Sources */,
|
||||
57425FA01BA3A46000BDAAC1 /* SocketEngineClient.swift in Sources */,
|
||||
57425FA11BA3A46000BDAAC1 /* SocketEventHandler.swift in Sources */,
|
||||
57425FA21BA3A46000BDAAC1 /* SocketFixUTF8.swift in Sources */,
|
||||
57425FA31BA3A46000BDAAC1 /* SocketIOClient.swift in Sources */,
|
||||
57425FA41BA3A46000BDAAC1 /* SocketAnyEvent.swift in Sources */,
|
||||
57425FA51BA3A46000BDAAC1 /* SocketLogger.swift in Sources */,
|
||||
57425FA61BA3A46000BDAAC1 /* SocketIOClientStatus.swift in Sources */,
|
||||
57425FA71BA3A46000BDAAC1 /* WebSocket.swift in Sources */,
|
||||
57425FA81BA3A46000BDAAC1 /* SocketPacket.swift in Sources */,
|
||||
57425FA91BA3A46000BDAAC1 /* SocketAckManager.swift in Sources */,
|
||||
57425FAA1BA3A46000BDAAC1 /* SwiftRegex.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
57425FDB1BA3A4F100BDAAC1 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
57425FDC1BA3A4F100BDAAC1 /* SocketStringReader.swift in Sources */,
|
||||
57425FDD1BA3A4F100BDAAC1 /* SocketParser.swift in Sources */,
|
||||
57425FDE1BA3A4F100BDAAC1 /* SocketPacket.swift in Sources */,
|
||||
57425FDF1BA3A4F100BDAAC1 /* SocketFixUTF8.swift in Sources */,
|
||||
57425FE01BA3A4F100BDAAC1 /* SocketEventHandler.swift in Sources */,
|
||||
57425FE11BA3A4F100BDAAC1 /* SocketTestCases.swift in Sources */,
|
||||
57425FE21BA3A4F100BDAAC1 /* SocketEngine.swift in Sources */,
|
||||
57425FE31BA3A4F100BDAAC1 /* SocketAckManager.swift in Sources */,
|
||||
57425FE41BA3A4F100BDAAC1 /* TestKind.swift in Sources */,
|
||||
57425FE51BA3A4F100BDAAC1 /* AbstractSocketTest.swift in Sources */,
|
||||
57425FE61BA3A4F100BDAAC1 /* SocketEmitTest.swift in Sources */,
|
||||
57425FE71BA3A4F100BDAAC1 /* SwiftRegex.swift in Sources */,
|
||||
57425FE81BA3A4F100BDAAC1 /* SocketLogger.swift in Sources */,
|
||||
57425FE91BA3A4F100BDAAC1 /* SocketAckManagerTest.swift in Sources */,
|
||||
57425FEA1BA3A4F100BDAAC1 /* SocketEngineClient.swift in Sources */,
|
||||
57425FEB1BA3A4F100BDAAC1 /* SocketAnyEvent.swift in Sources */,
|
||||
57425FEC1BA3A4F100BDAAC1 /* SocketAcknowledgementTest.swift in Sources */,
|
||||
57425FED1BA3A4F100BDAAC1 /* SocketTypes.swift in Sources */,
|
||||
57425FEE1BA3A4F100BDAAC1 /* SocketIOClientStatus.swift in Sources */,
|
||||
57425FEF1BA3A4F100BDAAC1 /* SocketIOClient.swift in Sources */,
|
||||
57425FF01BA3A4F100BDAAC1 /* SocketParserTest.swift in Sources */,
|
||||
57425FF11BA3A4F100BDAAC1 /* SocketNamespaceEmitTest.swift in Sources */,
|
||||
57425FF21BA3A4F100BDAAC1 /* WebSocket.swift in Sources */,
|
||||
57425FF31BA3A4F100BDAAC1 /* SocketNamespaceAcknowledgementTest.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
@@ -725,18 +609,15 @@
|
||||
target = 572EF2371B51F18A00EEBB58 /* SocketIO-Mac */;
|
||||
targetProxy = 572EF2441B51F18A00EEBB58 /* PBXContainerItemProxy */;
|
||||
};
|
||||
57425FD91BA3A4F100BDAAC1 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 572EF2181B51F16C00EEBB58 /* SocketIO-iOS */;
|
||||
targetProxy = 57425FDA1BA3A4F100BDAAC1 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
572EF2121B51F12F00EEBB58 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BITCODE_GENERATION_MODE = bitcode;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||
ENABLE_BITCODE = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
PRODUCT_NAME = SocketIO;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
@@ -746,7 +627,9 @@
|
||||
572EF2131B51F12F00EEBB58 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
BITCODE_GENERATION_MODE = bitcode;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||
ENABLE_BITCODE = YES;
|
||||
PRODUCT_NAME = SocketIO;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
};
|
||||
@@ -769,6 +652,7 @@
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
@@ -823,7 +707,8 @@
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CODE_SIGN_IDENTITY = "iPhone Distribution";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
@@ -966,6 +851,7 @@
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
@@ -1020,6 +906,7 @@
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
@@ -1068,6 +955,7 @@
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
@@ -1118,6 +1006,7 @@
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
CODE_SIGN_IDENTITY = "";
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
@@ -1144,203 +1033,6 @@
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
57425FB01BA3A46000BDAAC1 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
57425FB11BA3A46000BDAAC1 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = 3;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
57425FF81BA3A4F100BDAAC1 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
57425FF91BA3A4F100BDAAC1 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
@@ -1389,24 +1081,6 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
57425FAF1BA3A46000BDAAC1 /* Build configuration list for PBXNativeTarget "SocketIO-tvOS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
57425FB01BA3A46000BDAAC1 /* Debug */,
|
||||
57425FB11BA3A46000BDAAC1 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
57425FF71BA3A4F100BDAAC1 /* Build configuration list for PBXNativeTarget "SocketIO-tvOSTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
57425FF81BA3A4F100BDAAC1 /* Debug */,
|
||||
57425FF91BA3A4F100BDAAC1 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 572EF20E1B51F12F00EEBB58 /* Project object */;
|
||||
|
||||
@@ -37,10 +37,10 @@
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
@@ -62,15 +62,18 @@
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
@@ -85,10 +88,10 @@
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
|
||||
@@ -1,113 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0710"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "57425F9A1BA3A46000BDAAC1"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-tvOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "57425FD81BA3A4F100BDAAC1"
|
||||
BuildableName = "SocketIO-tvOSTests.xctest"
|
||||
BlueprintName = "SocketIO-tvOSTests"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "57425FD81BA3A4F100BDAAC1"
|
||||
BuildableName = "SocketIO-tvOSTests.xctest"
|
||||
BlueprintName = "SocketIO-tvOSTests"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "57425F9A1BA3A46000BDAAC1"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-tvOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "57425F9A1BA3A46000BDAAC1"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-tvOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "57425F9A1BA3A46000BDAAC1"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-tvOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,6 +1,8 @@
|
||||
var app = require('express')()
|
||||
var server = app.listen(6979)
|
||||
var io = require('socket.io')(server)
|
||||
var app = require('http').createServer()
|
||||
var io = require('socket.io')(app);
|
||||
app.listen(6979)
|
||||
|
||||
|
||||
var acknowledgementsEvents = require("./acknowledgementEvents.js")
|
||||
var emitEvents = require("./emitEvents.js")
|
||||
var socketEventRegister = require("./socketEventRegister.js")
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
"author": "Lukas Schmidt",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"express": "^4.13.1",
|
||||
"socket.io": "^1.3.6"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// SocketBasicPacketTest.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 10/7/15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SocketBasicPacketTest: XCTestCase {
|
||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
let data2 = "test2".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
|
||||
func testEmpyEmit() {
|
||||
let expectedSendString = "2[\"test\"]"
|
||||
let sendData = ["test"]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testNullEmit() {
|
||||
let expectedSendString = "2[\"test\",null]"
|
||||
let sendData = ["test", NSNull()]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testStringEmit() {
|
||||
let expectedSendString = "2[\"test\",\"foo bar\"]"
|
||||
let sendData = ["test", "foo bar"]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testJSONEmit() {
|
||||
let expectedSendString = "2[\"test\",{\"test\":\"hello\",\"hello\":1,\"foobar\":true,\"null\":null}]"
|
||||
let sendData = ["test", ["foobar": true, "hello": 1, "test": "hello", "null": NSNull()]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testArrayEmit() {
|
||||
let expectedSendString = "2[\"test\",[\"hello\",1,{\"test\":\"test\"}]]"
|
||||
let sendData = ["test", ["hello", 1, ["test": "test"]]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testBinaryEmit() {
|
||||
let expectedSendString = "51-[\"test\",{\"num\":0,\"_placeholder\":true}]"
|
||||
let sendData = ["test", data]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data])
|
||||
}
|
||||
|
||||
func testMultipleBinaryEmit() {
|
||||
let expectedSendString = "52-[\"test\",{\"data1\":{\"num\":0,\"_placeholder\":true},\"data2\":{\"num\":1,\"_placeholder\":true}}]"
|
||||
let sendData = ["test", ["data1": data, "data2": data2]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data, data2])
|
||||
}
|
||||
|
||||
func testEmitWithAck() {
|
||||
let expectedSendString = "20[\"test\"]"
|
||||
let sendData = ["test"]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testEmitDataWithAck() {
|
||||
let expectedSendString = "51-0[\"test\",{\"num\":0,\"_placeholder\":true}]"
|
||||
let sendData = ["test", data]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data])
|
||||
}
|
||||
|
||||
// Acks
|
||||
func testEmptyAck() {
|
||||
let expectedSendString = "30[]"
|
||||
let packet = SocketPacket.packetFromEmit([], id: 0, nsp: "/", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testNullAck() {
|
||||
let expectedSendString = "30[null]"
|
||||
let sendData = [NSNull()]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testStringAck() {
|
||||
let expectedSendString = "30[\"test\"]"
|
||||
let sendData = ["test"]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testJSONAck() {
|
||||
let expectedSendString = "30[{\"test\":\"hello\",\"hello\":1,\"foobar\":true,\"null\":null}]"
|
||||
let sendData = [["foobar": true, "hello": 1, "test": "hello", "null": NSNull()]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testBinaryAck() {
|
||||
let expectedSendString = "61-0[{\"num\":0,\"_placeholder\":true}]"
|
||||
let sendData = [data]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data])
|
||||
}
|
||||
|
||||
func testMultipleBinaryAck() {
|
||||
let expectedSendString = "62-0[{\"data2\":{\"num\":0,\"_placeholder\":true},\"data1\":{\"num\":1,\"_placeholder\":true}}]"
|
||||
let sendData = [["data1": data, "data2": data2]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data2, data])
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// SocketEngineTest.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 10/15/15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SocketEngineTest: XCTestCase {
|
||||
var client: SocketIOClient!
|
||||
var engine: SocketEngine!
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
client = SocketIOClient(socketURL: "")
|
||||
engine = SocketEngine(client: client, options: nil)
|
||||
|
||||
client.setTestable()
|
||||
}
|
||||
|
||||
func testBasicPollingMessage() {
|
||||
let expectation = expectationWithDescription("Basic polling test")
|
||||
client.on("blankTest") {data, ack in
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
engine.parsePollingMessage("15:42[\"blankTest\"]")
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testTwoPacketsInOnePollTest() {
|
||||
let finalExpectation = expectationWithDescription("Final packet in poll test")
|
||||
var gotBlank = false
|
||||
|
||||
client.on("blankTest") {data, ack in
|
||||
gotBlank = true
|
||||
}
|
||||
|
||||
client.on("stringTest") {data, ack in
|
||||
if let str = data[0] as? String where gotBlank {
|
||||
if str == "hello" {
|
||||
finalExpectation.fulfill()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
engine.parsePollingMessage("15:42[\"blankTest\"]24:42[\"stringTest\",\"hello\"]")
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
//
|
||||
// SocketIO_MacTests.swift
|
||||
// SocketIO-MacTests
|
||||
//
|
||||
// Created by Nacho Soto on 7/11/15.
|
||||
//
|
||||
//
|
||||
|
||||
import Cocoa
|
||||
import XCTest
|
||||
|
||||
class SocketIO_MacTests: XCTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testExample() {
|
||||
// This is an example of a functional test case.
|
||||
XCTAssert(true, "Pass")
|
||||
}
|
||||
|
||||
func testPerformanceExample() {
|
||||
// This is an example of a performance test case.
|
||||
self.measureBlock() {
|
||||
// Put the code you want to measure the time of here.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// SocketNamespacePacketTest.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 10/11/15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SocketNamespacePacketTest: XCTestCase {
|
||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
let data2 = "test2".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
|
||||
func testEmpyEmit() {
|
||||
let expectedSendString = "2/swift,[\"test\"]"
|
||||
let sendData = ["test"]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testNullEmit() {
|
||||
let expectedSendString = "2/swift,[\"test\",null]"
|
||||
let sendData = ["test", NSNull()]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testStringEmit() {
|
||||
let expectedSendString = "2/swift,[\"test\",\"foo bar\"]"
|
||||
let sendData = ["test", "foo bar"]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testJSONEmit() {
|
||||
let expectedSendString = "2/swift,[\"test\",{\"test\":\"hello\",\"hello\":1,\"foobar\":true,\"null\":null}]"
|
||||
let sendData = ["test", ["foobar": true, "hello": 1, "test": "hello", "null": NSNull()]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testArrayEmit() {
|
||||
let expectedSendString = "2/swift,[\"test\",[\"hello\",1,{\"test\":\"test\"}]]"
|
||||
let sendData = ["test", ["hello", 1, ["test": "test"]]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testBinaryEmit() {
|
||||
let expectedSendString = "51-/swift,[\"test\",{\"num\":0,\"_placeholder\":true}]"
|
||||
let sendData = ["test", data]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data])
|
||||
}
|
||||
|
||||
func testMultipleBinaryEmit() {
|
||||
let expectedSendString = "52-/swift,[\"test\",{\"data1\":{\"num\":0,\"_placeholder\":true},\"data2\":{\"num\":1,\"_placeholder\":true}}]"
|
||||
let sendData = ["test", ["data1": data, "data2": data2]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data, data2])
|
||||
}
|
||||
|
||||
func testEmitWithAck() {
|
||||
let expectedSendString = "2/swift,0[\"test\"]"
|
||||
let sendData = ["test"]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testEmitDataWithAck() {
|
||||
let expectedSendString = "51-/swift,0[\"test\",{\"num\":0,\"_placeholder\":true}]"
|
||||
let sendData = ["test", data]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: false)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data])
|
||||
}
|
||||
|
||||
// Acks
|
||||
func testEmptyAck() {
|
||||
let expectedSendString = "3/swift,0[]"
|
||||
let packet = SocketPacket.packetFromEmit([], id: 0, nsp: "/swift", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testNullAck() {
|
||||
let expectedSendString = "3/swift,0[null]"
|
||||
let sendData = [NSNull()]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testStringAck() {
|
||||
let expectedSendString = "3/swift,0[\"test\"]"
|
||||
let sendData = ["test"]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testJSONAck() {
|
||||
let expectedSendString = "3/swift,0[{\"test\":\"hello\",\"hello\":1,\"foobar\":true,\"null\":null}]"
|
||||
let sendData = [["foobar": true, "hello": 1, "test": "hello", "null": NSNull()]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
}
|
||||
|
||||
func testBinaryAck() {
|
||||
let expectedSendString = "61-/swift,0[{\"num\":0,\"_placeholder\":true}]"
|
||||
let sendData = [data]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data])
|
||||
}
|
||||
|
||||
func testMultipleBinaryAck() {
|
||||
let expectedSendString = "62-/swift,0[{\"data2\":{\"num\":0,\"_placeholder\":true},\"data1\":{\"num\":1,\"_placeholder\":true}}]"
|
||||
let sendData = [["data1": data, "data2": data2]]
|
||||
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||
|
||||
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||
XCTAssertEqual(packet.binary, [data2, data])
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// SocketSideEffectTest.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 10/11/15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SocketSideEffectTest: XCTestCase {
|
||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
let data2 = "test2".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
private var socket: SocketIOClient!
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
socket = SocketIOClient(socketURL: "")
|
||||
socket.setTestable()
|
||||
}
|
||||
|
||||
func testInitialCurrentAck() {
|
||||
XCTAssertEqual(socket.currentAck, -1)
|
||||
}
|
||||
|
||||
func testFirstAck() {
|
||||
socket.emitWithAck("test")(timeoutAfter: 0) {data in}
|
||||
XCTAssertEqual(socket.currentAck, 0)
|
||||
}
|
||||
|
||||
func testSecondAck() {
|
||||
socket.emitWithAck("test")(timeoutAfter: 0) {data in}
|
||||
socket.emitWithAck("test")(timeoutAfter: 0) {data in}
|
||||
|
||||
XCTAssertEqual(socket.currentAck, 1)
|
||||
}
|
||||
|
||||
func testHandleAck() {
|
||||
let expectation = expectationWithDescription("handled ack")
|
||||
socket.emitWithAck("test")(timeoutAfter: 0) {data in
|
||||
XCTAssertEqual(data[0] as? String, "hello world")
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
socket.parseSocketMessage("30[\"hello world\"]")
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testHandleEvent() {
|
||||
let expectation = expectationWithDescription("handled event")
|
||||
socket.on("test") {data, ack in
|
||||
XCTAssertEqual(data[0] as? String, "hello world")
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
socket.parseSocketMessage("2[\"test\",\"hello world\"]")
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testHandleBinaryEvent() {
|
||||
let expectation = expectationWithDescription("handled binary event")
|
||||
socket.on("test") {data, ack in
|
||||
if let dict = data[0] as? NSDictionary, data = dict["test"] as? NSData {
|
||||
XCTAssertEqual(data, self.data)
|
||||
expectation.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
socket.parseSocketMessage("51-[\"test\",{\"test\":{\"_placeholder\":true,\"num\":0}}]")
|
||||
socket.parseBinaryData(data)
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testHandleMultipleBinaryEvent() {
|
||||
let expectation = expectationWithDescription("handled multiple binary event")
|
||||
socket.on("test") {data, ack in
|
||||
if let dict = data[0] as? NSDictionary, data = dict["test"] as? NSData,
|
||||
data2 = dict["test2"] as? NSData {
|
||||
XCTAssertEqual(data, self.data)
|
||||
XCTAssertEqual(data2, self.data2)
|
||||
expectation.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
socket.parseSocketMessage("52-[\"test\",{\"test\":{\"_placeholder\":true,\"num\":0},\"test2\":{\"_placeholder\":true,\"num\":1}}]")
|
||||
socket.parseBinaryData(data)
|
||||
socket.parseBinaryData(data2)
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
//
|
||||
// AbstractSocketTest.swift
|
||||
// AbstractSocketTest.socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Lukas Schmidt on 02.08.15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class AbstractSocketTest: XCTestCase {
|
||||
static let testLocal = false
|
||||
static let serverURL = AbstractSocketTest.testLocal ? "localhost:6979" : "milkbartube.com:6979"
|
||||
static let TEST_TIMEOUT = 8.0
|
||||
static var socket:SocketIOClient!
|
||||
var testKind:TestKind?
|
||||
|
||||
|
||||
func openConnection() {
|
||||
guard AbstractSocketTest.socket.status == SocketIOClientStatus.NotConnected else {return}
|
||||
|
||||
weak var expection = self.expectationWithDescription("connect")
|
||||
XCTAssertTrue(AbstractSocketTest.socket.status == SocketIOClientStatus.NotConnected)
|
||||
AbstractSocketTest.socket.on("connect") {data, ack in
|
||||
XCTAssertEqual(AbstractSocketTest.socket.status, SocketIOClientStatus.Connected)
|
||||
XCTAssertFalse(AbstractSocketTest.socket.secure)
|
||||
if let expection = expection {
|
||||
expection.fulfill()
|
||||
}
|
||||
}
|
||||
AbstractSocketTest.socket.connect()
|
||||
XCTAssertEqual(AbstractSocketTest.socket.status, SocketIOClientStatus.Connecting)
|
||||
waitForExpectationsWithTimeout(AbstractSocketTest.TEST_TIMEOUT, handler: nil)
|
||||
}
|
||||
|
||||
func generateTestName(rawTestName:String) ->String {
|
||||
return rawTestName + testKind!.rawValue
|
||||
}
|
||||
|
||||
func checkConnectionStatus() {
|
||||
XCTAssertEqual(AbstractSocketTest.socket.status, SocketIOClientStatus.Connected)
|
||||
XCTAssertFalse(AbstractSocketTest.socket.secure)
|
||||
}
|
||||
|
||||
func socketMultipleEmit(testName:String, emitData:Array<AnyObject>, callback:NormalCallback){
|
||||
let finalTestname = generateTestName(testName)
|
||||
weak var expection = self.expectationWithDescription(finalTestname)
|
||||
func didGetEmit(result:NSArray?, ack:AckEmitter?) {
|
||||
callback(result, ack)
|
||||
if let expection = expection {
|
||||
expection.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
AbstractSocketTest.socket.emit(finalTestname, withItems: emitData)
|
||||
AbstractSocketTest.socket.on(finalTestname + "Return", callback: didGetEmit)
|
||||
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
||||
}
|
||||
|
||||
|
||||
func socketEmit(testName:String, emitData:AnyObject?, callback:NormalCallback){
|
||||
let finalTestname = generateTestName(testName)
|
||||
weak var expection = self.expectationWithDescription(finalTestname)
|
||||
func didGetEmit(result:NSArray?, ack:AckEmitter?) {
|
||||
callback(result, ack)
|
||||
if let expection = expection {
|
||||
expection.fulfill()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AbstractSocketTest.socket.on(finalTestname + "Return", callback: didGetEmit)
|
||||
if let emitData = emitData {
|
||||
AbstractSocketTest.socket.emit(finalTestname, emitData)
|
||||
} else {
|
||||
AbstractSocketTest.socket.emit(finalTestname)
|
||||
}
|
||||
|
||||
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
||||
}
|
||||
|
||||
func socketAcknwoledgeMultiple(testName:String, Data:Array<AnyObject>, callback:NormalCallback){
|
||||
let finalTestname = generateTestName(testName)
|
||||
weak var expection = self.expectationWithDescription(finalTestname)
|
||||
func didGetResult(result:NSArray?) {
|
||||
callback(result, nil)
|
||||
if let expection = expection {
|
||||
expection.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
AbstractSocketTest.socket.emitWithAck(finalTestname, withItems: Data)(timeoutAfter: 5, callback: didGetResult)
|
||||
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
||||
}
|
||||
|
||||
func socketAcknwoledge(testName:String, Data:AnyObject?, callback:NormalCallback){
|
||||
let finalTestname = generateTestName(testName)
|
||||
weak var expection = self.expectationWithDescription(finalTestname)
|
||||
func didGet(result:NSArray?) {
|
||||
callback(result, nil)
|
||||
if let expection = expection {
|
||||
expection.fulfill()
|
||||
}
|
||||
}
|
||||
var ack:OnAckCallback!
|
||||
if let Data = Data {
|
||||
ack = AbstractSocketTest.socket.emitWithAck(finalTestname, Data)
|
||||
} else {
|
||||
ack = AbstractSocketTest.socket.emitWithAck(finalTestname)
|
||||
}
|
||||
ack(timeoutAfter: 20, callback: didGet)
|
||||
|
||||
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
||||
}
|
||||
}
|
||||
@@ -14,9 +14,8 @@ class SocketAckManagerTest: XCTestCase {
|
||||
func testAddAcks() {
|
||||
let callbackExpection = self.expectationWithDescription("callbackExpection")
|
||||
let itemsArray = ["Hi", "ho"]
|
||||
func callback(items: NSArray?) {
|
||||
func callback(items: [AnyObject]) {
|
||||
callbackExpection.fulfill()
|
||||
items?.isEqualToArray(itemsArray)
|
||||
}
|
||||
ackManager.addAck(1, callback: callback)
|
||||
ackManager.executeAck(1, items: itemsArray)
|
||||
|
||||
@@ -1,88 +0,0 @@
|
||||
//
|
||||
// SocketAcknowledgementTest.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Lukas Schmidt on 27.07.15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SocketAcknowledgementTest: AbstractSocketTest {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
testKind = TestKind.Acknowledgement
|
||||
if AbstractSocketTest.socket == nil {
|
||||
AbstractSocketTest.socket = SocketIOClient(socketURL: "milkbartube.com:6979", opts: [
|
||||
"reconnects": true, // default true
|
||||
"reconnectAttempts": -1, // default -1
|
||||
"reconnectWait": 5, // default 10
|
||||
"forcePolling": false,
|
||||
"forceWebsockets": false,// default false
|
||||
"path": ""])
|
||||
openConnection()
|
||||
}else {
|
||||
AbstractSocketTest.socket.leaveNamespace()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func testConnectionStatus() {
|
||||
super.checkConnectionStatus()
|
||||
}
|
||||
|
||||
func testBasic() {
|
||||
SocketTestCases.testBasic(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testNull() {
|
||||
SocketTestCases.testNull(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testBinary() {
|
||||
SocketTestCases.testBinary(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testArray() {
|
||||
SocketTestCases.testArray(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testString() {
|
||||
SocketTestCases.testString(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testBool() {
|
||||
SocketTestCases.testBool(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testInteger() {
|
||||
SocketTestCases.testInteger(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testDouble() {
|
||||
SocketTestCases.testDouble(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testJSON() {
|
||||
SocketTestCases.testJSON(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testJSONWithBuffer() {
|
||||
SocketTestCases.testJSONWithBuffer(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testUnicode() {
|
||||
SocketTestCases.testUnicode(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testMultipleItems() {
|
||||
SocketTestCases.testMultipleItems(socketAcknwoledgeMultiple)
|
||||
}
|
||||
|
||||
func testMultipleWithBuffer() {
|
||||
SocketTestCases.testMultipleItemsWithBuffer(socketAcknwoledgeMultiple)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
//
|
||||
// ConvertedSocketTest.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Lukas Schmidt on 25.07.15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Foundation
|
||||
|
||||
class SocketEmitTest: AbstractSocketTest {
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
testKind = TestKind.Emit
|
||||
if AbstractSocketTest.socket == nil {
|
||||
AbstractSocketTest.socket = SocketIOClient(socketURL: AbstractSocketTest.serverURL, opts: [
|
||||
"reconnects": true, // default true
|
||||
"reconnectAttempts": -1, // default -1
|
||||
"reconnectWait": 5, // default 10
|
||||
"forcePolling": false,
|
||||
"forceWebsockets": false,// default false
|
||||
"path": ""]
|
||||
)
|
||||
openConnection()
|
||||
}else {
|
||||
AbstractSocketTest.socket.leaveNamespace()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testConnectionStatus() {
|
||||
super.checkConnectionStatus()
|
||||
}
|
||||
|
||||
func testBasic() {
|
||||
SocketTestCases.testBasic(socketEmit)
|
||||
}
|
||||
|
||||
func testNull() {
|
||||
SocketTestCases.testNull(socketEmit)
|
||||
}
|
||||
|
||||
func testBinary() {
|
||||
SocketTestCases.testBinary(socketEmit)
|
||||
}
|
||||
|
||||
func testArray() {
|
||||
SocketTestCases.testArray(socketEmit)
|
||||
}
|
||||
|
||||
func testString() {
|
||||
SocketTestCases.testString(socketEmit)
|
||||
}
|
||||
|
||||
func testBool() {
|
||||
SocketTestCases.testBool(socketEmit)
|
||||
}
|
||||
|
||||
func testInteger() {
|
||||
SocketTestCases.testInteger(socketEmit)
|
||||
}
|
||||
|
||||
func testDouble() {
|
||||
SocketTestCases.testDouble(socketEmit)
|
||||
}
|
||||
|
||||
func testJSON() {
|
||||
SocketTestCases.testJSON(socketEmit)
|
||||
}
|
||||
|
||||
func testJSONWithBuffer() {
|
||||
SocketTestCases.testJSONWithBuffer(socketEmit)
|
||||
}
|
||||
|
||||
func testUnicode() {
|
||||
SocketTestCases.testUnicode(socketEmit)
|
||||
}
|
||||
|
||||
func testMultipleItems() {
|
||||
SocketTestCases.testMultipleItems(socketMultipleEmit)
|
||||
}
|
||||
|
||||
func testMultipleWithBuffer() {
|
||||
SocketTestCases.testMultipleItemsWithBuffer(socketMultipleEmit)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
//
|
||||
// SocketNamespaceAcknowledgementTest.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Lukas Schmidt on 28.07.15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SocketNamespaceAcknowledgementTest: AbstractSocketTest {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
testKind = TestKind.Acknowledgement
|
||||
if AbstractSocketTest.socket == nil {
|
||||
AbstractSocketTest.socket = SocketIOClient(socketURL: AbstractSocketTest.serverURL, opts: [
|
||||
"reconnects": true, // default true
|
||||
"reconnectAttempts": -1, // default -1
|
||||
"reconnectWait": 5, // default 10
|
||||
"forcePolling": false,
|
||||
"forceWebsockets": false,// default false
|
||||
"path": "",
|
||||
"nsp": "/swift"])
|
||||
openConnection()
|
||||
}else {
|
||||
AbstractSocketTest.socket.joinNamespace("/swift")
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
func testConnectionStatus() {
|
||||
super.checkConnectionStatus()
|
||||
}
|
||||
|
||||
func testBasic() {
|
||||
SocketTestCases.testBasic(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testNull() {
|
||||
SocketTestCases.testNull(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testBinary() {
|
||||
SocketTestCases.testBinary(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testArray() {
|
||||
SocketTestCases.testArray(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testString() {
|
||||
SocketTestCases.testString(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testBool() {
|
||||
SocketTestCases.testBool(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testInteger() {
|
||||
SocketTestCases.testInteger(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testDouble() {
|
||||
SocketTestCases.testDouble(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testJSON() {
|
||||
SocketTestCases.testJSON(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testJSONWithBuffer() {
|
||||
SocketTestCases.testJSONWithBuffer(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testUnicode() {
|
||||
SocketTestCases.testUnicode(socketAcknwoledge)
|
||||
}
|
||||
|
||||
func testMultipleItems() {
|
||||
SocketTestCases.testMultipleItems(socketAcknwoledgeMultiple)
|
||||
}
|
||||
|
||||
func testMultipleWithBuffer() {
|
||||
SocketTestCases.testMultipleItemsWithBuffer(socketAcknwoledgeMultiple)
|
||||
}
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
//
|
||||
// SocketNamespaceEmitTest.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Lukas Schmidt on 26.07.15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
class SocketNamespaceEmitTest: AbstractSocketTest {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
testKind = TestKind.Emit
|
||||
if AbstractSocketTest.socket == nil {
|
||||
AbstractSocketTest.socket = SocketIOClient(socketURL: AbstractSocketTest.serverURL, opts: [
|
||||
"reconnects": true, // default true
|
||||
"reconnectAttempts": -1, // default -1
|
||||
"reconnectWait": 5, // default 10
|
||||
"forcePolling": false,
|
||||
"forceWebsockets": false,// default false
|
||||
"path": "",
|
||||
"nsp": "/swift"])
|
||||
openConnection()
|
||||
}else {
|
||||
AbstractSocketTest.socket.joinNamespace("/swift")
|
||||
}
|
||||
}
|
||||
|
||||
func testConnectionStatus() {
|
||||
super.checkConnectionStatus()
|
||||
}
|
||||
|
||||
func testBasic() {
|
||||
SocketTestCases.testBasic(socketEmit)
|
||||
}
|
||||
|
||||
func testNull() {
|
||||
SocketTestCases.testNull(socketEmit)
|
||||
}
|
||||
|
||||
func testBinary() {
|
||||
SocketTestCases.testBinary(socketEmit)
|
||||
}
|
||||
|
||||
func testArray() {
|
||||
SocketTestCases.testArray(socketEmit)
|
||||
}
|
||||
|
||||
func testString() {
|
||||
SocketTestCases.testString(socketEmit)
|
||||
}
|
||||
|
||||
func testBool() {
|
||||
SocketTestCases.testBool(socketEmit)
|
||||
}
|
||||
|
||||
func testInteger() {
|
||||
SocketTestCases.testInteger(socketEmit)
|
||||
}
|
||||
|
||||
func testDouble() {
|
||||
SocketTestCases.testDouble(socketEmit)
|
||||
}
|
||||
|
||||
func testJSON() {
|
||||
SocketTestCases.testJSON(socketEmit)
|
||||
}
|
||||
|
||||
func testJSONWithBuffer() {
|
||||
SocketTestCases.testJSONWithBuffer(socketEmit)
|
||||
}
|
||||
|
||||
func testUnicode() {
|
||||
SocketTestCases.testUnicode(socketEmit)
|
||||
}
|
||||
|
||||
func testMultipleItems() {
|
||||
SocketTestCases.testMultipleItems(socketMultipleEmit)
|
||||
}
|
||||
|
||||
func testMultipleWithBuffer() {
|
||||
SocketTestCases.testMultipleItemsWithBuffer(socketMultipleEmit)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,13 +13,17 @@ class SocketParserTest: XCTestCase {
|
||||
//Format key: message; namespace-data-binary-id
|
||||
static let packetTypes: Dictionary<String, (String, [AnyObject], [NSData], Int)> = [
|
||||
"0": ("/", [], [], -1), "1": ("/", [], [], -1),
|
||||
"25[\"test\"]": ("/", ["test"], [], 5),
|
||||
"2[\"test\",\"~~0\"]": ("/", ["test", "~~0"], [], -1),
|
||||
"2/swift,[\"testArrayEmitReturn\",[\"test3\",\"test4\"]]": ("/swift", ["testArrayEmitReturn", ["test3", "test4"]], [], -1),
|
||||
"51-/swift,[\"testMultipleItemsWithBufferEmitReturn\",[1,2],{\"test\":\"bob\"},25,\"polo\",{\"_placeholder\":true,\"num\":0}]": ("/swift", ["testMultipleItemsWithBufferEmitReturn", [1, 2], ["test": "bob"], 25, "polo", "~~0"], [], -1),
|
||||
"3/swift,0[[\"test3\",\"test4\"]]": ("/swift", [["test3", "test4"]], [], 0),
|
||||
"61-/swift,19[[1,2],{\"test\":\"bob\"},25,\"polo\",{\"_placeholder\":true,\"num\":0}]": ("/swift", [ [1, 2], ["test": "bob"], 25, "polo", "~~0"], [], 19),
|
||||
"4/swift,": ("/swift", [], [], -1),
|
||||
"0/swift": ("/swift", [], [], -1),
|
||||
"1/swift": ("/swift", [], [], -1)]
|
||||
"1/swift": ("/swift", [], [], -1),
|
||||
"4\"ERROR\"": ("/", ["ERROR"], [], -1),
|
||||
"41": ("/", [1], [], -1)]
|
||||
|
||||
func testDisconnect() {
|
||||
let message = "1"
|
||||
@@ -41,6 +45,16 @@ class SocketParserTest: XCTestCase {
|
||||
validateParseResult(message)
|
||||
}
|
||||
|
||||
func testIdEvent() {
|
||||
let message = "25[\"test\"]"
|
||||
validateParseResult(message)
|
||||
}
|
||||
|
||||
func testBinaryPlaceholderAsString() {
|
||||
let message = "2[\"test\",\"~~0\"]"
|
||||
validateParseResult(message)
|
||||
}
|
||||
|
||||
func testNameSpaceArrayParse() {
|
||||
let message = "2/swift,[\"testArrayEmitReturn\",[\"test3\",\"test4\"]]"
|
||||
validateParseResult(message)
|
||||
@@ -66,9 +80,24 @@ class SocketParserTest: XCTestCase {
|
||||
validateParseResult(message)
|
||||
}
|
||||
|
||||
func testErrorTypeString() {
|
||||
let message = "4\"ERROR\""
|
||||
validateParseResult(message)
|
||||
}
|
||||
|
||||
func testErrorTypeInt() {
|
||||
let message = "41"
|
||||
validateParseResult(message)
|
||||
}
|
||||
|
||||
func testInvalidInput() {
|
||||
let message = "8"
|
||||
XCTAssertNil(SocketParser.parseString(message))
|
||||
switch SocketParser.parseString(message) {
|
||||
case .Left(_):
|
||||
return
|
||||
case .Right(_):
|
||||
XCTFail("Created packet when shouldn't have")
|
||||
}
|
||||
}
|
||||
|
||||
func testGenericParser() {
|
||||
@@ -83,8 +112,8 @@ class SocketParserTest: XCTestCase {
|
||||
let validValues = SocketParserTest.packetTypes[message]!
|
||||
let packet = SocketParser.parseString(message)
|
||||
let type = message.substringWithRange(Range<String.Index>(start: message.startIndex, end: message.startIndex.advancedBy(1)))
|
||||
if let packet = packet {
|
||||
XCTAssertEqual(packet.type, SocketPacket.PacketType(str:type)!)
|
||||
if case let .Right(packet) = packet {
|
||||
XCTAssertEqual(packet.type, SocketPacket.PacketType(rawValue: Int(type) ?? -1)!)
|
||||
XCTAssertEqual(packet.nsp, validValues.0)
|
||||
XCTAssertTrue((packet.data as NSArray).isEqualToArray(validValues.1))
|
||||
XCTAssertTrue((packet.binary as NSArray).isEqualToArray(validValues.2))
|
||||
|
||||
@@ -1,248 +0,0 @@
|
||||
//
|
||||
// SocketTestCases.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Lukas Schmidt on 02.08.15.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import Foundation
|
||||
|
||||
class SocketTestCases: NSObject {
|
||||
typealias SocketSendFunction = (testName:String, emitData:AnyObject?, callback:NormalCallback)->()
|
||||
|
||||
static func testBasic(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "basicTest"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
|
||||
}
|
||||
abstractSocketSend(testName: testName, emitData: nil, callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testNull(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testNull"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let _ = result?.firstObject as? NSNull {
|
||||
|
||||
}else
|
||||
{
|
||||
XCTFail("Should have NSNull as result")
|
||||
}
|
||||
}
|
||||
abstractSocketSend(testName: testName, emitData: NSNull(), callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testBinary(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testBinary"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let data = result?.firstObject as? NSData {
|
||||
let string = NSString(data: data, encoding: NSUTF8StringEncoding)!
|
||||
XCTAssertEqual(string, "gakgakgak2")
|
||||
}else {
|
||||
XCTFail("Should have NSData as result")
|
||||
}
|
||||
}
|
||||
let data = NSString(string: "gakgakgak2").dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
abstractSocketSend(testName: testName, emitData: data, callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testArray(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testArray"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let array = result?.firstObject as? NSArray {
|
||||
XCTAssertEqual(array.count, 2)
|
||||
XCTAssertEqual((array.firstObject! as! String), "test3")
|
||||
XCTAssertEqual((array.lastObject! as! String), "test4")
|
||||
}else {
|
||||
XCTFail("Should have NSArray as result")
|
||||
}
|
||||
}
|
||||
abstractSocketSend(testName: testName, emitData: ["test1", "test2"], callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testString(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testString"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let string = result?.firstObject as? String {
|
||||
XCTAssertEqual(string, "polo")
|
||||
}else {
|
||||
XCTFail("Should have String as result")
|
||||
}
|
||||
}
|
||||
abstractSocketSend(testName: testName, emitData: "marco", callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testBool(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testBool"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let bool = result?.firstObject as? NSNumber {
|
||||
XCTAssertTrue(bool.boolValue)
|
||||
}else {
|
||||
XCTFail("Should have Boolean as result")
|
||||
}
|
||||
}
|
||||
abstractSocketSend(testName: testName, emitData: false, callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testInteger(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testInteger"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let integer = result?.firstObject as? Int {
|
||||
XCTAssertEqual(integer, 20)
|
||||
}else {
|
||||
XCTFail("Should have Integer as result")
|
||||
}
|
||||
}
|
||||
abstractSocketSend(testName: testName, emitData: 10, callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testDouble(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testDouble"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let double = result?.firstObject as? NSNumber {
|
||||
XCTAssertEqual(double.floatValue, 1.2)
|
||||
}else {
|
||||
XCTFail("Should have Double as result")
|
||||
}
|
||||
}
|
||||
abstractSocketSend(testName: testName, emitData: 1.1, callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testJSONWithBuffer(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testJSONWithBuffer"
|
||||
let data = "0".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
|
||||
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let json = result?.firstObject as? NSDictionary {
|
||||
XCTAssertEqual((json.valueForKey("testString")! as! String), "test")
|
||||
XCTAssertEqual((json.valueForKey("testNumber")! as! Int), 15)
|
||||
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).count, 2)
|
||||
XCTAssertEqual(((json.valueForKey("testArray")! as! Array<AnyObject>).last! as! Int), 1)
|
||||
let string = NSString(data: (json.valueForKey("testArray")! as! Array<AnyObject>).first! as! NSData, encoding: NSUTF8StringEncoding)!
|
||||
XCTAssertEqual(string, "gakgakgak2")
|
||||
}else {
|
||||
XCTFail("Should have NSDictionary as result")
|
||||
}
|
||||
}
|
||||
let json = ["name": "test", "testArray": ["hallo"], "nestedTest": ["test": "test"], "number": 15, "buf": data]
|
||||
|
||||
abstractSocketSend(testName: testName, emitData: json, callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testJSON(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testJSON"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let json = result?.firstObject as? NSDictionary {
|
||||
XCTAssertEqual((json.valueForKey("testString")! as! String), "test")
|
||||
XCTAssertEqual(json.valueForKey("testNumber")! as? Int, 15)
|
||||
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).count, 2)
|
||||
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).first! as? Int, 1)
|
||||
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).last! as? Int, 1)
|
||||
|
||||
}else {
|
||||
XCTFail("Should have NSDictionary as result")
|
||||
}
|
||||
}
|
||||
let json = ["name": "test", "testArray": ["hallo"], "nestedTest": ["test": "test"], "number": 15]
|
||||
|
||||
abstractSocketSend(testName: testName, emitData: json, callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testUnicode(abstractSocketSend:SocketSendFunction) {
|
||||
let testName = "testUnicode"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
if let unicode = result?.firstObject as? String {
|
||||
XCTAssertEqual(unicode, "🚄")
|
||||
}else {
|
||||
XCTFail("Should have String as result")
|
||||
}
|
||||
}
|
||||
abstractSocketSend(testName: testName, emitData: "🚀", callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testMultipleItemsWithBuffer(abstractSocketMultipleSend:(testName:String, emitData:Array<AnyObject>, callback:NormalCallback)->()) {
|
||||
let testName = "testMultipleItemsWithBuffer"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
XCTAssertEqual(result!.count, 5)
|
||||
if result!.count != 5 {
|
||||
XCTFail("Fatal Fail. Lost some Data")
|
||||
return
|
||||
}
|
||||
if let array = result?.firstObject as? Array<AnyObject> {
|
||||
XCTAssertEqual((array.last! as! Int), 2)
|
||||
XCTAssertEqual((array.first! as! Int), 1)
|
||||
}else {
|
||||
XCTFail("Should have Array as result")
|
||||
}
|
||||
if let dict = result?[1] as? NSDictionary {
|
||||
XCTAssertEqual((dict.valueForKey("test") as! String), "bob")
|
||||
|
||||
}else {
|
||||
XCTFail("Should have NSDictionary as result")
|
||||
}
|
||||
if let number = result?[2] as? Int {
|
||||
XCTAssertEqual(number, 25)
|
||||
|
||||
}else {
|
||||
XCTFail("Should have Integer as result")
|
||||
}
|
||||
if let string = result?[3] as? String {
|
||||
XCTAssertEqual(string, "polo")
|
||||
|
||||
}else {
|
||||
XCTFail("Should have Integer as result")
|
||||
}
|
||||
if let data = result?[4] as? NSData {
|
||||
let string = NSString(data: data, encoding: NSUTF8StringEncoding)!
|
||||
XCTAssertEqual(string, "gakgakgak2")
|
||||
}else {
|
||||
XCTFail("Should have NSData as result")
|
||||
}
|
||||
}
|
||||
let data = NSString(string: "gakgakgak2").dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
let emitArray = [["test1", "test2"], ["test": "test"], 15, "marco", data]
|
||||
abstractSocketMultipleSend(testName: testName, emitData: emitArray, callback: didGetResult)
|
||||
}
|
||||
|
||||
static func testMultipleItems(abstractSocketMultipleSend:(testName:String, emitData:Array<AnyObject>, callback:NormalCallback)->()) {
|
||||
let testName = "testMultipleItems"
|
||||
func didGetResult(result:NSArray?, ack:AckEmitter?) {
|
||||
XCTAssertEqual(result!.count, 5)
|
||||
if result!.count != 5 {
|
||||
XCTFail("Fatal Fail. Lost some Data")
|
||||
return
|
||||
}
|
||||
if let array = result?.firstObject as? Array<AnyObject> {
|
||||
XCTAssertEqual((array.last! as! Int), 2)
|
||||
XCTAssertEqual((array.first! as! Int), 1)
|
||||
}else {
|
||||
XCTFail("Should have Array as result")
|
||||
}
|
||||
if let dict = result?[1] as? NSDictionary {
|
||||
XCTAssertEqual((dict.valueForKey("test") as! String), "bob")
|
||||
|
||||
}else {
|
||||
XCTFail("Should have NSDictionary as result")
|
||||
}
|
||||
if let number = result?[2] as? Int {
|
||||
XCTAssertEqual(number, 25)
|
||||
|
||||
}else {
|
||||
XCTFail("Should have Integer as result")
|
||||
}
|
||||
if let string = result?[3] as? String {
|
||||
XCTAssertEqual(string, "polo")
|
||||
}else {
|
||||
XCTFail("Should have Integer as result")
|
||||
}
|
||||
if let bool = result?[4] as? NSNumber {
|
||||
XCTAssertFalse(bool.boolValue)
|
||||
}else {
|
||||
XCTFail("Should have NSNumber as result")
|
||||
}
|
||||
}
|
||||
let emitArray = [["test1", "test2"], ["test": "test"], 15, "marco", false]
|
||||
abstractSocketMultipleSend(testName: testName, emitData: emitArray, callback: didGetResult)
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
//
|
||||
// TestKind.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Lukas Schmidt on 28.07.15.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
enum TestKind: String {
|
||||
case Emit, Acknowledgement
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// SocketAckEmitter.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 9/16/15.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
public final class SocketAckEmitter: NSObject {
|
||||
let socket: SocketIOClient
|
||||
let ackNum: Int
|
||||
|
||||
init(socket: SocketIOClient, ackNum: Int) {
|
||||
self.socket = socket
|
||||
self.ackNum = ackNum
|
||||
}
|
||||
|
||||
public func with(items: AnyObject...) {
|
||||
socket.emitAck(ackNum, withItems: items)
|
||||
}
|
||||
|
||||
public func with(items: [AnyObject]) {
|
||||
socket.emitAck(ackNum, withItems: items)
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ struct SocketAckManager {
|
||||
acks.insert(SocketAck(ack: ack, callback: callback))
|
||||
}
|
||||
|
||||
mutating func executeAck(ack: Int, items: [AnyObject]?) {
|
||||
mutating func executeAck(ack: Int, items: [AnyObject]) {
|
||||
let callback = acks.remove(SocketAck(ack: ack))
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
|
||||
@@ -24,16 +24,24 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
private typealias Probe = (msg: String, type: PacketType, data: [NSData]?)
|
||||
public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
public private(set) var sid = ""
|
||||
public private(set) var cookies: [NSHTTPCookie]?
|
||||
public private(set) var socketPath = ""
|
||||
public private(set) var urlPolling = ""
|
||||
public private(set) var urlWebSocket = ""
|
||||
public private(set) var ws: WebSocket?
|
||||
|
||||
public weak var client: SocketEngineClient?
|
||||
|
||||
private typealias Probe = (msg: String, type: SocketEnginePacketType, data: [NSData]?)
|
||||
private typealias ProbeWaitQueue = [Probe]
|
||||
|
||||
private let allowedCharacterSet = NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
|
||||
private let emitQueue = dispatch_queue_create("engineEmitQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let handleQueue = dispatch_queue_create("engineHandleQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let emitQueue = dispatch_queue_create("com.socketio.engineEmitQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let handleQueue = dispatch_queue_create("com.socketio.engineHandleQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let logType = "SocketEngine"
|
||||
private let parseQueue = dispatch_queue_create("engineParseQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let session: NSURLSession!
|
||||
private let parseQueue = dispatch_queue_create("com.socketio.engineParseQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let workQueue = NSOperationQueue()
|
||||
|
||||
private var closed = false
|
||||
@@ -41,6 +49,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
private var fastUpgrade = false
|
||||
private var forcePolling = false
|
||||
private var forceWebsockets = false
|
||||
private var invalidated = false
|
||||
private var pingInterval: Double?
|
||||
private var pingTimer: NSTimer?
|
||||
private var pingTimeout = 0.0 {
|
||||
@@ -53,6 +62,8 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
private var postWait = [String]()
|
||||
private var probing = false
|
||||
private var probeWait = ProbeWaitQueue()
|
||||
private var session: NSURLSession!
|
||||
private var voipEnabled = false
|
||||
private var waitingForPoll = false
|
||||
private var waitingForPost = false
|
||||
private var websocketConnected = false
|
||||
@@ -60,63 +71,82 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
private(set) var connected = false
|
||||
private(set) var polling = true
|
||||
private(set) var websocket = false
|
||||
|
||||
weak var client: SocketEngineClient?
|
||||
var cookies: [NSHTTPCookie]?
|
||||
var sid = ""
|
||||
var socketPath = ""
|
||||
var urlPolling: String?
|
||||
var urlWebSocket: String?
|
||||
var ws: WebSocket?
|
||||
|
||||
@objc public enum PacketType: Int {
|
||||
case Open, Close, Ping, Pong, Message, Upgrade, Noop
|
||||
public init(client: SocketEngineClient, options: Set<SocketIOClientOption>) {
|
||||
self.client = client
|
||||
|
||||
init?(str: String) {
|
||||
if let value = Int(str), raw = PacketType(rawValue: value) {
|
||||
self = raw
|
||||
} else {
|
||||
return nil
|
||||
for option in options {
|
||||
switch option {
|
||||
case .SessionDelegate(let delegate):
|
||||
session = NSURLSession(configuration: .defaultSessionConfiguration(),
|
||||
delegate: delegate,
|
||||
delegateQueue: workQueue)
|
||||
case .ForcePolling(let force):
|
||||
forcePolling = force
|
||||
case .ForceWebsockets(let force):
|
||||
forceWebsockets = force
|
||||
case .Cookies(let cookies):
|
||||
self.cookies = cookies
|
||||
case .Path(let path):
|
||||
socketPath = path
|
||||
case .ExtraHeaders(let headers):
|
||||
extraHeaders = headers
|
||||
case .VoipEnabled(let enable):
|
||||
voipEnabled = enable
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if session == nil {
|
||||
session = NSURLSession(configuration: .defaultSessionConfiguration(),
|
||||
delegate: nil,
|
||||
delegateQueue: workQueue)
|
||||
}
|
||||
}
|
||||
|
||||
public init(client: SocketEngineClient, sessionDelegate: NSURLSessionDelegate?) {
|
||||
self.client = client
|
||||
self.session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration(),
|
||||
delegate: sessionDelegate, delegateQueue: workQueue)
|
||||
}
|
||||
|
||||
public convenience init(client: SocketEngineClient, opts: NSDictionary?) {
|
||||
self.init(client: client, sessionDelegate: opts?["sessionDelegate"] as? NSURLSessionDelegate)
|
||||
forceWebsockets = opts?["forceWebsockets"] as? Bool ?? false
|
||||
forcePolling = opts?["forcePolling"] as? Bool ?? false
|
||||
cookies = opts?["cookies"] as? [NSHTTPCookie]
|
||||
socketPath = opts?["path"] as? String ?? ""
|
||||
extraHeaders = opts?["extraHeaders"] as? [String: String]
|
||||
|
||||
public convenience init(client: SocketEngineClient, options: NSDictionary?) {
|
||||
self.init(client: client,
|
||||
options: SocketIOClientOption.NSDictionaryToSocketOptionsSet(options ?? [:]))
|
||||
}
|
||||
|
||||
deinit {
|
||||
Logger.log("Engine is being deinit", type: logType)
|
||||
closed = true
|
||||
stopPolling()
|
||||
}
|
||||
|
||||
public func close(fast fast: Bool) {
|
||||
Logger.log("Engine is being closed. Fast: %@", type: logType, args: fast)
|
||||
private func checkIfMessageIsBase64Binary(var message: String) {
|
||||
if message.hasPrefix("b4") {
|
||||
// binary in base64 string
|
||||
message.removeRange(Range<String.Index>(start: message.startIndex,
|
||||
end: message.startIndex.advancedBy(2)))
|
||||
|
||||
if let data = NSData(base64EncodedString: message,
|
||||
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters) {
|
||||
client?.parseBinaryData(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func close() {
|
||||
Logger.log("Engine is being closed.", type: logType)
|
||||
|
||||
pingTimer?.invalidate()
|
||||
closed = true
|
||||
|
||||
ws?.disconnect()
|
||||
|
||||
if fast || polling {
|
||||
write("", withType: PacketType.Close, withData: nil)
|
||||
client?.engineDidClose("Disconnect")
|
||||
if websocket {
|
||||
sendWebSocketMessage("", withType: .Close)
|
||||
} else {
|
||||
sendPollMessage("", withType: .Close)
|
||||
}
|
||||
|
||||
|
||||
ws?.disconnect()
|
||||
stopPolling()
|
||||
client?.engineDidClose("Disconnect")
|
||||
}
|
||||
|
||||
private func createBinaryDataForSend(data: NSData) -> (NSData?, String?) {
|
||||
private func createBinaryDataForSend(data: NSData) -> Either<NSData, String> {
|
||||
if websocket {
|
||||
var byteArray = [UInt8](count: 1, repeatedValue: 0x0)
|
||||
byteArray[0] = 4
|
||||
@@ -124,23 +154,20 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
|
||||
mutData.appendData(data)
|
||||
|
||||
return (mutData, nil)
|
||||
return .Left(mutData)
|
||||
} else {
|
||||
var str = "b4"
|
||||
str += data.base64EncodedStringWithOptions(
|
||||
NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
|
||||
let str = "b4" + data.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
|
||||
|
||||
return (nil, str)
|
||||
return .Right(str)
|
||||
}
|
||||
}
|
||||
|
||||
private func createURLs(params: [String: AnyObject]?) -> (String?, String?) {
|
||||
private func createURLs(params: [String: AnyObject]?) -> (String, String) {
|
||||
if client == nil {
|
||||
return (nil, nil)
|
||||
return ("", "")
|
||||
}
|
||||
|
||||
let path = socketPath == "" ? "/socket.io" : socketPath
|
||||
|
||||
let url = "\(client!.socketURL)\(path)/?transport="
|
||||
var urlPolling: String
|
||||
var urlWebSocket: String
|
||||
@@ -175,19 +202,26 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
return (urlPolling, urlWebSocket)
|
||||
}
|
||||
|
||||
private func createWebsocket(andConnect connect: Bool) {
|
||||
let wsUrl = urlWebSocket! + (sid == "" ? "" : "&sid=\(sid)")
|
||||
|
||||
ws = WebSocket(url: NSURL(string: wsUrl)!,
|
||||
cookies: cookies)
|
||||
|
||||
private func createWebsocketAndConnect(connect: Bool) {
|
||||
let wsUrl = urlWebSocket + (sid == "" ? "" : "&sid=\(sid)")
|
||||
|
||||
ws = WebSocket(url: NSURL(string: wsUrl)!)
|
||||
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
for (key, value) in headers {
|
||||
ws?.headers[key] = value
|
||||
}
|
||||
}
|
||||
|
||||
if extraHeaders != nil {
|
||||
for (headerName, value) in extraHeaders! {
|
||||
ws?.headers[headerName] = value
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ws?.queue = handleQueue
|
||||
ws?.voipEnabled = voipEnabled
|
||||
ws?.delegate = self
|
||||
|
||||
if connect {
|
||||
@@ -201,7 +235,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
"we'll probably disconnect soon. You should report this.", type: logType)
|
||||
}
|
||||
|
||||
sendWebSocketMessage("", withType: PacketType.Upgrade, datas: nil)
|
||||
sendWebSocketMessage("", withType: .Upgrade, datas: nil)
|
||||
websocket = true
|
||||
polling = false
|
||||
fastUpgrade = false
|
||||
@@ -209,66 +243,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
flushProbeWait()
|
||||
}
|
||||
|
||||
private func doPoll() {
|
||||
if websocket || waitingForPoll || !connected {
|
||||
return
|
||||
}
|
||||
|
||||
waitingForPoll = true
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling! + "&sid=\(sid)&b64=1")!)
|
||||
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
req.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
if extraHeaders != nil {
|
||||
for (headerName, value) in extraHeaders! {
|
||||
req.setValue(value, forHTTPHeaderField: headerName)
|
||||
}
|
||||
}
|
||||
|
||||
doRequest(req)
|
||||
}
|
||||
|
||||
private func doRequest(req: NSMutableURLRequest) {
|
||||
if !polling {
|
||||
return
|
||||
}
|
||||
|
||||
req.cachePolicy = NSURLRequestCachePolicy.ReloadIgnoringLocalAndRemoteCacheData
|
||||
|
||||
Logger.log("Doing polling request", type: logType)
|
||||
|
||||
session.dataTaskWithRequest(req) {[weak self] data, res, err in
|
||||
if let this = self {
|
||||
if err != nil || data == nil {
|
||||
if this.polling {
|
||||
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
||||
} else {
|
||||
Logger.error(err?.localizedDescription ?? "Error", type: this.logType)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Logger.log("Got polling response", type: this.logType)
|
||||
|
||||
if let str = NSString(data: data!, encoding: NSUTF8StringEncoding) as? String {
|
||||
dispatch_async(this.parseQueue) {[weak this] in
|
||||
this?.parsePollingMessage(str)
|
||||
}
|
||||
}
|
||||
|
||||
this.waitingForPoll = false
|
||||
|
||||
if this.fastUpgrade {
|
||||
this.doFastUpgrade()
|
||||
} else if !this.closed && this.polling {
|
||||
this.doPoll()
|
||||
}
|
||||
}}.resume()
|
||||
}
|
||||
|
||||
private func flushProbeWait() {
|
||||
Logger.log("Flushing probe wait", type: logType)
|
||||
|
||||
@@ -287,96 +261,12 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private func flushWaitingForPost() {
|
||||
if postWait.count == 0 || !connected {
|
||||
return
|
||||
} else if websocket {
|
||||
flushWaitingForPostToWebSocket()
|
||||
return
|
||||
}
|
||||
|
||||
var postStr = ""
|
||||
|
||||
for packet in postWait {
|
||||
let len = packet.characters.count
|
||||
|
||||
postStr += "\(len):\(packet)"
|
||||
}
|
||||
|
||||
postWait.removeAll(keepCapacity: false)
|
||||
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling! + "&sid=\(sid)")!)
|
||||
|
||||
if let cookies = cookies {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies)
|
||||
req.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
req.HTTPMethod = "POST"
|
||||
req.setValue("text/plain; charset=UTF-8", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding,
|
||||
allowLossyConversion: false)!
|
||||
|
||||
req.HTTPBody = postData
|
||||
req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length")
|
||||
|
||||
waitingForPost = true
|
||||
|
||||
Logger.log("POSTing: %@", type: logType, args: postStr)
|
||||
|
||||
session.dataTaskWithRequest(req) {[weak self] data, res, err in
|
||||
if let this = self {
|
||||
if err != nil && this.polling {
|
||||
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
||||
return
|
||||
} else if err != nil {
|
||||
NSLog(err?.localizedDescription ?? "Error")
|
||||
return
|
||||
}
|
||||
|
||||
this.waitingForPost = false
|
||||
|
||||
dispatch_async(this.emitQueue) {[weak this] in
|
||||
if !(this?.fastUpgrade ?? true) {
|
||||
this?.flushWaitingForPost()
|
||||
this?.doPoll()
|
||||
}
|
||||
}
|
||||
}}.resume()
|
||||
}
|
||||
|
||||
// We had packets waiting for send when we upgraded
|
||||
// Send them raw
|
||||
private func flushWaitingForPostToWebSocket() {
|
||||
guard let ws = self.ws else {return}
|
||||
|
||||
for msg in postWait {
|
||||
ws.writeString(msg)
|
||||
}
|
||||
|
||||
postWait.removeAll(keepCapacity: true)
|
||||
}
|
||||
|
||||
private func handleClose() {
|
||||
if let client = client where polling == true {
|
||||
client.engineDidClose("Disconnect")
|
||||
}
|
||||
}
|
||||
|
||||
private func checkIfMessageIsBase64Binary(var message: String) {
|
||||
if message.hasPrefix("b4") {
|
||||
// binary in base64 string
|
||||
message.removeRange(Range<String.Index>(start: message.startIndex,
|
||||
end: message.startIndex.advancedBy(2)))
|
||||
|
||||
if let data = NSData(base64EncodedString: message,
|
||||
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters) {
|
||||
client?.parseBinaryData(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleMessage(message: String) {
|
||||
client?.parseSocketMessage(message)
|
||||
}
|
||||
@@ -395,20 +285,20 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
|
||||
self.sid = sid
|
||||
connected = 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)
|
||||
createWebsocketAndConnect(true)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
@@ -450,7 +340,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
if connected {
|
||||
Logger.error("Tried to open while connected", type: logType)
|
||||
client?.didError("Tried to open while connected")
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -464,71 +354,55 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
if forceWebsockets {
|
||||
polling = false
|
||||
websocket = true
|
||||
createWebsocket(andConnect: true)
|
||||
createWebsocketAndConnect(true)
|
||||
return
|
||||
}
|
||||
|
||||
let reqPolling = NSMutableURLRequest(URL: NSURL(string: urlPolling! + "&b64=1")!)
|
||||
let reqPolling = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&b64=1")!)
|
||||
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
reqPolling.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
|
||||
if let extraHeaders = extraHeaders {
|
||||
for (headerName, value) in extraHeaders {
|
||||
reqPolling.setValue(value, forHTTPHeaderField: headerName)
|
||||
}
|
||||
}
|
||||
|
||||
doRequest(reqPolling)
|
||||
}
|
||||
|
||||
private func parsePollingMessage(str: String) {
|
||||
guard str.characters.count != 1 else {
|
||||
return
|
||||
}
|
||||
|
||||
var reader = SocketStringReader(message: str)
|
||||
|
||||
while reader.hasNext {
|
||||
let n = reader.readUntilStringOccurence(":")
|
||||
let str = reader.read(Int(n)!)
|
||||
|
||||
dispatch_async(handleQueue) {
|
||||
self.parseEngineMessage(str, fromPolling: true)
|
||||
}
|
||||
}
|
||||
doLongPoll(reqPolling)
|
||||
}
|
||||
|
||||
private func parseEngineData(data: NSData) {
|
||||
Logger.log("Got binary data: %@", type: "SocketEngine", args: data)
|
||||
client?.parseBinaryData(data.subdataWithRange(NSMakeRange(1, data.length - 1)))
|
||||
}
|
||||
|
||||
private func parseEngineMessage(var message: String, fromPolling: Bool) {
|
||||
Logger.log("Got message: %@", type: logType, args: message)
|
||||
|
||||
if fromPolling {
|
||||
fixDoubleUTF8(&message)
|
||||
}
|
||||
|
||||
let type = PacketType(str: (message["^(\\d)"].groups()?[1]) ?? "") ?? {
|
||||
let type = SocketEnginePacketType(rawValue: Int((message["^(\\d)"].groups()?[1]) ?? "") ?? -1) ?? {
|
||||
self.checkIfMessageIsBase64Binary(message)
|
||||
return .Noop
|
||||
}()
|
||||
|
||||
if fromPolling && type != .Noop {
|
||||
fixDoubleUTF8(&message)
|
||||
}
|
||||
|
||||
switch type {
|
||||
case PacketType.Message:
|
||||
case .Message:
|
||||
message.removeAtIndex(message.startIndex)
|
||||
handleMessage(message)
|
||||
case PacketType.Noop:
|
||||
case .Noop:
|
||||
handleNOOP()
|
||||
case PacketType.Pong:
|
||||
case .Pong:
|
||||
handlePong(message)
|
||||
case PacketType.Open:
|
||||
case .Open:
|
||||
message.removeAtIndex(message.startIndex)
|
||||
handleOpen(message)
|
||||
case PacketType.Close:
|
||||
case .Close:
|
||||
handleClose()
|
||||
default:
|
||||
Logger.log("Got unknown packet type", type: logType)
|
||||
@@ -537,16 +411,16 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
|
||||
private func probeWebSocket() {
|
||||
if websocketConnected {
|
||||
sendWebSocketMessage("probe", withType: PacketType.Ping)
|
||||
sendWebSocketMessage("probe", withType: .Ping)
|
||||
}
|
||||
}
|
||||
|
||||
/// Send an engine message (4)
|
||||
public func send(msg: String, withData datas: [NSData]?) {
|
||||
if probing {
|
||||
probeWait.append((msg, PacketType.Message, datas))
|
||||
probeWait.append((msg, .Message, datas))
|
||||
} else {
|
||||
write(msg, withType: PacketType.Message, withData: datas)
|
||||
write(msg, withType: .Message, withData: datas)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -559,45 +433,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
}
|
||||
|
||||
++pongsMissed
|
||||
write("", withType: PacketType.Ping, withData: nil)
|
||||
}
|
||||
|
||||
/// Send polling message.
|
||||
/// Only call on emitQueue
|
||||
private func sendPollMessage(var msg: String, withType type: PacketType,
|
||||
datas:[NSData]? = nil) {
|
||||
Logger.log("Sending poll: %@ as type: %@", type: logType, args: msg, type.rawValue)
|
||||
|
||||
doubleEncodeUTF8(&msg)
|
||||
let strMsg = "\(type.rawValue)\(msg)"
|
||||
|
||||
postWait.append(strMsg)
|
||||
|
||||
for data in datas ?? [] {
|
||||
let (_, b64Data) = createBinaryDataForSend(data)
|
||||
|
||||
postWait.append(b64Data!)
|
||||
}
|
||||
|
||||
if !waitingForPost {
|
||||
flushWaitingForPost()
|
||||
}
|
||||
}
|
||||
|
||||
/// Send message on WebSockets
|
||||
/// Only call on emitQueue
|
||||
private func sendWebSocketMessage(str: String, withType type: PacketType,
|
||||
datas:[NSData]? = nil) {
|
||||
Logger.log("Sending ws: %@ as type: %@", type: logType, args: str, type.rawValue)
|
||||
|
||||
ws?.writeString("\(type.rawValue)\(str)")
|
||||
|
||||
for data in datas ?? [] {
|
||||
let (data, _) = createBinaryDataForSend(data)
|
||||
if data != nil {
|
||||
ws?.writeData(data!)
|
||||
}
|
||||
}
|
||||
write("", withType: .Ping, withData: nil)
|
||||
}
|
||||
|
||||
// Starts the ping timer
|
||||
@@ -613,16 +449,12 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
func stopPolling() {
|
||||
session.invalidateAndCancel()
|
||||
}
|
||||
|
||||
private func upgradeTransport() {
|
||||
if websocketConnected {
|
||||
Logger.log("Upgrading transport to WebSockets", type: logType)
|
||||
|
||||
fastUpgrade = true
|
||||
sendPollMessage("", withType: PacketType.Noop)
|
||||
sendPollMessage("", withType: .Noop)
|
||||
// After this point, we should not send anymore polling messages
|
||||
}
|
||||
}
|
||||
@@ -630,7 +462,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
/**
|
||||
Write a message, independent of transport.
|
||||
*/
|
||||
public func write(msg: String, withType type: PacketType, withData data: [NSData]?) {
|
||||
public func write(msg: String, withType type: SocketEnginePacketType, withData data: [NSData]?) {
|
||||
dispatch_async(emitQueue) {
|
||||
if self.connected {
|
||||
if self.websocket {
|
||||
@@ -645,12 +477,220 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Polling methods
|
||||
extension SocketEngine {
|
||||
private func doPoll() {
|
||||
if websocket || waitingForPoll || !connected || closed {
|
||||
return
|
||||
}
|
||||
|
||||
waitingForPoll = true
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&sid=\(sid)&b64=1")!)
|
||||
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
req.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
if extraHeaders != nil {
|
||||
for (headerName, value) in extraHeaders! {
|
||||
req.setValue(value, forHTTPHeaderField: headerName)
|
||||
}
|
||||
}
|
||||
|
||||
doLongPoll(req)
|
||||
}
|
||||
|
||||
private func doRequest(req: NSMutableURLRequest,
|
||||
withCallback callback: (NSData?, NSURLResponse?, NSError?) -> Void) {
|
||||
if !polling || closed || invalidated {
|
||||
return
|
||||
}
|
||||
|
||||
Logger.log("Doing polling request", type: logType)
|
||||
|
||||
req.cachePolicy = .ReloadIgnoringLocalAndRemoteCacheData
|
||||
session.dataTaskWithRequest(req, completionHandler: callback).resume()
|
||||
}
|
||||
|
||||
private func doLongPoll(req: NSMutableURLRequest) {
|
||||
doRequest(req) {[weak self] data, res, err in
|
||||
if let this = self {
|
||||
if err != nil || data == nil {
|
||||
if this.polling {
|
||||
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
||||
} else {
|
||||
Logger.error(err?.localizedDescription ?? "Error", type: this.logType)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
Logger.log("Got polling response", type: this.logType)
|
||||
|
||||
if let str = NSString(data: data!, encoding: NSUTF8StringEncoding) as? String {
|
||||
dispatch_async(this.parseQueue) {[weak this] in
|
||||
this?.parsePollingMessage(str)
|
||||
}
|
||||
}
|
||||
|
||||
this.waitingForPoll = false
|
||||
|
||||
if this.fastUpgrade {
|
||||
this.doFastUpgrade()
|
||||
} else if !this.closed && this.polling {
|
||||
this.doPoll()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func flushWaitingForPost() {
|
||||
if postWait.count == 0 || !connected {
|
||||
return
|
||||
} else if websocket {
|
||||
flushWaitingForPostToWebSocket()
|
||||
return
|
||||
}
|
||||
|
||||
var postStr = ""
|
||||
|
||||
for packet in postWait {
|
||||
let len = packet.characters.count
|
||||
|
||||
postStr += "\(len):\(packet)"
|
||||
}
|
||||
|
||||
postWait.removeAll(keepCapacity: false)
|
||||
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&sid=\(sid)")!)
|
||||
|
||||
if let cookies = cookies {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies)
|
||||
req.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
req.HTTPMethod = "POST"
|
||||
req.setValue("text/plain; charset=UTF-8", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding,
|
||||
allowLossyConversion: false)!
|
||||
|
||||
req.HTTPBody = postData
|
||||
req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length")
|
||||
|
||||
waitingForPost = true
|
||||
|
||||
Logger.log("POSTing: %@", type: logType, args: postStr)
|
||||
|
||||
doRequest(req) {[weak self] data, res, err in
|
||||
if let this = self {
|
||||
if err != nil && this.polling {
|
||||
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
||||
return
|
||||
} else if err != nil {
|
||||
Logger.error(err?.localizedDescription ?? "Error", type: this.logType)
|
||||
return
|
||||
}
|
||||
|
||||
this.waitingForPost = false
|
||||
|
||||
dispatch_async(this.emitQueue) {[weak this] in
|
||||
if !(this?.fastUpgrade ?? true) {
|
||||
this?.flushWaitingForPost()
|
||||
this?.doPoll()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We had packets waiting for send when we upgraded
|
||||
// Send them raw
|
||||
private func flushWaitingForPostToWebSocket() {
|
||||
guard let ws = self.ws else {return}
|
||||
|
||||
for msg in postWait {
|
||||
ws.writeString(msg)
|
||||
}
|
||||
|
||||
postWait.removeAll(keepCapacity: true)
|
||||
}
|
||||
|
||||
func parsePollingMessage(str: String) {
|
||||
guard str.characters.count != 1 else {
|
||||
return
|
||||
}
|
||||
|
||||
var reader = SocketStringReader(message: str)
|
||||
|
||||
while reader.hasNext {
|
||||
if let n = Int(reader.readUntilStringOccurence(":")) {
|
||||
let str = reader.read(n)
|
||||
|
||||
dispatch_async(handleQueue) {
|
||||
self.parseEngineMessage(str, fromPolling: true)
|
||||
}
|
||||
} else {
|
||||
dispatch_async(handleQueue) {
|
||||
self.parseEngineMessage(str, fromPolling: true)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Send polling message.
|
||||
/// Only call on emitQueue
|
||||
private func sendPollMessage(var msg: String, withType type: SocketEnginePacketType,
|
||||
datas:[NSData]? = nil) {
|
||||
Logger.log("Sending poll: %@ as type: %@", type: logType, args: msg, type.rawValue)
|
||||
|
||||
doubleEncodeUTF8(&msg)
|
||||
let strMsg = "\(type.rawValue)\(msg)"
|
||||
|
||||
postWait.append(strMsg)
|
||||
|
||||
for data in datas ?? [] {
|
||||
if case let .Right(bin) = createBinaryDataForSend(data) {
|
||||
postWait.append(bin)
|
||||
}
|
||||
}
|
||||
|
||||
if !waitingForPost {
|
||||
flushWaitingForPost()
|
||||
}
|
||||
}
|
||||
|
||||
private func stopPolling() {
|
||||
invalidated = true
|
||||
session.finishTasksAndInvalidate()
|
||||
}
|
||||
}
|
||||
|
||||
// WebSocket methods
|
||||
extension SocketEngine {
|
||||
/// Send message on WebSockets
|
||||
/// Only call on emitQueue
|
||||
private func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType,
|
||||
datas:[NSData]? = nil) {
|
||||
Logger.log("Sending ws: %@ as type: %@", type: logType, args: str, type.rawValue)
|
||||
|
||||
ws?.writeString("\(type.rawValue)\(str)")
|
||||
|
||||
for data in datas ?? [] {
|
||||
if case let Either.Left(bin) = createBinaryDataForSend(data) {
|
||||
ws?.writeData(bin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delagate methods
|
||||
|
||||
|
||||
public func websocketDidConnect(socket:WebSocket) {
|
||||
websocketConnected = true
|
||||
|
||||
|
||||
if !forceWebsockets {
|
||||
probing = true
|
||||
probeWebSocket()
|
||||
@@ -660,23 +700,23 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
polling = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func websocketDidDisconnect(socket: WebSocket, error: NSError?) {
|
||||
websocketConnected = false
|
||||
probing = false
|
||||
|
||||
|
||||
if closed {
|
||||
client?.engineDidClose("Disconnect")
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if websocket {
|
||||
pingTimer?.invalidate()
|
||||
connected = false
|
||||
websocket = false
|
||||
|
||||
|
||||
let reason = error?.localizedDescription ?? "Socket Disconnected"
|
||||
|
||||
|
||||
if error != nil {
|
||||
client?.didError(reason)
|
||||
}
|
||||
@@ -686,11 +726,11 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
||||
flushProbeWait()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
|
||||
parseEngineMessage(text, fromPolling: false)
|
||||
}
|
||||
|
||||
|
||||
public func websocketDidReceiveData(socket: WebSocket, data: NSData) {
|
||||
parseEngineData(data)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// SocketEnginePacketType.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 10/7/15.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public enum SocketEnginePacketType: Int {
|
||||
case Open, Close, Ping, Pong, Message, Upgrade, Noop
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
//
|
||||
// SocketEngineSpec.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 10/7/15.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public protocol SocketEngineSpec {
|
||||
weak var client: SocketEngineClient? {get set}
|
||||
var cookies: [NSHTTPCookie]? {get}
|
||||
var sid: String {get}
|
||||
var socketPath: String {get}
|
||||
var urlPolling: String {get}
|
||||
var urlWebSocket: String {get}
|
||||
|
||||
init(client: SocketEngineClient, options: NSDictionary?)
|
||||
|
||||
func close()
|
||||
func open(opts: [String: AnyObject]?)
|
||||
func send(msg: String, withData datas: [NSData]?)
|
||||
func write(msg: String, withType type: SocketEnginePacketType, withData data: [NSData]?)
|
||||
}
|
||||
@@ -24,37 +24,23 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
private func emitAckCallback(socket: SocketIOClient?, num: Int?)
|
||||
(items: AnyObject...) -> Void {
|
||||
socket?.emitAck(num ?? -1, withItems: items)
|
||||
}
|
||||
|
||||
private func emitAckCallbackObjectiveC(socket: SocketIOClient?, num: Int?)
|
||||
(items: NSArray) -> Void {
|
||||
socket?.emitAck(num ?? -1, withItems: items as [AnyObject])
|
||||
private func emitAckCallback(socket: SocketIOClient, num: Int?) -> SocketAckEmitter? {
|
||||
return num != nil ? SocketAckEmitter(socket: socket, ackNum: num!) : nil
|
||||
}
|
||||
|
||||
struct SocketEventHandler {
|
||||
let event: String
|
||||
let callback: NormalCallback?
|
||||
let callBackObjectiveC: NormalCallbackObjectiveC?
|
||||
let callback: NormalCallback
|
||||
let id: NSUUID
|
||||
|
||||
init(event: String, callback: NormalCallback) {
|
||||
init(event: String, id: NSUUID = NSUUID(), callback: NormalCallback) {
|
||||
self.event = event
|
||||
self.id = id
|
||||
self.callback = callback
|
||||
self.callBackObjectiveC = nil
|
||||
}
|
||||
|
||||
init(event: String, callback: NormalCallbackObjectiveC) {
|
||||
self.event = event
|
||||
self.callback = nil
|
||||
self.callBackObjectiveC = callback
|
||||
}
|
||||
|
||||
func executeCallback(items:NSArray? = nil, withAck ack:Int? = nil, withAckType type:Int? = nil,
|
||||
withSocket socket:SocketIOClient? = nil) {
|
||||
self.callback != nil ?
|
||||
self.callback?(items, emitAckCallback(socket, num: ack))
|
||||
: self.callBackObjectiveC?(items, emitAckCallbackObjectiveC(socket, num: ack))
|
||||
func executeCallback(items: [AnyObject], withAck ack: Int? = nil, withAckType type: Int? = nil,
|
||||
withSocket socket: SocketIOClient) {
|
||||
self.callback(items, emitAckCallback(socket, num: ack))
|
||||
}
|
||||
}
|
||||
@@ -26,13 +26,15 @@
|
||||
import Foundation
|
||||
|
||||
func fixDoubleUTF8(inout name: String) {
|
||||
let utf8 = name.dataUsingEncoding(NSISOLatin1StringEncoding)!
|
||||
let latin1 = NSString(data: utf8, encoding: NSUTF8StringEncoding)!
|
||||
name = latin1 as String
|
||||
if let utf8 = name.dataUsingEncoding(NSISOLatin1StringEncoding),
|
||||
latin1 = NSString(data: utf8, encoding: NSUTF8StringEncoding) {
|
||||
name = latin1 as String
|
||||
}
|
||||
}
|
||||
|
||||
func doubleEncodeUTF8(inout str: String) {
|
||||
let latin1 = str.dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
let utf8 = NSString(data: latin1, encoding: NSISOLatin1StringEncoding)!
|
||||
str = utf8 as String
|
||||
if let latin1 = str.dataUsingEncoding(NSUTF8StringEncoding),
|
||||
utf8 = NSString(data: latin1, encoding: NSISOLatin1StringEncoding) {
|
||||
str = utf8 as String
|
||||
}
|
||||
}
|
||||
@@ -25,23 +25,21 @@
|
||||
import Foundation
|
||||
|
||||
public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
private let emitQueue = dispatch_queue_create("emitQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let handleQueue: dispatch_queue_t!
|
||||
|
||||
public let socketURL: String
|
||||
|
||||
public private(set) var engine: SocketEngine?
|
||||
public private(set) var engine: SocketEngineSpec?
|
||||
public private(set) var secure = false
|
||||
public private(set) var status = SocketIOClientStatus.NotConnected
|
||||
|
||||
public var nsp = "/"
|
||||
public var opts: [String: AnyObject]?
|
||||
public var options: Set<SocketIOClientOption>?
|
||||
public var reconnects = true
|
||||
public var reconnectWait = 10
|
||||
public var sid: String? {
|
||||
return engine?.sid
|
||||
}
|
||||
|
||||
private let emitQueue = dispatch_queue_create("com.socketio.emitQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let logType = "SocketIOClient"
|
||||
|
||||
private var anyHandler: ((SocketAnyEvent) -> Void)?
|
||||
@@ -49,17 +47,17 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
private var handlers = ContiguousArray<SocketEventHandler>()
|
||||
private var connectParams: [String: AnyObject]?
|
||||
private var reconnectTimer: NSTimer?
|
||||
|
||||
private let reconnectAttempts: Int!
|
||||
private var ackHandlers = SocketAckManager()
|
||||
private var currentAck = -1
|
||||
|
||||
internal var waitingData = [SocketPacket]()
|
||||
|
||||
private(set) var currentAck = -1
|
||||
private(set) var handleQueue = dispatch_get_main_queue()
|
||||
private(set) var reconnectAttempts = -1
|
||||
var waitingData = [SocketPacket]()
|
||||
|
||||
/**
|
||||
Create a new SocketIOClient. opts can be omitted
|
||||
Type safe way to create a new SocketIOClient. opts can be omitted
|
||||
*/
|
||||
public init(var socketURL: String, opts: [String: AnyObject]? = nil) {
|
||||
public init(var socketURL: String, options: Set<SocketIOClientOption>? = nil) {
|
||||
if socketURL["https://"].matches().count != 0 {
|
||||
self.secure = true
|
||||
}
|
||||
@@ -68,56 +66,52 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
socketURL = socketURL["https://"] ~= ""
|
||||
|
||||
self.socketURL = socketURL
|
||||
self.opts = opts
|
||||
self.options = options
|
||||
|
||||
if let connectParams = opts?["connectParams"] as? [String: AnyObject] {
|
||||
self.connectParams = connectParams
|
||||
}
|
||||
|
||||
if let logger = opts?["logger"] as? SocketLogger {
|
||||
Logger = logger
|
||||
}
|
||||
|
||||
if let log = opts?["log"] as? Bool {
|
||||
Logger.log = log
|
||||
}
|
||||
|
||||
if let nsp = opts?["nsp"] as? String {
|
||||
self.nsp = nsp
|
||||
}
|
||||
|
||||
if let reconnects = opts?["reconnects"] as? Bool {
|
||||
self.reconnects = reconnects
|
||||
}
|
||||
|
||||
if let reconnectAttempts = opts?["reconnectAttempts"] as? Int {
|
||||
self.reconnectAttempts = reconnectAttempts
|
||||
} else {
|
||||
self.reconnectAttempts = -1
|
||||
}
|
||||
|
||||
if let reconnectWait = opts?["reconnectWait"] as? Int {
|
||||
self.reconnectWait = abs(reconnectWait)
|
||||
}
|
||||
|
||||
if let handleQueue = opts?["handleQueue"] as? dispatch_queue_t {
|
||||
self.handleQueue = handleQueue
|
||||
} else {
|
||||
self.handleQueue = dispatch_get_main_queue()
|
||||
for option in options ?? [] {
|
||||
switch option {
|
||||
case .ConnectParams(let params):
|
||||
connectParams = params
|
||||
case .Reconnects(let reconnects):
|
||||
self.reconnects = reconnects
|
||||
case .ReconnectAttempts(let attempts):
|
||||
reconnectAttempts = attempts
|
||||
case .ReconnectWait(let wait):
|
||||
reconnectWait = abs(wait)
|
||||
case .Nsp(let nsp):
|
||||
self.nsp = nsp
|
||||
case .Log(let log):
|
||||
Logger.log = log
|
||||
case .Logger(let logger):
|
||||
Logger = logger
|
||||
case .HandleQueue(let queue):
|
||||
handleQueue = queue
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
/**
|
||||
Not so type safe way to create a SocketIOClient, meant for Objective-C compatiblity.
|
||||
If using Swift it's recommended to use `init(var socketURL: String, opts: SocketOptionsDictionary? = nil)`
|
||||
*/
|
||||
public convenience init(socketURL: String, options: NSDictionary?) {
|
||||
self.init(socketURL: socketURL,
|
||||
options: SocketIOClientOption.NSDictionaryToSocketOptionsSet(options ?? [:]))
|
||||
}
|
||||
|
||||
deinit {
|
||||
Logger.log("Client is being deinit", type: logType)
|
||||
engine?.close(fast: true)
|
||||
engine?.close()
|
||||
}
|
||||
|
||||
private func addEngine() -> SocketEngine {
|
||||
Logger.log("Adding engine", type: logType)
|
||||
|
||||
let newEngine = SocketEngine(client: self, opts: opts)
|
||||
let newEngine = SocketEngine(client: self, options: options ?? [])
|
||||
|
||||
engine = newEngine
|
||||
return newEngine
|
||||
@@ -133,12 +127,11 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
Will turn off automatic reconnects.
|
||||
Pass true to fast if you're closing from a background task
|
||||
*/
|
||||
public func close(fast fast: Bool) {
|
||||
public func close() {
|
||||
Logger.log("Closing socket", type: logType)
|
||||
|
||||
reconnects = false
|
||||
status = SocketIOClientStatus.Closed
|
||||
engine?.close(fast: fast)
|
||||
didDisconnect("Closed")
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,8 +144,8 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
/**
|
||||
Connect to the server. If we aren't connected after timeoutAfter, call handler
|
||||
*/
|
||||
public func connect(timeoutAfter timeoutAfter:Int,
|
||||
withTimeoutHandler handler:(() -> Void)?) {
|
||||
public func connect(timeoutAfter timeoutAfter: Int,
|
||||
withTimeoutHandler handler: (() -> Void)?) {
|
||||
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
|
||||
|
||||
guard status != .Connected else {
|
||||
@@ -173,10 +166,10 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
|
||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
|
||||
|
||||
dispatch_after(time, dispatch_get_main_queue()) {
|
||||
if self.status != .Connected {
|
||||
self.status = .Closed
|
||||
self.engine?.close(fast: true)
|
||||
dispatch_after(time, handleQueue) {[weak self] in
|
||||
if let this = self where this.status != .Connected {
|
||||
this.status = .Closed
|
||||
this.engine?.close()
|
||||
|
||||
handler?()
|
||||
}
|
||||
@@ -211,7 +204,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
|
||||
// Don't handle as internal because something crazy could happen where
|
||||
// we disconnect before it's handled
|
||||
handleEvent("connect", data: nil, isInternalMessage: false)
|
||||
handleEvent("connect", data: [], isInternalMessage: false)
|
||||
}
|
||||
|
||||
func didDisconnect(reason: String) {
|
||||
@@ -222,11 +215,10 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
Logger.log("Disconnected: %@", type: logType, args: reason)
|
||||
|
||||
status = .Closed
|
||||
|
||||
reconnects = false
|
||||
|
||||
// Make sure the engine is actually dead.
|
||||
engine?.close(fast: true)
|
||||
engine?.close()
|
||||
handleEvent("disconnect", data: [reason], isInternalMessage: true)
|
||||
}
|
||||
|
||||
@@ -241,8 +233,8 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
/**
|
||||
Same as close
|
||||
*/
|
||||
public func disconnect(fast fast: Bool) {
|
||||
close(fast: fast)
|
||||
public func disconnect() {
|
||||
close()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -330,16 +322,18 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
|
||||
// Called when the socket gets an ack for something it sent
|
||||
func handleAck(ack: Int, data: AnyObject?) {
|
||||
guard status == .Connected else {return}
|
||||
|
||||
Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "")
|
||||
|
||||
ackHandlers.executeAck(ack,
|
||||
items: (data as? [AnyObject]?) ?? (data != nil ? [data!] : nil))
|
||||
items: (data as? [AnyObject]) ?? (data != nil ? [data!] : []))
|
||||
}
|
||||
|
||||
/**
|
||||
Causes an event to be handled. Only use if you know what you're doing.
|
||||
*/
|
||||
public func handleEvent(event: String, data: [AnyObject]?, isInternalMessage: Bool,
|
||||
public func handleEvent(event: String, data: [AnyObject], isInternalMessage: Bool,
|
||||
wantsAck ack: Int? = nil) {
|
||||
guard status == .Connected || isInternalMessage else {
|
||||
return
|
||||
@@ -360,7 +354,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
}
|
||||
} else {
|
||||
dispatch_async(handleQueue) {
|
||||
handler.executeCallback(data)
|
||||
handler.executeCallback(data, withAck: ack, withSocket: self)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -415,12 +409,19 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
}
|
||||
|
||||
/**
|
||||
Adds a handler for an event.
|
||||
Adds a single-use handler for an event.
|
||||
*/
|
||||
public func onObjectiveC(event: String, callback: NormalCallbackObjectiveC) {
|
||||
Logger.log("Adding handler for event: %@", type: logType, args: event)
|
||||
public func once(event: String, callback: NormalCallback) {
|
||||
Logger.log("Adding once handler for event: %@", type: logType, args: event)
|
||||
|
||||
let handler = SocketEventHandler(event: event, callback: callback)
|
||||
let id = NSUUID()
|
||||
|
||||
let handler = SocketEventHandler(event: event, id: id) {[weak self] data, ack in
|
||||
guard let this = self else {return}
|
||||
this.handlers = ContiguousArray(this.handlers.filter {$0.id != id})
|
||||
callback(data, ack)
|
||||
}
|
||||
|
||||
handlers.append(handler)
|
||||
}
|
||||
|
||||
@@ -462,7 +463,6 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
Tries to reconnect to the server.
|
||||
*/
|
||||
public func reconnect() {
|
||||
engine?.stopPolling()
|
||||
tryReconnect()
|
||||
}
|
||||
|
||||
@@ -486,7 +486,6 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if reconnectAttempts != -1 && currentReconnectAttempt + 1 > reconnectAttempts || !reconnects {
|
||||
clearReconnectTimer()
|
||||
didDisconnect("Reconnect Failed")
|
||||
@@ -502,3 +501,18 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
connect()
|
||||
}
|
||||
}
|
||||
|
||||
// Test extensions
|
||||
extension SocketIOClient {
|
||||
func setTestable() {
|
||||
status = .Connected
|
||||
}
|
||||
|
||||
func setTestEngine(engine: SocketEngineSpec?) {
|
||||
self.engine = engine
|
||||
}
|
||||
|
||||
func emitTest(event: String, _ data: AnyObject...) {
|
||||
self._emit([event] + data)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// SocketIOClientOption .swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 10/17/15.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
public enum SocketIOClientOption: CustomStringConvertible, Hashable {
|
||||
case ConnectParams([String: AnyObject])
|
||||
case Reconnects(Bool)
|
||||
case ReconnectAttempts(Int)
|
||||
case ReconnectWait(Int)
|
||||
case ForcePolling(Bool)
|
||||
case ForceWebsockets(Bool)
|
||||
case Nsp(String)
|
||||
case Cookies([NSHTTPCookie])
|
||||
case Log(Bool)
|
||||
case Logger(SocketLogger)
|
||||
case SessionDelegate(NSURLSessionDelegate)
|
||||
case Path(String)
|
||||
case ExtraHeaders([String: String])
|
||||
case HandleQueue(dispatch_queue_t)
|
||||
case VoipEnabled(Bool)
|
||||
|
||||
public var description: String {
|
||||
if let label = Mirror(reflecting: self).children.first?.label {
|
||||
return String(label[label.startIndex]).lowercaseString + String(label.characters.dropFirst())
|
||||
} else {
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
public var hashValue: Int {
|
||||
return description.hashValue
|
||||
}
|
||||
|
||||
static func keyValueToSocketIOClientOption(key: String, value: AnyObject) -> SocketIOClientOption? {
|
||||
switch key {
|
||||
case "connectParams" where value is [String: AnyObject]:
|
||||
return .ConnectParams(value as! [String: AnyObject])
|
||||
case "reconnects" where value is Bool:
|
||||
return .Reconnects(value as! Bool)
|
||||
case "reconnectAttempts" where value is Int:
|
||||
return .ReconnectAttempts(value as! Int)
|
||||
case "reconnectWait" where value is Int:
|
||||
return .ReconnectWait(value as! Int)
|
||||
case "forcePolling" where value is Bool:
|
||||
return .ForcePolling(value as! Bool)
|
||||
case "forceWebsockets" where value is Bool:
|
||||
return .ForceWebsockets(value as! Bool)
|
||||
case "nsp" where value is String:
|
||||
return .Nsp(value as! String)
|
||||
case "cookies" where value is [NSHTTPCookie]:
|
||||
return .Cookies(value as! [NSHTTPCookie])
|
||||
case "log" where value is Bool:
|
||||
return .Log(value as! Bool)
|
||||
case "logger" where value is SocketLogger:
|
||||
return .Logger(value as! SocketLogger)
|
||||
case "sessionDelegate" where value is NSURLSessionDelegate:
|
||||
return .SessionDelegate(value as! NSURLSessionDelegate)
|
||||
case "path" where value is String:
|
||||
return .Path(value as! String)
|
||||
case "extraHeaders" where value is [String: String]:
|
||||
return .ExtraHeaders(value as! [String: String])
|
||||
case "handleQueue" where value is dispatch_queue_t:
|
||||
return .HandleQueue(value as! dispatch_queue_t)
|
||||
case "voipEnabled" where value is Bool:
|
||||
return .VoipEnabled(value as! Bool)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func getSocketIOOptionValue() -> AnyObject? {
|
||||
return Mirror(reflecting: self).children.first?.value as? AnyObject
|
||||
}
|
||||
|
||||
static func NSDictionaryToSocketOptionsSet(dict: NSDictionary) -> Set<SocketIOClientOption> {
|
||||
var options = Set<SocketIOClientOption>()
|
||||
|
||||
for (rawKey, value) in dict {
|
||||
if let key = rawKey as? String, opt = keyValueToSocketIOClientOption(key, value: value) {
|
||||
options.insert(opt)
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
static func SocketOptionsSetToNSDictionary(set: Set<SocketIOClientOption>) -> NSDictionary {
|
||||
let options = NSMutableDictionary()
|
||||
|
||||
for option in set {
|
||||
options[option.description] = option.getSocketIOOptionValue()
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
}
|
||||
|
||||
public func ==(lhs: SocketIOClientOption, rhs: SocketIOClientOption) -> Bool {
|
||||
return lhs.description == rhs.description
|
||||
}
|
||||
@@ -25,6 +25,8 @@
|
||||
import Foundation
|
||||
|
||||
@objc public enum SocketIOClientStatus: Int, CustomStringConvertible {
|
||||
case NotConnected, Closed, Connecting, Connected, Reconnecting
|
||||
|
||||
public var description: String {
|
||||
switch self {
|
||||
case NotConnected:
|
||||
@@ -39,6 +41,4 @@ import Foundation
|
||||
return "Reconnecting"
|
||||
}
|
||||
}
|
||||
|
||||
case NotConnected, Closed, Connecting, Connected, Reconnecting
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import Foundation
|
||||
|
||||
var Logger: SocketLogger = DefaultSocketLogger()
|
||||
|
||||
public protocol SocketLogger {
|
||||
public protocol SocketLogger: class {
|
||||
/// Whether to log or not
|
||||
var log: Bool {get set}
|
||||
|
||||
@@ -56,6 +56,6 @@ public extension SocketLogger {
|
||||
}
|
||||
}
|
||||
|
||||
struct DefaultSocketLogger: SocketLogger {
|
||||
class DefaultSocketLogger: SocketLogger {
|
||||
var log = false
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
@@ -36,14 +37,6 @@ struct SocketPacket {
|
||||
|
||||
enum PacketType: Int {
|
||||
case Connect, Disconnect, Event, Ack, Error, BinaryEvent, BinaryAck
|
||||
|
||||
init?(str: String) {
|
||||
if let int = Int(str), raw = PacketType(rawValue: int) {
|
||||
self = raw
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var args: [AnyObject]? {
|
||||
@@ -116,7 +109,7 @@ struct SocketPacket {
|
||||
|
||||
message += jsonString! as String + ","
|
||||
} catch {
|
||||
Logger.error("Error creating JSON object in SocketPacket.completeMessage", type: SocketPacket.logType)
|
||||
Logger.error("Error creating JSON object in SocketPacket.completeMessage", type: SocketPacket.logType)
|
||||
}
|
||||
} else if var str = arg as? String {
|
||||
str = str["\n"] ~= "\\\\n"
|
||||
@@ -150,7 +143,7 @@ struct SocketPacket {
|
||||
if nsp == "/" {
|
||||
msg = "6\(binary.count)-\(id)["
|
||||
} else {
|
||||
msg = "6\(binary.count)-/\(nsp),\(id)["
|
||||
msg = "6\(binary.count)-\(nsp),\(id)["
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,6 +202,7 @@ struct SocketPacket {
|
||||
mutating func fillInPlaceholders() {
|
||||
for i in 0..<data.count {
|
||||
if let str = data[i] as? String, num = str["~~(\\d)"].groups() {
|
||||
// Fill in binary placeholder with data
|
||||
data[i] = binary[Int(num[1])!]
|
||||
} else if data[i] is NSDictionary || data[i] is NSArray {
|
||||
data[i] = _fillInPlaceholders(data[i])
|
||||
|
||||
@@ -27,26 +27,7 @@ class SocketParser {
|
||||
private static func isCorrectNamespace(nsp: String, _ socket: SocketIOClient) -> Bool {
|
||||
return nsp == socket.nsp
|
||||
}
|
||||
|
||||
private static func handleEvent(p: SocketPacket, socket: SocketIOClient) {
|
||||
guard isCorrectNamespace(p.nsp, socket) else { return }
|
||||
|
||||
socket.handleEvent(p.event, data: p.args,
|
||||
isInternalMessage: false, wantsAck: p.id)
|
||||
}
|
||||
|
||||
private static func handleAck(p: SocketPacket, socket: SocketIOClient) {
|
||||
guard isCorrectNamespace(p.nsp, socket) else { return }
|
||||
|
||||
socket.handleAck(p.id, data: p.data)
|
||||
}
|
||||
|
||||
private static func handleBinary(p: SocketPacket, socket: SocketIOClient) {
|
||||
guard isCorrectNamespace(p.nsp, socket) else { return }
|
||||
|
||||
socket.waitingData.append(p)
|
||||
}
|
||||
|
||||
|
||||
private static func handleConnect(p: SocketPacket, socket: SocketIOClient) {
|
||||
if p.nsp == "/" && socket.nsp != "/" {
|
||||
socket.joinNamespace()
|
||||
@@ -57,14 +38,37 @@ class SocketParser {
|
||||
}
|
||||
}
|
||||
|
||||
static func parseString(message: String) -> SocketPacket? {
|
||||
private static func handlePacket(pack: SocketPacket, withSocket socket: SocketIOClient) {
|
||||
switch pack.type {
|
||||
case .Event where isCorrectNamespace(pack.nsp, socket):
|
||||
socket.handleEvent(pack.event, data: pack.args ?? [],
|
||||
isInternalMessage: false, wantsAck: pack.id)
|
||||
case .Ack where isCorrectNamespace(pack.nsp, socket):
|
||||
socket.handleAck(pack.id, data: pack.data)
|
||||
case .BinaryEvent where isCorrectNamespace(pack.nsp, socket):
|
||||
socket.waitingData.append(pack)
|
||||
case .BinaryAck where isCorrectNamespace(pack.nsp, socket):
|
||||
socket.waitingData.append(pack)
|
||||
case .Connect:
|
||||
handleConnect(pack, socket: socket)
|
||||
case .Disconnect:
|
||||
socket.didDisconnect("Got Disconnect")
|
||||
case .Error:
|
||||
socket.didError(pack.data)
|
||||
default:
|
||||
Logger.log("Got invalid packet: %@", type: "SocketParser", args: pack.description)
|
||||
}
|
||||
}
|
||||
|
||||
static func parseString(message: String) -> Either<String, SocketPacket> {
|
||||
var parser = SocketStringReader(message: message)
|
||||
|
||||
guard let type = SocketPacket.PacketType(str: parser.read(1))
|
||||
else {return nil}
|
||||
guard let type = SocketPacket.PacketType(rawValue: Int(parser.read(1)) ?? -1) else {
|
||||
return .Left("Invalid packet type")
|
||||
}
|
||||
|
||||
if !parser.hasNext {
|
||||
return SocketPacket(type: type, nsp: "/")
|
||||
return .Right(SocketPacket(type: type, nsp: "/"))
|
||||
}
|
||||
|
||||
var namespace: String?
|
||||
@@ -74,7 +78,7 @@ class SocketParser {
|
||||
if let holders = Int(parser.readUntilStringOccurence("-")) {
|
||||
placeholders = holders
|
||||
} else {
|
||||
return nil
|
||||
return .Left("Invalid packet")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,13 +87,17 @@ class SocketParser {
|
||||
}
|
||||
|
||||
if !parser.hasNext {
|
||||
return SocketPacket(type: type, id: -1,
|
||||
nsp: namespace ?? "/", placeholders: placeholders)
|
||||
return .Right(SocketPacket(type: type, id: -1,
|
||||
nsp: namespace ?? "/", placeholders: placeholders))
|
||||
}
|
||||
|
||||
var idString = ""
|
||||
|
||||
while parser.hasNext {
|
||||
if type == .Error {
|
||||
parser.advanceIndexBy(-1)
|
||||
}
|
||||
|
||||
while parser.hasNext && type != .Error {
|
||||
if let int = Int(parser.read(1)) {
|
||||
idString += String(int)
|
||||
} else {
|
||||
@@ -100,21 +108,34 @@ class SocketParser {
|
||||
|
||||
let d = message[parser.currentIndex.advancedBy(1)..<message.endIndex]
|
||||
let noPlaceholders = d["(\\{\"_placeholder\":true,\"num\":(\\d*)\\})"] ~= "\"~~$2\""
|
||||
let data = parseData(noPlaceholders) as? [AnyObject] ?? [noPlaceholders]
|
||||
|
||||
return SocketPacket(type: type, data: data, id: Int(idString) ?? -1,
|
||||
nsp: namespace ?? "/", placeholders: placeholders)
|
||||
switch parseData(noPlaceholders) {
|
||||
case .Left(let err):
|
||||
// If first you don't succeed, try again
|
||||
if case let .Right(data) = parseData("\([noPlaceholders as AnyObject])") {
|
||||
return .Right(SocketPacket(type: type, data: data, id: Int(idString) ?? -1,
|
||||
nsp: namespace ?? "/", placeholders: placeholders))
|
||||
} else {
|
||||
return .Left(err)
|
||||
}
|
||||
case .Right(let data):
|
||||
return .Right(SocketPacket(type: type, data: data, id: Int(idString) ?? -1,
|
||||
nsp: namespace ?? "/", placeholders: placeholders))
|
||||
}
|
||||
}
|
||||
|
||||
// Parses data for events
|
||||
static func parseData(data: String) -> AnyObject? {
|
||||
private static func parseData(data: String) -> Either<String, [AnyObject]> {
|
||||
let stringData = data.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
|
||||
do {
|
||||
return try NSJSONSerialization.JSONObjectWithData(stringData!,
|
||||
options: NSJSONReadingOptions.MutableContainers)
|
||||
if let arr = try NSJSONSerialization.JSONObjectWithData(stringData!,
|
||||
options: NSJSONReadingOptions.MutableContainers) as? [AnyObject] {
|
||||
return .Right(arr)
|
||||
} else {
|
||||
return .Left("Expected data array")
|
||||
}
|
||||
} catch {
|
||||
Logger.error("Parsing JSON: %@", type: "SocketParser", args: data)
|
||||
return nil
|
||||
return .Left("Error parsing data for packet")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,30 +145,13 @@ class SocketParser {
|
||||
|
||||
Logger.log("Parsing %@", type: "SocketParser", args: message)
|
||||
|
||||
guard let pack = parseString(message) else {
|
||||
Logger.error("Parsing message: %@", type: "SocketParser", args: message)
|
||||
return
|
||||
switch parseString(message) {
|
||||
case .Left(let err):
|
||||
Logger.error("\(err): %@", type: "SocketParser", args: message)
|
||||
case .Right(let pack):
|
||||
Logger.log("Decoded packet as: %@", type: "SocketParser", args: pack.description)
|
||||
handlePacket(pack, withSocket: socket)
|
||||
}
|
||||
|
||||
Logger.log("Decoded packet as: %@", type: "SocketParser", args: pack.description)
|
||||
|
||||
switch pack.type {
|
||||
case .Event:
|
||||
handleEvent(pack, socket: socket)
|
||||
case .Ack:
|
||||
handleAck(pack, socket: socket)
|
||||
case .BinaryEvent:
|
||||
handleBinary(pack, socket: socket)
|
||||
case .BinaryAck:
|
||||
handleBinary(pack, socket: socket)
|
||||
case .Connect:
|
||||
handleConnect(pack, socket: socket)
|
||||
case .Disconnect:
|
||||
socket.didDisconnect("Got Disconnect")
|
||||
case .Error:
|
||||
socket.didError("Error: \(pack.data)")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static func parseBinaryData(data: NSData, socket: SocketIOClient) {
|
||||
@@ -156,14 +160,16 @@ class SocketParser {
|
||||
return
|
||||
}
|
||||
|
||||
let shouldExecute = socket.waitingData[0].addData(data)
|
||||
guard shouldExecute else { return }
|
||||
// Should execute event?
|
||||
guard socket.waitingData[socket.waitingData.count - 1].addData(data) else {
|
||||
return
|
||||
}
|
||||
|
||||
var packet = socket.waitingData.removeAtIndex(0)
|
||||
var packet = socket.waitingData.removeLast()
|
||||
packet.fillInPlaceholders()
|
||||
|
||||
if packet.type != .BinaryAck {
|
||||
socket.handleEvent(packet.event, data: packet.args,
|
||||
socket.handleEvent(packet.event, data: packet.args ?? [],
|
||||
isInternalMessage: false, wantsAck: packet.id)
|
||||
} else {
|
||||
socket.handleAck(packet.id, data: packet.args)
|
||||
|
||||
@@ -24,10 +24,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public typealias AckCallback = (NSArray?) -> Void
|
||||
public typealias AckEmitter = (AnyObject...) -> Void
|
||||
public typealias AckEmitterObjectiveC = (NSArray) -> Void
|
||||
public typealias NormalCallback = (NSArray?, AckEmitter?) -> Void
|
||||
public typealias NormalCallbackObjectiveC = (NSArray?, AckEmitterObjectiveC?) -> Void
|
||||
public typealias OnAckCallback = (timeoutAfter:UInt64, callback:AckCallback) -> Void
|
||||
public typealias AckCallback = ([AnyObject]) -> Void
|
||||
public typealias NormalCallback = ([AnyObject], SocketAckEmitter?) -> Void
|
||||
public typealias OnAckCallback = (timeoutAfter: UInt64, callback: AckCallback) -> Void
|
||||
|
||||
enum Either<E, V> {
|
||||
case Left(E)
|
||||
case Right(V)
|
||||
}
|
||||
@@ -29,8 +29,8 @@ internal class SwiftRegex: NSObject, BooleanType {
|
||||
NSRegularExpressionOptions.DotMatchesLineSeparators)
|
||||
swiftRegexCache[pattern] = regex
|
||||
self.regex = regex
|
||||
} catch let error1 as NSError {
|
||||
SwiftRegex.failure("Error in pattern: \(pattern) - \(error1)")
|
||||
} catch let error as NSError {
|
||||
SwiftRegex.failure("Error in pattern: \(pattern) - \(error)")
|
||||
self.regex = NSRegularExpression()
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ internal class SwiftRegex: NSObject, BooleanType {
|
||||
}
|
||||
|
||||
private final func substring(range: NSRange) -> String? {
|
||||
if ( range.location != NSNotFound ) {
|
||||
if range.location != NSNotFound {
|
||||
return (target as NSString).substringWithRange(range)
|
||||
} else {
|
||||
return nil
|
||||
@@ -70,20 +70,19 @@ internal class SwiftRegex: NSObject, BooleanType {
|
||||
NSMatchingOptions.WithoutAnchoringBounds, range: targetRange))
|
||||
}
|
||||
|
||||
private func groupsForMatch(match: NSTextCheckingResult!) -> [String]? {
|
||||
if match != nil {
|
||||
var groups = [String]()
|
||||
for groupno in 0...regex.numberOfCaptureGroups {
|
||||
if let group = substring(match.rangeAtIndex(groupno)) {
|
||||
groups += [group]
|
||||
} else {
|
||||
groups += ["_"] // avoids bridging problems
|
||||
}
|
||||
}
|
||||
return groups
|
||||
} else {
|
||||
private func groupsForMatch(match: NSTextCheckingResult?) -> [String]? {
|
||||
guard let match = match else {
|
||||
return nil
|
||||
}
|
||||
var groups = [String]()
|
||||
for groupno in 0...regex.numberOfCaptureGroups {
|
||||
if let group = substring(match.rangeAtIndex(groupno)) {
|
||||
groups += [group]
|
||||
} else {
|
||||
groups += ["_"] // avoids bridging problems
|
||||
}
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
subscript(groupno: Int) -> String? {
|
||||
@@ -124,7 +123,7 @@ internal class SwiftRegex: NSObject, BooleanType {
|
||||
}
|
||||
|
||||
func allGroups() -> [[String]?] {
|
||||
return matchResults().map {self.groupsForMatch($0)}
|
||||
return matchResults().map { self.groupsForMatch($0) }
|
||||
}
|
||||
|
||||
func dictionary(options: NSMatchingOptions!) -> Dictionary<String,String> {
|
||||
|
||||
+165
-192
@@ -8,6 +8,7 @@
|
||||
|
||||
import Foundation
|
||||
import CoreFoundation
|
||||
import Security
|
||||
|
||||
public protocol WebSocketDelegate: class {
|
||||
func websocketDidConnect(socket: WebSocket)
|
||||
@@ -93,19 +94,18 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
public var headers = Dictionary<String,String>()
|
||||
public var voipEnabled = false
|
||||
public var selfSignedSSL = false
|
||||
private var security: Security?
|
||||
private var security: SSLSecurity?
|
||||
public var enabledSSLCipherSuites: [SSLCipherSuite]?
|
||||
public var isConnected :Bool {
|
||||
return connected
|
||||
}
|
||||
|
||||
private var cookies:[NSHTTPCookie]?
|
||||
private var url: NSURL
|
||||
private var inputStream: NSInputStream?
|
||||
private var outputStream: NSOutputStream?
|
||||
private var isRunLoop = false
|
||||
private var connected = false
|
||||
private var isCreated = false
|
||||
private var writeQueue: NSOperationQueue?
|
||||
private var writeQueue = NSOperationQueue()
|
||||
private var readStack = Array<WSResponse>()
|
||||
private var inputQueue = Array<NSData>()
|
||||
private var fragBuffer: NSData?
|
||||
@@ -115,13 +115,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
//init the websocket with a url
|
||||
public init(url: NSURL) {
|
||||
self.url = url
|
||||
writeQueue.maxConcurrentOperationCount = 1
|
||||
}
|
||||
|
||||
public convenience init(url: NSURL, cookies:[NSHTTPCookie]?) {
|
||||
self.init(url: url)
|
||||
self.cookies = cookies
|
||||
}
|
||||
|
||||
//used for setting protocols.
|
||||
public convenience init(url: NSURL, protocols: Array<String>) {
|
||||
self.init(url: url)
|
||||
@@ -133,23 +128,14 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
if isCreated {
|
||||
return
|
||||
}
|
||||
|
||||
dispatch_async(queue, { [weak self] in
|
||||
guard let weakSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
weakSelf.didDisconnect = false
|
||||
})
|
||||
dispatch_async(queue,{ [weak self] in
|
||||
self?.didDisconnect = false
|
||||
})
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), { [weak self] in
|
||||
guard let weakSelf = self else {
|
||||
return
|
||||
}
|
||||
|
||||
weakSelf.isCreated = true
|
||||
weakSelf.createHTTPRequest()
|
||||
weakSelf.isCreated = false
|
||||
})
|
||||
self?.isCreated = true
|
||||
self?.createHTTPRequest()
|
||||
self?.isCreated = false
|
||||
})
|
||||
}
|
||||
|
||||
///disconnect from the websocket server
|
||||
@@ -188,30 +174,22 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
port = 80
|
||||
}
|
||||
}
|
||||
|
||||
if self.cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(self.cookies!)
|
||||
for (key, value) in headers {
|
||||
self.addHeader(urlRequest, key: key as String, val: value as String)
|
||||
}
|
||||
}
|
||||
|
||||
self.addHeader(urlRequest, key: headerWSUpgradeName, val: headerWSUpgradeValue)
|
||||
self.addHeader(urlRequest, key: headerWSConnectionName, val: headerWSConnectionValue)
|
||||
addHeader(urlRequest, key: headerWSUpgradeName, val: headerWSUpgradeValue)
|
||||
addHeader(urlRequest, key: headerWSConnectionName, val: headerWSConnectionValue)
|
||||
if let protocols = optionalProtocols {
|
||||
self.addHeader(urlRequest, key: headerWSProtocolName, val: protocols.joinWithSeparator(","))
|
||||
addHeader(urlRequest, key: headerWSProtocolName, val: protocols.joinWithSeparator(","))
|
||||
}
|
||||
self.addHeader(urlRequest, key: headerWSVersionName, val: headerWSVersionValue)
|
||||
self.addHeader(urlRequest, key: headerWSKeyName, val: self.generateWebSocketKey())
|
||||
self.addHeader(urlRequest, key: headerOriginName, val: url.absoluteString)
|
||||
self.addHeader(urlRequest, key: headerWSHostName, val: "\(url.host!):\(port!)")
|
||||
addHeader(urlRequest, key: headerWSVersionName, val: headerWSVersionValue)
|
||||
addHeader(urlRequest, key: headerWSKeyName, val: generateWebSocketKey())
|
||||
addHeader(urlRequest, key: headerOriginName, val: url.absoluteString)
|
||||
addHeader(urlRequest, key: headerWSHostName, val: "\(url.host!):\(port!)")
|
||||
for (key,value) in headers {
|
||||
self.addHeader(urlRequest, key: key, val: value)
|
||||
addHeader(urlRequest, key: key, val: value)
|
||||
}
|
||||
if let cfHTTPMessage = CFHTTPMessageCopySerializedMessage(urlRequest) {
|
||||
let serializedRequest = cfHTTPMessage.takeRetainedValue()
|
||||
initStreamsWithData(serializedRequest, Int(port!))
|
||||
}
|
||||
|
||||
|
||||
let serializedRequest: NSData = CFHTTPMessageCopySerializedMessage(urlRequest)!.takeRetainedValue()
|
||||
self.initStreamsWithData(serializedRequest, Int(port!))
|
||||
}
|
||||
//Add a header to the CFHTTPMessage by using the NSString bridges to CFString
|
||||
private func addHeader(urlRequest: CFHTTPMessage,key: String, val: String) {
|
||||
@@ -244,31 +222,48 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
CFStreamCreatePairWithSocketToHost(nil, h, UInt32(port), &readStream, &writeStream)
|
||||
inputStream = readStream!.takeRetainedValue()
|
||||
outputStream = writeStream!.takeRetainedValue()
|
||||
|
||||
inputStream!.delegate = self
|
||||
outputStream!.delegate = self
|
||||
guard let inStream = inputStream, let outStream = outputStream else { return }
|
||||
inStream.delegate = self
|
||||
outStream.delegate = self
|
||||
if url.scheme == "wss" || url.scheme == "https" {
|
||||
inputStream!.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
|
||||
outputStream!.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
|
||||
inStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
|
||||
outStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
|
||||
} else {
|
||||
certValidated = true //not a https session, so no need to check SSL pinning
|
||||
}
|
||||
if self.voipEnabled {
|
||||
inputStream!.setProperty(NSStreamNetworkServiceTypeVoIP, forKey: NSStreamNetworkServiceType)
|
||||
outputStream!.setProperty(NSStreamNetworkServiceTypeVoIP, forKey: NSStreamNetworkServiceType)
|
||||
if voipEnabled {
|
||||
inStream.setProperty(NSStreamNetworkServiceTypeVoIP, forKey: NSStreamNetworkServiceType)
|
||||
outStream.setProperty(NSStreamNetworkServiceTypeVoIP, forKey: NSStreamNetworkServiceType)
|
||||
}
|
||||
if self.selfSignedSSL {
|
||||
if selfSignedSSL {
|
||||
let settings: Dictionary<NSObject, NSObject> = [kCFStreamSSLValidatesCertificateChain: NSNumber(bool:false), kCFStreamSSLPeerName: kCFNull]
|
||||
inputStream!.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String)
|
||||
outputStream!.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String)
|
||||
inStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String)
|
||||
outStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String)
|
||||
}
|
||||
if let cipherSuites = self.enabledSSLCipherSuites {
|
||||
if let sslContextIn = CFReadStreamCopyProperty(inputStream, kCFStreamPropertySSLContext) as! SSLContextRef?,
|
||||
sslContextOut = CFWriteStreamCopyProperty(outputStream, kCFStreamPropertySSLContext) as! SSLContextRef? {
|
||||
let resIn = SSLSetEnabledCiphers(sslContextIn, cipherSuites, cipherSuites.count)
|
||||
let resOut = SSLSetEnabledCiphers(sslContextOut, cipherSuites, cipherSuites.count)
|
||||
if (resIn != errSecSuccess) {
|
||||
let error = self.errorWithDetail("Error setting ingoing cypher suites", code: UInt16(resIn))
|
||||
disconnectStream(error)
|
||||
return
|
||||
}
|
||||
if (resOut != errSecSuccess) {
|
||||
let error = self.errorWithDetail("Error setting outgoing cypher suites", code: UInt16(resOut))
|
||||
disconnectStream(error)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
isRunLoop = true
|
||||
inputStream!.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
outputStream!.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
inputStream!.open()
|
||||
outputStream!.open()
|
||||
inStream.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
outStream.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
inStream.open()
|
||||
outStream.open()
|
||||
let bytes = UnsafePointer<UInt8>(data.bytes)
|
||||
outputStream!.write(bytes, maxLength: data.length)
|
||||
outStream.write(bytes, maxLength: data.length)
|
||||
while(isRunLoop) {
|
||||
NSRunLoop.currentRunLoop().runMode(NSDefaultRunLoopMode, beforeDate: NSDate.distantFuture() as NSDate)
|
||||
}
|
||||
@@ -283,8 +278,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
if sec.isValid(trust as! SecTrustRef, domain: domain as! String?) {
|
||||
certValidated = true
|
||||
} else {
|
||||
let error = self.errorWithDetail("Invalid SSL certificate", code: 1)
|
||||
doDisconnect(error)
|
||||
let error = errorWithDetail("Invalid SSL certificate", code: 1)
|
||||
disconnectStream(error)
|
||||
return
|
||||
}
|
||||
@@ -302,9 +296,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
//disconnect the stream object
|
||||
private func disconnectStream(error: NSError?) {
|
||||
if writeQueue != nil {
|
||||
writeQueue!.waitUntilAllOperationsAreFinished()
|
||||
}
|
||||
writeQueue.waitUntilAllOperationsAreFinished()
|
||||
if let stream = inputStream {
|
||||
stream.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
stream.close()
|
||||
@@ -316,7 +308,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
outputStream = nil
|
||||
isRunLoop = false
|
||||
certValidated = false
|
||||
self.doDisconnect(error)
|
||||
doDisconnect(error)
|
||||
connected = false
|
||||
}
|
||||
|
||||
@@ -327,9 +319,12 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
let length = inputStream!.read(buffer, maxLength: BUFFER_MAX)
|
||||
if length > 0 {
|
||||
if !connected {
|
||||
let status = processHTTP(buffer, bufferLen: length)
|
||||
if !status {
|
||||
self.doDisconnect(self.errorWithDetail("Invalid HTTP upgrade", code: 1))
|
||||
connected = processHTTP(buffer, bufferLen: length)
|
||||
if !connected {
|
||||
let response = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, false).takeRetainedValue()
|
||||
CFHTTPMessageAppendBytes(response, buffer, length)
|
||||
let code = CFHTTPMessageGetResponseStatusCode(response)
|
||||
doDisconnect(errorWithDetail("Invalid HTTP upgrade", code: UInt16(code)))
|
||||
}
|
||||
} else {
|
||||
var process = false
|
||||
@@ -348,7 +343,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
if inputQueue.count > 0 {
|
||||
let data = inputQueue[0]
|
||||
var work = data
|
||||
if (fragBuffer != nil) {
|
||||
if fragBuffer != nil {
|
||||
let combine = NSMutableData(data: fragBuffer!)
|
||||
combine.appendData(data)
|
||||
work = combine
|
||||
@@ -378,17 +373,17 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
if totalSize > 0 {
|
||||
if validateResponse(buffer, bufferLen: totalSize) {
|
||||
dispatch_async(queue, {
|
||||
self.connected = true
|
||||
if let connectBlock = self.onConnect {
|
||||
dispatch_async(queue,{ [weak self] in
|
||||
guard let s = self else { return }
|
||||
if let connectBlock = s.onConnect {
|
||||
connectBlock()
|
||||
}
|
||||
self.delegate?.websocketDidConnect(self)
|
||||
})
|
||||
s.delegate?.websocketDidConnect(s)
|
||||
})
|
||||
totalSize += 1 //skip the last \n
|
||||
let restSize = bufferLen - totalSize
|
||||
if restSize > 0 {
|
||||
processRawMessage((buffer+totalSize), bufferLen: restSize)
|
||||
processRawMessage((buffer+totalSize),bufferLen: restSize)
|
||||
}
|
||||
return true
|
||||
}
|
||||
@@ -403,11 +398,12 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
if CFHTTPMessageGetResponseStatusCode(response) != 101 {
|
||||
return false
|
||||
}
|
||||
let cfHeaders = CFHTTPMessageCopyAllHeaderFields(response)
|
||||
let headers:NSDictionary? = cfHeaders?.takeRetainedValue()
|
||||
let acceptKey = headers?[headerWSAcceptName] as! NSString
|
||||
if acceptKey.length > 0 {
|
||||
return true
|
||||
if let cfHeaders = CFHTTPMessageCopyAllHeaderFields(response) {
|
||||
let headers = cfHeaders.takeRetainedValue() as NSDictionary
|
||||
let acceptKey = headers[headerWSAcceptName] as! NSString
|
||||
if acceptKey.length > 0 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -443,8 +439,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
var offset = 2
|
||||
if((isMasked > 0 || (RSVMask & buffer[0]) > 0) && receivedOpcode != OpCode.Pong.rawValue) {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("masked and rsv data is not currently supported", code: errCode)
|
||||
self.doDisconnect(error)
|
||||
doDisconnect(errorWithDetail("masked and rsv data is not currently supported", code: errCode))
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -452,15 +447,13 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
if !isControlFrame && (receivedOpcode != OpCode.BinaryFrame.rawValue && receivedOpcode != OpCode.ContinueFrame.rawValue &&
|
||||
receivedOpcode != OpCode.TextFrame.rawValue && receivedOpcode != OpCode.Pong.rawValue) {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("unknown opcode: \(receivedOpcode)", code: errCode)
|
||||
self.doDisconnect(error)
|
||||
doDisconnect(errorWithDetail("unknown opcode: \(receivedOpcode)", code: errCode))
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
if isControlFrame && isFin == 0 {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("control frames can't be fragmented", code: errCode)
|
||||
self.doDisconnect(error)
|
||||
doDisconnect(errorWithDetail("control frames can't be fragmented", code: errCode))
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -486,8 +479,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
let error = self.errorWithDetail("connection closed by server", code: code)
|
||||
self.doDisconnect(error)
|
||||
doDisconnect(errorWithDetail("connection closed by server", code: code))
|
||||
writeError(code)
|
||||
return
|
||||
}
|
||||
@@ -521,10 +513,13 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
data = NSData(bytes: UnsafePointer<UInt8>((buffer+offset)), length: Int(len))
|
||||
}
|
||||
if receivedOpcode == OpCode.Pong.rawValue {
|
||||
dispatch_async(queue, {
|
||||
self.onPong?()
|
||||
self.pongDelegate?.websocketDidReceivePong(self)
|
||||
})
|
||||
dispatch_async(queue,{ [weak self] in
|
||||
guard let s = self else { return }
|
||||
if let pongBlock = s.onPong {
|
||||
pongBlock()
|
||||
}
|
||||
s.pongDelegate?.websocketDidReceivePong(s)
|
||||
})
|
||||
|
||||
let step = Int(offset+numericCast(len))
|
||||
let extra = bufferLen-step
|
||||
@@ -539,8 +534,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
if isFin == 0 && receivedOpcode == OpCode.ContinueFrame.rawValue && response == nil {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("continue frame before a binary or text frame", code: errCode)
|
||||
self.doDisconnect(error)
|
||||
doDisconnect(errorWithDetail("continue frame before a binary or text frame", code: errCode))
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -548,9 +542,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
if(response == nil) {
|
||||
if receivedOpcode == OpCode.ContinueFrame.rawValue {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("first frame can't be a continue frame",
|
||||
code: errCode)
|
||||
self.doDisconnect(error)
|
||||
doDisconnect(errorWithDetail("first frame can't be a continue frame",
|
||||
code: errCode))
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -564,9 +557,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
response!.bytesLeft = Int(dataLength)
|
||||
} else {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("second and beyond of fragment message must be a continue frame",
|
||||
code: errCode)
|
||||
self.doDisconnect(error)
|
||||
doDisconnect(errorWithDetail("second and beyond of fragment message must be a continue frame",
|
||||
code: errCode))
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -608,24 +600,28 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
dequeueWrite(data, code: OpCode.Pong)
|
||||
} else if response.code == .TextFrame {
|
||||
let str: NSString? = NSString(data: response.buffer!, encoding: NSUTF8StringEncoding)
|
||||
|
||||
if let str = str as String? {
|
||||
dispatch_async(queue, {
|
||||
self.onText?(str)
|
||||
self.delegate?.websocketDidReceiveMessage(self, text: str)
|
||||
})
|
||||
} else {
|
||||
if str == nil {
|
||||
writeError(CloseCode.Encoding.rawValue)
|
||||
return false
|
||||
}
|
||||
|
||||
dispatch_async(queue,{ [weak self] in
|
||||
guard let s = self else { return }
|
||||
if let textBlock = s.onText {
|
||||
textBlock(str! as String)
|
||||
}
|
||||
s.delegate?.websocketDidReceiveMessage(s, text: str! as String)
|
||||
})
|
||||
} else if response.code == .BinaryFrame {
|
||||
let data = response.buffer! //local copy so it is perverse for writing
|
||||
dispatch_async(queue) {
|
||||
self.onData?(data)
|
||||
self.delegate?.websocketDidReceiveData(self, data: data)
|
||||
}
|
||||
dispatch_async(queue,{ [weak self] in
|
||||
guard let s = self else { return }
|
||||
if let dataBlock = s.onData {
|
||||
dataBlock(data)
|
||||
}
|
||||
s.delegate?.websocketDidReceiveData(s, data: data)
|
||||
})
|
||||
}
|
||||
|
||||
readStack.removeLast()
|
||||
return true
|
||||
}
|
||||
@@ -648,31 +644,18 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
///used to write things to the stream
|
||||
private func dequeueWrite(data: NSData, code: OpCode) {
|
||||
if writeQueue == nil {
|
||||
writeQueue = NSOperationQueue()
|
||||
writeQueue!.maxConcurrentOperationCount = 1
|
||||
if !isConnected {
|
||||
return
|
||||
}
|
||||
writeQueue!.addOperationWithBlock {
|
||||
writeQueue.addOperationWithBlock { [weak self] in
|
||||
//stream isn't ready, let's wait
|
||||
var tries = 0;
|
||||
while self.outputStream == nil || !self.connected {
|
||||
if(tries < 5) {
|
||||
sleep(1);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
tries++;
|
||||
}
|
||||
if !self.connected {
|
||||
return
|
||||
}
|
||||
guard let s = self else { return }
|
||||
var offset = 2
|
||||
UINT16_MAX
|
||||
let bytes = UnsafeMutablePointer<UInt8>(data.bytes)
|
||||
let dataLength = data.length
|
||||
let frame = NSMutableData(capacity: dataLength + self.MaxFrameSize)
|
||||
let frame = NSMutableData(capacity: dataLength + s.MaxFrameSize)
|
||||
let buffer = UnsafeMutablePointer<UInt8>(frame!.mutableBytes)
|
||||
buffer[0] = self.FinMask | code.rawValue
|
||||
buffer[0] = s.FinMask | code.rawValue
|
||||
if dataLength < 126 {
|
||||
buffer[1] = CUnsignedChar(dataLength)
|
||||
} else if dataLength <= Int(UInt16.max) {
|
||||
@@ -686,7 +669,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
sizeBuffer[0] = UInt64(dataLength).bigEndian
|
||||
offset += sizeof(UInt64)
|
||||
}
|
||||
buffer[1] |= self.MaskMask
|
||||
buffer[1] |= s.MaskMask
|
||||
let maskKey = UnsafeMutablePointer<UInt8>(buffer + offset)
|
||||
SecRandomCopyBytes(kSecRandomDefault, Int(sizeof(UInt32)), maskKey)
|
||||
offset += sizeof(UInt32)
|
||||
@@ -697,23 +680,24 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
var total = 0
|
||||
while true {
|
||||
if self.outputStream == nil {
|
||||
if !s.isConnected {
|
||||
break
|
||||
}
|
||||
guard let outStream = s.outputStream else { break }
|
||||
let writeBuffer = UnsafePointer<UInt8>(frame!.bytes+total)
|
||||
let len = self.outputStream?.write(writeBuffer, maxLength: offset-total)
|
||||
if len == nil || len! < 0 {
|
||||
let len = outStream.write(writeBuffer, maxLength: offset-total)
|
||||
if len < 0 {
|
||||
var error: NSError?
|
||||
if let streamError = self.outputStream?.streamError {
|
||||
if let streamError = outStream.streamError {
|
||||
error = streamError
|
||||
} else {
|
||||
let errCode = InternalErrorCode.OutputStreamWriteError.rawValue
|
||||
error = self.errorWithDetail("output stream error during write", code: errCode)
|
||||
error = s.errorWithDetail("output stream error during write", code: errCode)
|
||||
}
|
||||
self.doDisconnect(error)
|
||||
s.doDisconnect(error)
|
||||
break
|
||||
} else {
|
||||
total += len!
|
||||
total += len
|
||||
}
|
||||
if total >= offset {
|
||||
break
|
||||
@@ -725,31 +709,20 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
|
||||
///used to preform the disconnect delegate
|
||||
private func doDisconnect(error: NSError?) {
|
||||
if !self.didDisconnect {
|
||||
dispatch_async(queue) {
|
||||
self.didDisconnect = true
|
||||
|
||||
self.onDisconnect?(error)
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
}
|
||||
if !didDisconnect {
|
||||
dispatch_async(queue,{ [weak self] in
|
||||
guard let s = self else { return }
|
||||
s.didDisconnect = true
|
||||
if let disconnect = s.onDisconnect {
|
||||
disconnect(error)
|
||||
}
|
||||
s.delegate?.websocketDidDisconnect(s, error: error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Security.swift
|
||||
// Starscream
|
||||
//
|
||||
// Created by Dalton Cherry on 5/16/15.
|
||||
// Copyright (c) 2015 Vluxe. All rights reserved.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import Foundation
|
||||
import Security
|
||||
|
||||
private class SSLCert {
|
||||
var certData: NSData?
|
||||
var key: SecKeyRef?
|
||||
@@ -757,9 +730,9 @@ private class SSLCert {
|
||||
/**
|
||||
Designated init for certificates
|
||||
|
||||
:param: data is the binary data of the certificate
|
||||
- parameter data: is the binary data of the certificate
|
||||
|
||||
:returns: a representation security object to be used with
|
||||
- returns: a representation security object to be used with
|
||||
*/
|
||||
init(data: NSData) {
|
||||
self.certData = data
|
||||
@@ -768,17 +741,17 @@ private class SSLCert {
|
||||
/**
|
||||
Designated init for public keys
|
||||
|
||||
:param: key is the public key to be used
|
||||
- parameter key: is the public key to be used
|
||||
|
||||
:returns: a representation security object to be used with
|
||||
- returns: a representation security object to be used with
|
||||
*/
|
||||
init(key: SecKeyRef) {
|
||||
self.key = key
|
||||
}
|
||||
}
|
||||
|
||||
private class Security {
|
||||
private var validatedDN = true //should the domain name be validated?
|
||||
private class SSLSecurity {
|
||||
var validatedDN = true //should the domain name be validated?
|
||||
|
||||
var isReady = false //is the key processing done?
|
||||
var certificates: [NSData]? //the certificates
|
||||
@@ -788,11 +761,11 @@ private class Security {
|
||||
/**
|
||||
Use certs from main app bundle
|
||||
|
||||
:param: usePublicKeys is to specific if the publicKeys or certificates should be used for SSL pinning validation
|
||||
- parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation
|
||||
|
||||
:returns: a representation security object to be used with
|
||||
- returns: a representation security object to be used with
|
||||
*/
|
||||
private convenience init(usePublicKeys: Bool = false) {
|
||||
convenience init(usePublicKeys: Bool = false) {
|
||||
let paths = NSBundle.mainBundle().pathsForResourcesOfType("cer", inDirectory: ".")
|
||||
var collect = Array<SSLCert>()
|
||||
for path in paths {
|
||||
@@ -806,12 +779,12 @@ private class Security {
|
||||
/**
|
||||
Designated init
|
||||
|
||||
:param: keys is the certificates or public keys to use
|
||||
:param: usePublicKeys is to specific if the publicKeys or certificates should be used for SSL pinning validation
|
||||
- parameter keys: is the certificates or public keys to use
|
||||
- parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation
|
||||
|
||||
:returns: a representation security object to be used with
|
||||
- returns: a representation security object to be used with
|
||||
*/
|
||||
private init(certs: [SSLCert], usePublicKeys: Bool) {
|
||||
init(certs: [SSLCert], usePublicKeys: Bool) {
|
||||
self.usePublicKeys = usePublicKeys
|
||||
|
||||
if self.usePublicKeys {
|
||||
@@ -843,12 +816,12 @@ private class Security {
|
||||
/**
|
||||
Valid the trust and domain name.
|
||||
|
||||
:param: trust is the serverTrust to validate
|
||||
:param: domain is the CN domain to validate
|
||||
- parameter trust: is the serverTrust to validate
|
||||
- parameter domain: is the CN domain to validate
|
||||
|
||||
:returns: if the key was successfully validated
|
||||
- returns: if the key was successfully validated
|
||||
*/
|
||||
private func isValid(trust: SecTrustRef, domain: String?) -> Bool {
|
||||
func isValid(trust: SecTrustRef, domain: String?) -> Bool {
|
||||
|
||||
var tries = 0
|
||||
while(!self.isReady) {
|
||||
@@ -912,14 +885,14 @@ private class Security {
|
||||
/**
|
||||
Get the public key from a certificate data
|
||||
|
||||
:param: data is the certificate to pull the public key from
|
||||
- parameter data: is the certificate to pull the public key from
|
||||
|
||||
:returns: a public key
|
||||
- returns: a public key
|
||||
*/
|
||||
func extractPublicKey(data: NSData) -> SecKeyRef? {
|
||||
let possibleCert = SecCertificateCreateWithData(nil,data)
|
||||
if let cert = possibleCert {
|
||||
return extractPublicKeyFromCert(cert,policy: SecPolicyCreateBasicX509())
|
||||
return extractPublicKeyFromCert(cert, policy: SecPolicyCreateBasicX509())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -927,16 +900,16 @@ private class Security {
|
||||
/**
|
||||
Get the public key from a certificate
|
||||
|
||||
:param: data is the certificate to pull the public key from
|
||||
- parameter data: is the certificate to pull the public key from
|
||||
|
||||
:returns: a public key
|
||||
- returns: a public key
|
||||
*/
|
||||
func extractPublicKeyFromCert(cert: SecCertificate, policy: SecPolicy) -> SecKeyRef? {
|
||||
let possibleTrust = UnsafeMutablePointer<SecTrust?>.alloc(1)
|
||||
SecTrustCreateWithCertificates( cert, policy, possibleTrust)
|
||||
if let trust = possibleTrust.memory {
|
||||
var possibleTrust: SecTrust?
|
||||
SecTrustCreateWithCertificates(cert, policy, &possibleTrust)
|
||||
if let trust = possibleTrust {
|
||||
var result: SecTrustResultType = 0
|
||||
SecTrustEvaluate(trust,&result)
|
||||
SecTrustEvaluate(trust, &result)
|
||||
return SecTrustCopyPublicKey(trust)
|
||||
}
|
||||
return nil
|
||||
@@ -945,9 +918,9 @@ private class Security {
|
||||
/**
|
||||
Get the certificate chain for the trust
|
||||
|
||||
:param: trust is the trust to lookup the certificate chain for
|
||||
- parameter trust: is the trust to lookup the certificate chain for
|
||||
|
||||
:returns: the certificate chain for the trust
|
||||
- returns: the certificate chain for the trust
|
||||
*/
|
||||
func certificateChainForTrust(trust: SecTrustRef) -> Array<NSData> {
|
||||
var collect = Array<NSData>()
|
||||
@@ -961,9 +934,9 @@ private class Security {
|
||||
/**
|
||||
Get the public key chain for the trust
|
||||
|
||||
:param: trust is the trust to lookup the certificate chain and extract the public keys
|
||||
- parameter trust: is the trust to lookup the certificate chain and extract the public keys
|
||||
|
||||
:returns: the public keys from the certifcate chain for the trust
|
||||
- returns: the public keys from the certifcate chain for the trust
|
||||
*/
|
||||
func publicKeyChainForTrust(trust: SecTrustRef) -> Array<SecKeyRef> {
|
||||
var collect = Array<SecKeyRef>()
|
||||
|
||||
Reference in new issue
Block a user