Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac663a8875 | ||
|
|
fba226a6de | ||
|
|
8928ce2693 | ||
|
|
ebe9384604 | ||
|
|
5f75e6080b | ||
|
|
c40b7c169f | ||
|
|
ea0fc9933e | ||
|
|
43827914b7 | ||
|
|
22b9a1e2f2 | ||
|
|
fd66a9fa62 | ||
|
|
998089df91 | ||
|
|
283644b75c | ||
|
|
846897157c | ||
|
|
a49f8f19cf | ||
|
|
531a9784da | ||
|
|
c34a660cae | ||
|
|
9484bc9614 | ||
|
|
d8f65c2804 | ||
|
|
ca3f3e810d | ||
|
|
63021eb995 | ||
|
|
d8e3408565 | ||
|
|
f17575b35c | ||
|
|
58571e5387 | ||
|
|
1a54decd51 | ||
|
|
d982cdc1b2 | ||
|
|
079063e396 | ||
|
|
33d5fd3f10 | ||
|
|
3be5621263 | ||
|
|
81ab71f519 | ||
|
|
bfeec57c04 | ||
|
|
0b09a1357c | ||
|
|
e8dfe589ac | ||
|
|
fcebc870c3 | ||
|
|
eeadccec94 | ||
|
|
fa0d5022cf | ||
|
|
2fdd1313a8 | ||
|
|
61b4628d3e | ||
|
|
77ed87d0d4 | ||
|
|
a6f68e7b70 | ||
|
|
2453f33191 | ||
|
|
bb3d7fbded | ||
|
|
f54153f3d4 | ||
|
|
709ecc30b3 | ||
|
|
72dd2ef364 |
No files matched your search
+18
@@ -23,3 +23,21 @@ Icon
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Xcode
|
||||
build/
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
*.xccheckout
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
*.hmap
|
||||
*.ipa
|
||||
*.xcuserstate
|
||||
@@ -19,7 +19,6 @@ socket.on("currentAmount") {data, ack in
|
||||
}
|
||||
}
|
||||
|
||||
// Connect
|
||||
socket.connect()
|
||||
```
|
||||
|
||||
@@ -27,12 +26,18 @@ socket.connect()
|
||||
```objective-c
|
||||
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" options:nil];
|
||||
|
||||
[socket on: @"connect" callback: ^(NSArray* data, void (^ack)(NSArray*)) {
|
||||
NSLog(@"connected");
|
||||
[socket emit:@"echo" withItems:@[@"echo test"]];
|
||||
[socket emitWithAck:@"ackack" withItems:@[@1]](10, ^(NSArray* data) {
|
||||
NSLog(@"Got ack");
|
||||
[socket on:@"connect" callback:^(NSArray* data, void (^ack)(NSArray*)) {
|
||||
NSLog(@"socket connected");
|
||||
}];
|
||||
|
||||
[socket on:@"currentAmount" callback:^(NSArray* data, void (^ack)(NSArray*)) {
|
||||
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"]);
|
||||
}];
|
||||
|
||||
[socket connect];
|
||||
@@ -50,6 +55,16 @@ SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8
|
||||
Requires Swift 1.2/Xcode 6.3
|
||||
|
||||
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" ~> 2.3.10 # 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))
|
||||
@@ -64,7 +79,7 @@ source 'https://github.com/CocoaPods/Specs.git'
|
||||
platform :ios, '8.0'
|
||||
use_frameworks!
|
||||
|
||||
pod 'Socket.IO-Client-Swift', '~> 1.3.2' # Or latest version
|
||||
pod 'Socket.IO-Client-Swift', '~> 2.3.10' # Or latest version
|
||||
```
|
||||
|
||||
Install pods:
|
||||
@@ -73,12 +88,18 @@ Install pods:
|
||||
$ pod install
|
||||
```
|
||||
|
||||
Import in your swift file:
|
||||
Import the module:
|
||||
|
||||
Swift:
|
||||
```swift
|
||||
import Socket_IO_Client_Swift
|
||||
```
|
||||
|
||||
Objective-C:
|
||||
```Objective-C
|
||||
#import <Socket_IO_Client_Swift/Socket_IO_Client_Swift-Swift.h>
|
||||
```
|
||||
|
||||
##API
|
||||
Constructors
|
||||
-----------
|
||||
@@ -99,6 +120,7 @@ Options
|
||||
- `log: Bool` If `true` socket will log debug messages. Default is false.
|
||||
- `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.
|
||||
|
||||
Methods
|
||||
-------
|
||||
@@ -112,6 +134,8 @@ Methods
|
||||
8. `connect(#timeoutAfter:Int, withTimeoutHandler handler:(() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
|
||||
9. `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.
|
||||
10. `reconnect()` - Causes the client to reconnect to the server.
|
||||
11. `joinNamespace()` - Causes the client to join nsp. Shouldn't need to be called unless you change nsp manually.
|
||||
12. `leaveNamespace()` - Causes the client to leave the nsp and go back to /
|
||||
|
||||
Client Events
|
||||
------
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Socket.IO-Client-Swift"
|
||||
s.version = "2.3.0"
|
||||
s.version = "2.3.10"
|
||||
s.summary = "Socket.IO-client for iOS and OS X"
|
||||
s.description = <<-DESC
|
||||
Socket.IO-client for iOS and OS X.
|
||||
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
|
||||
s.author = { "Erik" => "nuclear.ace@gmail.com" }
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.10'
|
||||
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.3.0' }
|
||||
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v2.3.10' }
|
||||
s.source_files = "SocketIOClientSwift/**/*.swift"
|
||||
s.requires_arc = true
|
||||
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
|
||||
|
||||
@@ -0,0 +1,935 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
||||
572EF22C1B51F16C00EEBB58 /* SocketIO_iOSTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572EF22B1B51F16C00EEBB58 /* SocketIO_iOSTests.swift */; };
|
||||
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 */; };
|
||||
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 */; };
|
||||
5764DF8C1B51F254004FF46E /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||
5764DF8D1B51F254004FF46E /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
||||
5764DF8E1B51F254004FF46E /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
||||
5764DF8F1B51F254004FF46E /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */; };
|
||||
5764DF901B51F254004FF46E /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */; };
|
||||
5764DF911B51F254004FF46E /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF801B51F254004FF46E /* SocketEventHandler.swift */; };
|
||||
5764DF921B51F254004FF46E /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF801B51F254004FF46E /* SocketEventHandler.swift */; };
|
||||
5764DF931B51F254004FF46E /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF811B51F254004FF46E /* SocketFixUTF8.swift */; };
|
||||
5764DF941B51F254004FF46E /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF811B51F254004FF46E /* SocketFixUTF8.swift */; };
|
||||
5764DF951B51F254004FF46E /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF821B51F254004FF46E /* SocketIOClient.swift */; };
|
||||
5764DF961B51F254004FF46E /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF821B51F254004FF46E /* SocketIOClient.swift */; };
|
||||
5764DF971B51F254004FF46E /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF831B51F254004FF46E /* SocketLogger.swift */; };
|
||||
5764DF981B51F254004FF46E /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF831B51F254004FF46E /* SocketLogger.swift */; };
|
||||
5764DF991B51F254004FF46E /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF841B51F254004FF46E /* SocketPacket.swift */; };
|
||||
5764DF9A1B51F254004FF46E /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF841B51F254004FF46E /* SocketPacket.swift */; };
|
||||
5764DF9B1B51F254004FF46E /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF851B51F254004FF46E /* SocketParser.swift */; };
|
||||
5764DF9C1B51F254004FF46E /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF851B51F254004FF46E /* SocketParser.swift */; };
|
||||
5764DF9D1B51F254004FF46E /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
||||
5764DF9E1B51F254004FF46E /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
||||
5764DF9F1B51F254004FF46E /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||
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 */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
572EF2261B51F16C00EEBB58 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 572EF20E1B51F12F00EEBB58 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 572EF2181B51F16C00EEBB58;
|
||||
remoteInfo = "SocketIO-iOS";
|
||||
};
|
||||
572EF2441B51F18A00EEBB58 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 572EF20E1B51F12F00EEBB58 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 572EF2371B51F18A00EEBB58;
|
||||
remoteInfo = "SocketIO-Mac";
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
572EF2191B51F16C00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
572EF21D1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = "<group>"; };
|
||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
572EF22A1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
572EF22B1B51F16C00EEBB58 /* SocketIO_iOSTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketIO_iOSTests.swift; sourceTree = "<group>"; };
|
||||
572EF2381B51F18A00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
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>"; };
|
||||
5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEngineClient.swift; path = SocketIOClientSwift/SocketEngineClient.swift; sourceTree = "<group>"; };
|
||||
5764DF801B51F254004FF46E /* SocketEventHandler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEventHandler.swift; path = SocketIOClientSwift/SocketEventHandler.swift; sourceTree = "<group>"; };
|
||||
5764DF811B51F254004FF46E /* SocketFixUTF8.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketFixUTF8.swift; path = SocketIOClientSwift/SocketFixUTF8.swift; sourceTree = "<group>"; };
|
||||
5764DF821B51F254004FF46E /* SocketIOClient.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClient.swift; path = SocketIOClientSwift/SocketIOClient.swift; sourceTree = "<group>"; };
|
||||
5764DF831B51F254004FF46E /* SocketLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketLogger.swift; path = SocketIOClientSwift/SocketLogger.swift; sourceTree = "<group>"; };
|
||||
5764DF841B51F254004FF46E /* SocketPacket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketPacket.swift; path = SocketIOClientSwift/SocketPacket.swift; sourceTree = "<group>"; };
|
||||
5764DF851B51F254004FF46E /* SocketParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketParser.swift; path = SocketIOClientSwift/SocketParser.swift; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
572EF2151B51F16C00EEBB58 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF2211B51F16C00EEBB58 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF2341B51F18A00EEBB58 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF23F1B51F18A00EEBB58 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
572EF20D1B51F12F00EEBB58 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5764DF7B1B51F24A004FF46E /* Source */,
|
||||
572EF21B1B51F16C00EEBB58 /* SocketIO-iOS */,
|
||||
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */,
|
||||
572EF2391B51F18A00EEBB58 /* SocketIO-Mac */,
|
||||
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */,
|
||||
572EF21A1B51F16C00EEBB58 /* Products */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF21A1B51F16C00EEBB58 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF2191B51F16C00EEBB58 /* SocketIO.framework */,
|
||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */,
|
||||
572EF2381B51F18A00EEBB58 /* SocketIO.framework */,
|
||||
572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF21B1B51F16C00EEBB58 /* SocketIO-iOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */,
|
||||
572EF21C1B51F16C00EEBB58 /* Supporting Files */,
|
||||
);
|
||||
path = "SocketIO-iOS";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF21C1B51F16C00EEBB58 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF21D1B51F16C00EEBB58 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF22B1B51F16C00EEBB58 /* SocketIO_iOSTests.swift */,
|
||||
572EF2291B51F16C00EEBB58 /* Supporting Files */,
|
||||
);
|
||||
path = "SocketIO-iOSTests";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF2291B51F16C00EEBB58 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF22A1B51F16C00EEBB58 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF2391B51F18A00EEBB58 /* SocketIO-Mac */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */,
|
||||
572EF23A1B51F18A00EEBB58 /* Supporting Files */,
|
||||
);
|
||||
path = "SocketIO-Mac";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF23A1B51F18A00EEBB58 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF23B1B51F18A00EEBB58 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF2491B51F18A00EEBB58 /* SocketIO_MacTests.swift */,
|
||||
572EF2471B51F18A00EEBB58 /* Supporting Files */,
|
||||
);
|
||||
path = "SocketIO-MacTests";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF2471B51F18A00EEBB58 /* Supporting Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF2481B51F18A00EEBB58 /* Info.plist */,
|
||||
);
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
5764DF7B1B51F24A004FF46E /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5764DF7C1B51F254004FF46E /* SocketAckManager.swift */,
|
||||
5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */,
|
||||
5764DF7E1B51F254004FF46E /* SocketEngine.swift */,
|
||||
5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */,
|
||||
5764DF801B51F254004FF46E /* SocketEventHandler.swift */,
|
||||
5764DF811B51F254004FF46E /* SocketFixUTF8.swift */,
|
||||
5764DF821B51F254004FF46E /* SocketIOClient.swift */,
|
||||
5764DF831B51F254004FF46E /* SocketLogger.swift */,
|
||||
5764DF841B51F254004FF46E /* SocketPacket.swift */,
|
||||
5764DF851B51F254004FF46E /* SocketParser.swift */,
|
||||
5764DF861B51F254004FF46E /* SocketTypes.swift */,
|
||||
5764DF871B51F254004FF46E /* SwiftRegex.swift */,
|
||||
5764DF881B51F254004FF46E /* WebSocket.swift */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
572EF2161B51F16C00EEBB58 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF2351B51F18A00EEBB58 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF23D1B51F18A00EEBB58 /* SocketIO-Mac.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
572EF2181B51F16C00EEBB58 /* SocketIO-iOS */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 572EF22D1B51F16C00EEBB58 /* Build configuration list for PBXNativeTarget "SocketIO-iOS" */;
|
||||
buildPhases = (
|
||||
572EF2141B51F16C00EEBB58 /* Sources */,
|
||||
572EF2151B51F16C00EEBB58 /* Frameworks */,
|
||||
572EF2161B51F16C00EEBB58 /* Headers */,
|
||||
572EF2171B51F16C00EEBB58 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "SocketIO-iOS";
|
||||
productName = "SocketIO-iOS";
|
||||
productReference = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
572EF2231B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 572EF2301B51F16C00EEBB58 /* Build configuration list for PBXNativeTarget "SocketIO-iOSTests" */;
|
||||
buildPhases = (
|
||||
572EF2201B51F16C00EEBB58 /* Sources */,
|
||||
572EF2211B51F16C00EEBB58 /* Frameworks */,
|
||||
572EF2221B51F16C00EEBB58 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
572EF2271B51F16C00EEBB58 /* PBXTargetDependency */,
|
||||
);
|
||||
name = "SocketIO-iOSTests";
|
||||
productName = "SocketIO-iOSTests";
|
||||
productReference = 572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
572EF2371B51F18A00EEBB58 /* SocketIO-Mac */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 572EF24B1B51F18A00EEBB58 /* Build configuration list for PBXNativeTarget "SocketIO-Mac" */;
|
||||
buildPhases = (
|
||||
572EF2331B51F18A00EEBB58 /* Sources */,
|
||||
572EF2341B51F18A00EEBB58 /* Frameworks */,
|
||||
572EF2351B51F18A00EEBB58 /* Headers */,
|
||||
572EF2361B51F18A00EEBB58 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = "SocketIO-Mac";
|
||||
productName = "SocketIO-Mac";
|
||||
productReference = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
572EF2411B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 572EF24E1B51F18A00EEBB58 /* Build configuration list for PBXNativeTarget "SocketIO-MacTests" */;
|
||||
buildPhases = (
|
||||
572EF23E1B51F18A00EEBB58 /* Sources */,
|
||||
572EF23F1B51F18A00EEBB58 /* Frameworks */,
|
||||
572EF2401B51F18A00EEBB58 /* Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
572EF2451B51F18A00EEBB58 /* PBXTargetDependency */,
|
||||
);
|
||||
name = "SocketIO-MacTests";
|
||||
productName = "SocketIO-MacTests";
|
||||
productReference = 572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
572EF20E1B51F12F00EEBB58 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0700;
|
||||
LastUpgradeCheck = 0640;
|
||||
TargetAttributes = {
|
||||
572EF2181B51F16C00EEBB58 = {
|
||||
CreatedOnToolsVersion = 6.4;
|
||||
};
|
||||
572EF2231B51F16C00EEBB58 = {
|
||||
CreatedOnToolsVersion = 6.4;
|
||||
};
|
||||
572EF2371B51F18A00EEBB58 = {
|
||||
CreatedOnToolsVersion = 6.4;
|
||||
};
|
||||
572EF2411B51F18A00EEBB58 = {
|
||||
CreatedOnToolsVersion = 6.4;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 572EF2111B51F12F00EEBB58 /* Build configuration list for PBXProject "Socket.IO-Client-Swift" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 572EF20D1B51F12F00EEBB58;
|
||||
productRefGroup = 572EF21A1B51F16C00EEBB58 /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
572EF2181B51F16C00EEBB58 /* SocketIO-iOS */,
|
||||
572EF2231B51F16C00EEBB58 /* SocketIO-iOSTests */,
|
||||
572EF2371B51F18A00EEBB58 /* SocketIO-Mac */,
|
||||
572EF2411B51F18A00EEBB58 /* SocketIO-MacTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXResourcesBuildPhase section */
|
||||
572EF2171B51F16C00EEBB58 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF2221B51F16C00EEBB58 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF2361B51F18A00EEBB58 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF2401B51F18A00EEBB58 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
572EF2141B51F16C00EEBB58 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5764DF8D1B51F254004FF46E /* SocketEngine.swift in Sources */,
|
||||
5764DF9B1B51F254004FF46E /* SocketParser.swift in Sources */,
|
||||
5764DF9D1B51F254004FF46E /* SocketTypes.swift in Sources */,
|
||||
5764DF8F1B51F254004FF46E /* SocketEngineClient.swift in Sources */,
|
||||
5764DF911B51F254004FF46E /* SocketEventHandler.swift in Sources */,
|
||||
5764DF931B51F254004FF46E /* SocketFixUTF8.swift in Sources */,
|
||||
5764DF951B51F254004FF46E /* SocketIOClient.swift in Sources */,
|
||||
5764DF8B1B51F254004FF46E /* SocketAnyEvent.swift in Sources */,
|
||||
5764DF971B51F254004FF46E /* SocketLogger.swift in Sources */,
|
||||
5764DFA11B51F254004FF46E /* WebSocket.swift in Sources */,
|
||||
5764DF991B51F254004FF46E /* SocketPacket.swift in Sources */,
|
||||
5764DF891B51F254004FF46E /* SocketAckManager.swift in Sources */,
|
||||
5764DF9F1B51F254004FF46E /* SwiftRegex.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF2201B51F16C00EEBB58 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF22C1B51F16C00EEBB58 /* SocketIO_iOSTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF2331B51F18A00EEBB58 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
5764DF8E1B51F254004FF46E /* SocketEngine.swift in Sources */,
|
||||
5764DF9C1B51F254004FF46E /* SocketParser.swift in Sources */,
|
||||
5764DF9E1B51F254004FF46E /* SocketTypes.swift in Sources */,
|
||||
5764DF901B51F254004FF46E /* SocketEngineClient.swift in Sources */,
|
||||
5764DF921B51F254004FF46E /* SocketEventHandler.swift in Sources */,
|
||||
5764DF941B51F254004FF46E /* SocketFixUTF8.swift in Sources */,
|
||||
5764DF961B51F254004FF46E /* SocketIOClient.swift in Sources */,
|
||||
5764DF8C1B51F254004FF46E /* SocketAnyEvent.swift in Sources */,
|
||||
5764DF981B51F254004FF46E /* SocketLogger.swift in Sources */,
|
||||
5764DFA21B51F254004FF46E /* WebSocket.swift in Sources */,
|
||||
5764DF9A1B51F254004FF46E /* SocketPacket.swift in Sources */,
|
||||
5764DF8A1B51F254004FF46E /* SocketAckManager.swift in Sources */,
|
||||
5764DFA01B51F254004FF46E /* SwiftRegex.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
572EF23E1B51F18A00EEBB58 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF24A1B51F18A00EEBB58 /* SocketIO_MacTests.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
572EF2271B51F16C00EEBB58 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 572EF2181B51F16C00EEBB58 /* SocketIO-iOS */;
|
||||
targetProxy = 572EF2261B51F16C00EEBB58 /* PBXContainerItemProxy */;
|
||||
};
|
||||
572EF2451B51F18A00EEBB58 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 572EF2371B51F18A00EEBB58 /* SocketIO-Mac */;
|
||||
targetProxy = 572EF2441B51F18A00EEBB58 /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
572EF2121B51F12F00EEBB58 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
PRODUCT_NAME = SocketIO;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
572EF2131B51F12F00EEBB58 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
PRODUCT_NAME = SocketIO;
|
||||
SWIFT_WHOLE_MODULE_OPTIMIZATION = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
572EF22E1B51F16C00EEBB58 /* 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 = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
572EF22F1B51F16C00EEBB58 /* 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 = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
572EF2311B51F16C00EEBB58 /* 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;
|
||||
};
|
||||
572EF2321B51F16C00EEBB58 /* 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;
|
||||
};
|
||||
572EF24C1B51F18A00EEBB58 /* 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;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
FRAMEWORK_VERSION = A;
|
||||
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-Mac/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
572EF24D1B51F18A00EEBB58 /* 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;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
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;
|
||||
FRAMEWORK_VERSION = A;
|
||||
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-Mac/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
572EF24F1B51F18A00EEBB58 /* 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;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(DEVELOPER_FRAMEWORKS_DIR)",
|
||||
"$(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-MacTests/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
572EF2501B51F18A00EEBB58 /* 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;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(DEVELOPER_FRAMEWORKS_DIR)",
|
||||
"$(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-MacTests/Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
572EF2111B51F12F00EEBB58 /* Build configuration list for PBXProject "Socket.IO-Client-Swift" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
572EF2121B51F12F00EEBB58 /* Debug */,
|
||||
572EF2131B51F12F00EEBB58 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
572EF22D1B51F16C00EEBB58 /* Build configuration list for PBXNativeTarget "SocketIO-iOS" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
572EF22E1B51F16C00EEBB58 /* Debug */,
|
||||
572EF22F1B51F16C00EEBB58 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
572EF2301B51F16C00EEBB58 /* Build configuration list for PBXNativeTarget "SocketIO-iOSTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
572EF2311B51F16C00EEBB58 /* Debug */,
|
||||
572EF2321B51F16C00EEBB58 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
572EF24B1B51F18A00EEBB58 /* Build configuration list for PBXNativeTarget "SocketIO-Mac" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
572EF24C1B51F18A00EEBB58 /* Debug */,
|
||||
572EF24D1B51F18A00EEBB58 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
572EF24E1B51F18A00EEBB58 /* Build configuration list for PBXNativeTarget "SocketIO-MacTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
572EF24F1B51F18A00EEBB58 /* Debug */,
|
||||
572EF2501B51F18A00EEBB58 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 572EF20E1B51F12F00EEBB58 /* Project object */;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "self:Socket.IO-Client-Swift.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0640"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2411B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO-MacTests.xctest"
|
||||
BlueprintName = "SocketIO-MacTests"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2411B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO-MacTests.xctest"
|
||||
BlueprintName = "SocketIO-MacTests"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,110 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0640"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "NO"
|
||||
buildForProfiling = "NO"
|
||||
buildForArchiving = "NO"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2231B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO-iOSTests.xctest"
|
||||
BlueprintName = "SocketIO-iOSTests"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2231B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO-iOSTests.xctest"
|
||||
BlueprintName = "SocketIO-iOSTests"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Debug"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
buildConfiguration = "Release"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SocketIO-Mac.h
|
||||
// SocketIO-Mac
|
||||
//
|
||||
// Created by Nacho Soto on 7/11/15.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
//! Project version number for SocketIO-Mac.
|
||||
FOUNDATION_EXPORT double SocketIO_MacVersionNumber;
|
||||
|
||||
//! Project version string for SocketIO-Mac.
|
||||
FOUNDATION_EXPORT const unsigned char SocketIO_MacVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <SocketIO_Mac/PublicHeader.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// 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,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,19 @@
|
||||
//
|
||||
// SocketIO-iOS.h
|
||||
// SocketIO-iOS
|
||||
//
|
||||
// Created by Nacho Soto on 7/11/15.
|
||||
//
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
//! Project version number for SocketIO-iOS.
|
||||
FOUNDATION_EXPORT double SocketIO_iOSVersionNumber;
|
||||
|
||||
//! Project version string for SocketIO-iOS.
|
||||
FOUNDATION_EXPORT const unsigned char SocketIO_iOSVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <SocketIO_iOS/PublicHeader.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// SocketIO_iOSTests.swift
|
||||
// SocketIO-iOSTests
|
||||
//
|
||||
// Created by Nacho Soto on 7/11/15.
|
||||
//
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import XCTest
|
||||
|
||||
class SocketIO_iOSTests: 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.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,11 +53,11 @@ struct SocketAckManager {
|
||||
private var acks = Set<SocketAck>(minimumCapacity: 1)
|
||||
|
||||
mutating func addAck(ack:Int, callback:AckCallback) {
|
||||
self.acks.insert(SocketAck(ack: ack, callback: callback))
|
||||
acks.insert(SocketAck(ack: ack, callback: callback))
|
||||
}
|
||||
|
||||
mutating func executeAck(ack:Int, items:[AnyObject]?) {
|
||||
let callback = self.acks.remove(SocketAck(ack: ack))
|
||||
let callback = acks.remove(SocketAck(ack: ack))
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
callback?.callback(items)
|
||||
@@ -65,7 +65,7 @@ struct SocketAckManager {
|
||||
}
|
||||
|
||||
mutating func timeoutAck(ack:Int) {
|
||||
let callback = self.acks.remove(SocketAck(ack: ack))
|
||||
let callback = acks.remove(SocketAck(ack: ack))
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
callback?.callback(["NO ACK"])
|
||||
|
||||
@@ -24,16 +24,11 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
extension String {
|
||||
private var length:Int {
|
||||
return count(self)
|
||||
}
|
||||
}
|
||||
|
||||
public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
private typealias Probe = (msg:String, type:PacketType, data:ContiguousArray<NSData>?)
|
||||
private typealias ProbeWaitQueue = [Probe]
|
||||
|
||||
private let allowedCharacterSet = NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
|
||||
private let workQueue = NSOperationQueue()
|
||||
private let emitQueue = dispatch_queue_create("engineEmitQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let parseQueue = dispatch_queue_create("engineParseQueue", DISPATCH_QUEUE_SERIAL)
|
||||
@@ -42,10 +37,19 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
|
||||
private var closed = false
|
||||
private var _connected = false
|
||||
private var extraHeaders:[String: String]?
|
||||
private var fastUpgrade = false
|
||||
private var forcePolling = false
|
||||
private var forceWebsockets = false
|
||||
private var pingInterval:Double?
|
||||
private var pingTimer:NSTimer?
|
||||
private var pingTimeout = 0.0 {
|
||||
didSet {
|
||||
pongsMissedMax = Int(pingTimeout / (pingInterval ?? 25))
|
||||
}
|
||||
}
|
||||
private var pongsMissed = 0
|
||||
private var pongsMissedMax = 0
|
||||
private var postWait = [String]()
|
||||
private var _polling = true
|
||||
private var probing = false
|
||||
@@ -58,21 +62,20 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
let logType = "SocketEngine"
|
||||
|
||||
var connected:Bool {
|
||||
return self._connected
|
||||
return _connected
|
||||
}
|
||||
weak var client:SocketEngineClient?
|
||||
var cookies:[NSHTTPCookie]?
|
||||
var log = false
|
||||
var pingInterval:Int?
|
||||
var polling:Bool {
|
||||
return self._polling
|
||||
return _polling
|
||||
}
|
||||
var sid = ""
|
||||
var socketPath = ""
|
||||
var urlPolling:String?
|
||||
var urlWebSocket:String?
|
||||
var websocket:Bool {
|
||||
return self._websocket
|
||||
return _websocket
|
||||
}
|
||||
var ws:WebSocket?
|
||||
|
||||
@@ -97,16 +100,17 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
public init(client:SocketEngineClient, sessionDelegate:NSURLSessionDelegate?) {
|
||||
self.client = client
|
||||
self.session = NSURLSession(configuration: NSURLSessionConfiguration.ephemeralSessionConfiguration(),
|
||||
delegate: sessionDelegate, delegateQueue: self.workQueue)
|
||||
delegate: sessionDelegate, delegateQueue: workQueue)
|
||||
}
|
||||
|
||||
public convenience init(client:SocketEngineClient, opts:NSDictionary?) {
|
||||
self.init(client: client, sessionDelegate: opts?["sessionDelegate"] as? NSURLSessionDelegate)
|
||||
self.forceWebsockets = opts?["forceWebsockets"] as? Bool ?? false
|
||||
self.forcePolling = opts?["forcePolling"] as? Bool ?? false
|
||||
self.cookies = opts?["cookies"] as? [NSHTTPCookie]
|
||||
self.log = opts?["log"] as? Bool ?? false
|
||||
self.socketPath = opts?["path"] as? String ?? ""
|
||||
forceWebsockets = opts?["forceWebsockets"] as? Bool ?? false
|
||||
forcePolling = opts?["forcePolling"] as? Bool ?? false
|
||||
cookies = opts?["cookies"] as? [NSHTTPCookie]
|
||||
log = opts?["log"] as? Bool ?? false
|
||||
socketPath = opts?["path"] as? String ?? ""
|
||||
extraHeaders = opts?["extraHeaders"] as? [String: String]
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -114,23 +118,23 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
|
||||
public func close(#fast:Bool) {
|
||||
SocketLogger.log("Engine is being closed. Fast: \(fast)", client: self)
|
||||
SocketLogger.log("Engine is being closed. Fast: %@", client: self, args: fast)
|
||||
|
||||
self.pingTimer?.invalidate()
|
||||
self.closed = true
|
||||
pingTimer?.invalidate()
|
||||
closed = true
|
||||
|
||||
self.ws?.disconnect()
|
||||
ws?.disconnect()
|
||||
|
||||
if fast || self.polling {
|
||||
self.write("", withType: PacketType.CLOSE, withData: nil)
|
||||
self.client?.engineDidClose("Disconnect")
|
||||
if fast || polling {
|
||||
write("", withType: PacketType.CLOSE, withData: nil)
|
||||
client?.engineDidClose("Disconnect")
|
||||
}
|
||||
|
||||
self.stopPolling()
|
||||
stopPolling()
|
||||
}
|
||||
|
||||
private func createBinaryDataForSend(data:NSData) -> (NSData?, String?) {
|
||||
if self.websocket {
|
||||
if websocket {
|
||||
var byteArray = [UInt8](count: 1, repeatedValue: 0x0)
|
||||
byteArray[0] = 4
|
||||
var mutData = NSMutableData(bytes: &byteArray, length: 1)
|
||||
@@ -147,18 +151,18 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
}
|
||||
|
||||
private func createURLs(params:[String: AnyObject]?) -> (String, String) {
|
||||
if self.client == nil {
|
||||
return ("", "")
|
||||
private func createURLs(params:[String: AnyObject]?) -> (String?, String?) {
|
||||
if client == nil {
|
||||
return (nil, nil)
|
||||
}
|
||||
|
||||
let path = self.socketPath == "" ? "/socket.io" : self.socketPath
|
||||
let path = socketPath == "" ? "/socket.io" : socketPath
|
||||
|
||||
var url = "\(self.client!.socketURL)\(path)/?transport="
|
||||
var url = "\(client!.socketURL)\(path)/?transport="
|
||||
var urlPolling:String
|
||||
var urlWebSocket:String
|
||||
|
||||
if self.client!.secure {
|
||||
if client!.secure {
|
||||
urlPolling = "https://" + url + "polling"
|
||||
urlWebSocket = "wss://" + url + "websocket"
|
||||
} else {
|
||||
@@ -167,7 +171,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
|
||||
if params != nil {
|
||||
let allowedCharacterSet = NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
|
||||
|
||||
for (key, value) in params! {
|
||||
let keyEsc = key.stringByAddingPercentEncodingWithAllowedCharacters(
|
||||
@@ -191,48 +194,63 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
|
||||
private func createWebsocket(andConnect connect:Bool) {
|
||||
self.ws = WebSocket(url: NSURL(string: self.urlWebSocket! + "&sid=\(self.sid)")!,
|
||||
cookies: self.cookies)
|
||||
self.ws?.queue = self.handleQueue
|
||||
self.ws?.delegate = self
|
||||
let wsUrl = urlWebSocket! + (sid == "" ? "" : "&sid=\(sid)")
|
||||
|
||||
ws = WebSocket(url: NSURL(string: wsUrl)!,
|
||||
cookies: cookies)
|
||||
|
||||
if extraHeaders != nil {
|
||||
for (headerName, value) in extraHeaders! {
|
||||
ws?.headers[headerName] = value
|
||||
}
|
||||
}
|
||||
|
||||
ws?.queue = handleQueue
|
||||
ws?.delegate = self
|
||||
|
||||
if connect {
|
||||
self.ws?.connect()
|
||||
ws?.connect()
|
||||
}
|
||||
}
|
||||
|
||||
private func doFastUpgrade() {
|
||||
if self.waitingForPoll {
|
||||
if waitingForPoll {
|
||||
SocketLogger.err("Outstanding poll when switched to WebSockets," +
|
||||
"we'll probably disconnect soon. You should report this.", client: self)
|
||||
}
|
||||
|
||||
self.sendWebSocketMessage("", withType: PacketType.UPGRADE, datas: nil)
|
||||
self._websocket = true
|
||||
self._polling = false
|
||||
self.fastUpgrade = false
|
||||
self.probing = false
|
||||
self.flushProbeWait()
|
||||
sendWebSocketMessage("", withType: PacketType.UPGRADE, datas: nil)
|
||||
_websocket = true
|
||||
_polling = false
|
||||
fastUpgrade = false
|
||||
probing = false
|
||||
flushProbeWait()
|
||||
}
|
||||
|
||||
private func doPoll() {
|
||||
if self.websocket || self.waitingForPoll || !self.connected {
|
||||
if websocket || waitingForPoll || !connected {
|
||||
return
|
||||
}
|
||||
|
||||
self.waitingForPoll = true
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: self.urlPolling! + "&sid=\(self.sid)&b64=1")!)
|
||||
waitingForPoll = true
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling! + "&sid=\(sid)&b64=1")!)
|
||||
|
||||
if self.cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(self.cookies!)
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
req.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
self.doRequest(req)
|
||||
if extraHeaders != nil {
|
||||
for (headerName, value) in extraHeaders! {
|
||||
req.setValue(value, forHTTPHeaderField: headerName)
|
||||
}
|
||||
}
|
||||
|
||||
doRequest(req)
|
||||
}
|
||||
|
||||
private func doRequest(req:NSMutableURLRequest) {
|
||||
if !self.polling {
|
||||
if !polling {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -240,13 +258,13 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
|
||||
SocketLogger.log("Doing polling request", client: self)
|
||||
|
||||
self.session.dataTaskWithRequest(req) {[weak self] data, res, err in
|
||||
session.dataTaskWithRequest(req) {[weak self] data, res, err in
|
||||
if let this = self {
|
||||
if err != nil {
|
||||
if this.polling {
|
||||
this.handlePollingFailed(err.localizedDescription)
|
||||
} else {
|
||||
NSLog(err.localizedDescription)
|
||||
SocketLogger.err(err.localizedDescription, client: this)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -263,7 +281,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
|
||||
if this.fastUpgrade {
|
||||
this.doFastUpgrade()
|
||||
return
|
||||
} else if !this.closed && this.polling {
|
||||
this.doPoll()
|
||||
}
|
||||
@@ -273,7 +290,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
private func flushProbeWait() {
|
||||
SocketLogger.log("Flushing probe wait", client: self)
|
||||
|
||||
dispatch_async(self.emitQueue) {[weak self] in
|
||||
dispatch_async(emitQueue) {[weak self] in
|
||||
if let this = self {
|
||||
for waiter in this.probeWait {
|
||||
this.write(waiter.msg, withType: waiter.type, withData: waiter.data)
|
||||
@@ -289,27 +306,27 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
|
||||
private func flushWaitingForPost() {
|
||||
if self.postWait.count == 0 || !self.connected {
|
||||
if postWait.count == 0 || !connected {
|
||||
return
|
||||
} else if self.websocket {
|
||||
self.flushWaitingForPostToWebSocket()
|
||||
} else if websocket {
|
||||
flushWaitingForPostToWebSocket()
|
||||
return
|
||||
}
|
||||
|
||||
var postStr = ""
|
||||
|
||||
for packet in self.postWait {
|
||||
for packet in postWait {
|
||||
let len = count(packet)
|
||||
|
||||
postStr += "\(len):\(packet)"
|
||||
}
|
||||
|
||||
self.postWait.removeAll(keepCapacity: false)
|
||||
postWait.removeAll(keepCapacity: false)
|
||||
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: self.urlPolling! + "&sid=\(self.sid)")!)
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling! + "&sid=\(sid)")!)
|
||||
|
||||
if self.cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(self.cookies!)
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
req.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
@@ -322,11 +339,11 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
req.HTTPBody = postData
|
||||
req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length")
|
||||
|
||||
self.waitingForPost = true
|
||||
waitingForPost = true
|
||||
|
||||
SocketLogger.log("POSTing: \(postStr)", client: self)
|
||||
SocketLogger.log("POSTing: %@", client: self, args: postStr)
|
||||
|
||||
self.session.dataTaskWithRequest(req) {[weak self] data, res, err in
|
||||
session.dataTaskWithRequest(req) {[weak self] data, res, err in
|
||||
if let this = self {
|
||||
if err != nil && this.polling {
|
||||
this.handlePollingFailed(err.localizedDescription)
|
||||
@@ -350,68 +367,145 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
// We had packets waiting for send when we upgraded
|
||||
// Send them raw
|
||||
private func flushWaitingForPostToWebSocket() {
|
||||
for msg in self.postWait {
|
||||
self.ws?.writeString(msg)
|
||||
for msg in postWait {
|
||||
ws?.writeString(msg)
|
||||
}
|
||||
|
||||
self.postWait.removeAll(keepCapacity: true)
|
||||
postWait.removeAll(keepCapacity: true)
|
||||
}
|
||||
|
||||
private func handleClose() {
|
||||
if polling {
|
||||
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: advance(message.startIndex, 2)))
|
||||
|
||||
if let data = NSData(base64EncodedString: message,
|
||||
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters), client = client {
|
||||
dispatch_async(client.handleQueue) {[weak self] in
|
||||
self?.client?.parseBinaryData(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleMessage(message:String) {
|
||||
if let client = client {
|
||||
dispatch_async(client.handleQueue) {[weak client] in
|
||||
client?.parseSocketMessage(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func handleNOOP() {
|
||||
doPoll()
|
||||
}
|
||||
|
||||
private func handleOpen(openData:String) {
|
||||
var err:NSError?
|
||||
let mesData = openData.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
|
||||
|
||||
if let json = NSJSONSerialization.JSONObjectWithData(mesData,
|
||||
options: NSJSONReadingOptions.AllowFragments,
|
||||
error: &err) as? NSDictionary, sid = json["sid"] as? String {
|
||||
self.sid = sid
|
||||
_connected = true
|
||||
|
||||
if !forcePolling && !forceWebsockets {
|
||||
createWebsocket(andConnect: true)
|
||||
}
|
||||
|
||||
if let pingInterval = json["pingInterval"] as? Double, pingTimeout = json["pingTimeout"] as? Double {
|
||||
self.pingInterval = pingInterval / 1000.0
|
||||
self.pingTimeout = pingTimeout / 1000.0
|
||||
}
|
||||
} else {
|
||||
client?.didError("Engine failed to handshake")
|
||||
return
|
||||
}
|
||||
|
||||
startPingTimer()
|
||||
|
||||
if !forceWebsockets {
|
||||
doPoll()
|
||||
}
|
||||
}
|
||||
|
||||
private func handlePong(pongMessage:String) {
|
||||
pongsMissed = 0
|
||||
|
||||
// We should upgrade
|
||||
if pongMessage == "3probe" {
|
||||
upgradeTransport()
|
||||
}
|
||||
}
|
||||
|
||||
// A poll failed, tell the client about it
|
||||
private func handlePollingFailed(reason:String) {
|
||||
self._connected = false
|
||||
self.ws?.disconnect()
|
||||
self.pingTimer?.invalidate()
|
||||
self.waitingForPoll = false
|
||||
self.waitingForPost = false
|
||||
_connected = false
|
||||
ws?.disconnect()
|
||||
pingTimer?.invalidate()
|
||||
waitingForPoll = false
|
||||
waitingForPost = false
|
||||
|
||||
// If cancelled we were already closing
|
||||
if self.client == nil || reason == "cancelled" {
|
||||
if client == nil || reason == "cancelled" {
|
||||
return
|
||||
}
|
||||
|
||||
if !self.closed {
|
||||
self.client?.didError(reason)
|
||||
self.client?.engineDidClose(reason)
|
||||
if !closed {
|
||||
client?.didError(reason)
|
||||
client?.engineDidClose(reason)
|
||||
}
|
||||
}
|
||||
|
||||
public func open(opts:[String: AnyObject]? = nil) {
|
||||
if self.connected {
|
||||
if connected {
|
||||
SocketLogger.err("Tried to open while connected", client: self)
|
||||
|
||||
self.client?.didError("Tried to open while connected")
|
||||
client?.didError("Tried to open while connected")
|
||||
return
|
||||
}
|
||||
|
||||
SocketLogger.log("Starting engine", client: self)
|
||||
SocketLogger.log("Handshaking", client: self)
|
||||
|
||||
self.closed = false
|
||||
let (urlPolling, urlWebSocket) = self.createURLs(opts)
|
||||
self.urlPolling = urlPolling
|
||||
self.urlWebSocket = urlWebSocket
|
||||
closed = false
|
||||
|
||||
if self.forceWebsockets {
|
||||
self._polling = false
|
||||
self._websocket = true
|
||||
self.createWebsocket(andConnect: true)
|
||||
(urlPolling, urlWebSocket) = createURLs(opts)
|
||||
|
||||
if forceWebsockets {
|
||||
_polling = false
|
||||
_websocket = true
|
||||
createWebsocket(andConnect: true)
|
||||
return
|
||||
}
|
||||
|
||||
let reqPolling = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&b64=1")!)
|
||||
let reqPolling = NSMutableURLRequest(URL: NSURL(string: urlPolling! + "&b64=1")!)
|
||||
|
||||
if self.cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(self.cookies!)
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
reqPolling.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
self.doRequest(reqPolling)
|
||||
if extraHeaders != nil {
|
||||
for (headerName, value) in extraHeaders! {
|
||||
reqPolling.setValue(value, forHTTPHeaderField: headerName)
|
||||
}
|
||||
}
|
||||
|
||||
doRequest(reqPolling)
|
||||
}
|
||||
|
||||
// Translatation of engine.io-parser#decodePayload
|
||||
private func parsePollingMessage(str:String) {
|
||||
if str.length == 1 {
|
||||
if count(str) == 1 {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -431,31 +525,28 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
}
|
||||
|
||||
for var i = 0, l = str.length; i < l; i = i &+ 1 {
|
||||
for var i = 0, l = count(str); i < l; i++ {
|
||||
let chr = String(strArray[i])
|
||||
|
||||
if chr != ":" {
|
||||
length += chr
|
||||
} else {
|
||||
if length == "" || testLength(length, &n) {
|
||||
SocketLogger.err("Parsing error: \(str)", client: self)
|
||||
|
||||
self.handlePollingFailed("Error parsing XHR message")
|
||||
SocketLogger.err("Parsing error: %@", client: self, args: str)
|
||||
handlePollingFailed("Error parsing XHR message")
|
||||
return
|
||||
}
|
||||
|
||||
msg = String(strArray[i&+1...i&+n])
|
||||
msg = String(strArray[i+1...i+n])
|
||||
|
||||
if let lengthInt = length.toInt() {
|
||||
if lengthInt != msg.length {
|
||||
SocketLogger.err("parsing error: \(str)", client: self)
|
||||
return
|
||||
}
|
||||
if let lengthInt = length.toInt() where lengthInt != count(msg) {
|
||||
SocketLogger.err("Parsing error: %@", client: self, args: str)
|
||||
return
|
||||
}
|
||||
|
||||
if msg.length != 0 {
|
||||
if count(msg) != 0 {
|
||||
// Be sure to capture the value of the msg
|
||||
dispatch_async(self.handleQueue) {[weak self, msg] in
|
||||
dispatch_async(handleQueue) {[weak self, msg] in
|
||||
self?.parseEngineMessage(msg, fromPolling: true)
|
||||
}
|
||||
}
|
||||
@@ -467,7 +558,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
|
||||
private func parseEngineData(data:NSData) {
|
||||
if let client = self.client {
|
||||
if let client = client {
|
||||
dispatch_async(client.handleQueue) {[weak self] in
|
||||
self?.client?.parseBinaryData(data.subdataWithRange(NSMakeRange(1, data.length - 1)))
|
||||
}
|
||||
@@ -475,121 +566,83 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
|
||||
private func parseEngineMessage(var message:String, fromPolling:Bool) {
|
||||
SocketLogger.log("Got message: \(message)", client: self)
|
||||
SocketLogger.log("Got message: %@", client: self, args: message)
|
||||
|
||||
if fromPolling {
|
||||
fixDoubleUTF8(&message)
|
||||
}
|
||||
|
||||
let type = PacketType(str: (message["^(\\d)"].groups()?[1]))
|
||||
let type = PacketType(str: (message["^(\\d)"].groups()?[1])) ?? {
|
||||
self.checkIfMessageIsBase64Binary(message)
|
||||
return PacketType.NOOP
|
||||
}()
|
||||
|
||||
if type == PacketType.MESSAGE {
|
||||
// Remove message type
|
||||
switch type {
|
||||
case PacketType.MESSAGE:
|
||||
message.removeAtIndex(message.startIndex)
|
||||
|
||||
if let client = self.client {
|
||||
dispatch_async(client.handleQueue) {[weak self] in
|
||||
self?.client?.parseSocketMessage(message)
|
||||
}
|
||||
}
|
||||
} else if type == PacketType.NOOP {
|
||||
self.doPoll()
|
||||
} else if type == PacketType.PONG {
|
||||
// We should upgrade
|
||||
if message == "3probe" {
|
||||
self.upgradeTransport()
|
||||
}
|
||||
} else if type == PacketType.OPEN {
|
||||
var err:NSError?
|
||||
|
||||
handleMessage(message)
|
||||
case PacketType.NOOP:
|
||||
handleNOOP()
|
||||
case PacketType.PONG:
|
||||
handlePong(message)
|
||||
case PacketType.OPEN:
|
||||
message.removeAtIndex(message.startIndex)
|
||||
let mesData = message.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
|
||||
|
||||
if let json = NSJSONSerialization.JSONObjectWithData(mesData,
|
||||
options: NSJSONReadingOptions.AllowFragments,
|
||||
error: &err) as? NSDictionary, let sid = json["sid"] as? String {
|
||||
self.sid = sid
|
||||
self._connected = true
|
||||
|
||||
if !self.forcePolling && !self.forceWebsockets {
|
||||
self.createWebsocket(andConnect: true)
|
||||
}
|
||||
|
||||
if let pingInterval = json["pingInterval"] as? Int {
|
||||
self.pingInterval = pingInterval / 1000
|
||||
}
|
||||
} else {
|
||||
self.client?.didError("Engine failed to handshake")
|
||||
return
|
||||
}
|
||||
|
||||
self.startPingTimer()
|
||||
|
||||
if !self.forceWebsockets {
|
||||
self.doPoll()
|
||||
}
|
||||
} else if type == PacketType.CLOSE {
|
||||
if self.client == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if self.polling {
|
||||
self.client!.engineDidClose("Disconnect")
|
||||
}
|
||||
} else if message.hasPrefix("b4") {
|
||||
// binary in base64 string
|
||||
message.removeRange(Range<String.Index>(start: message.startIndex,
|
||||
end: advance(message.startIndex, 2)))
|
||||
|
||||
if let data = NSData(base64EncodedString: message,
|
||||
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters), client = self.client {
|
||||
dispatch_async(client.handleQueue) {[weak self] in
|
||||
self?.client?.parseBinaryData(data)
|
||||
}
|
||||
}
|
||||
handleOpen(message)
|
||||
case PacketType.CLOSE:
|
||||
handleClose()
|
||||
default:
|
||||
SocketLogger.log("Got unknown packet type", client: self)
|
||||
}
|
||||
}
|
||||
|
||||
private func probeWebSocket() {
|
||||
if self.websocketConnected {
|
||||
self.sendWebSocketMessage("probe", withType: PacketType.PING)
|
||||
if websocketConnected {
|
||||
sendWebSocketMessage("probe", withType: PacketType.PING)
|
||||
}
|
||||
}
|
||||
|
||||
/// Send an engine message (4)
|
||||
public func send(msg:String, withData datas:ContiguousArray<NSData>?) {
|
||||
if self.probing {
|
||||
self.probeWait.append((msg, PacketType.MESSAGE, datas))
|
||||
if probing {
|
||||
probeWait.append((msg, PacketType.MESSAGE, datas))
|
||||
} else {
|
||||
self.write(msg, withType: PacketType.MESSAGE, withData: datas)
|
||||
write(msg, withType: PacketType.MESSAGE, withData: datas)
|
||||
}
|
||||
}
|
||||
|
||||
func sendPing() {
|
||||
self.write("", withType: PacketType.PING, withData: nil)
|
||||
@objc private func sendPing() {
|
||||
//Server is not responding
|
||||
if pongsMissed > pongsMissedMax {
|
||||
pingTimer?.invalidate()
|
||||
client?.engineDidClose("Ping timeout")
|
||||
return
|
||||
}
|
||||
|
||||
++pongsMissed
|
||||
write("", withType: PacketType.PING, withData: nil)
|
||||
}
|
||||
|
||||
/// Send polling message.
|
||||
/// Only call on emitQueue
|
||||
private func sendPollMessage(var msg:String, withType type:PacketType,
|
||||
datas:ContiguousArray<NSData>? = nil) {
|
||||
SocketLogger.log("Sending poll: \(msg) as type: \(type.rawValue)", client: self)
|
||||
SocketLogger.log("Sending poll: %@ as type: %@", client: self, args: msg, type.rawValue)
|
||||
|
||||
doubleEncodeUTF8(&msg)
|
||||
let strMsg = "\(type.rawValue)\(msg)"
|
||||
|
||||
self.postWait.append(strMsg)
|
||||
postWait.append(strMsg)
|
||||
|
||||
if datas != nil {
|
||||
for data in datas! {
|
||||
let (nilData, b64Data) = self.createBinaryDataForSend(data)
|
||||
let (nilData, b64Data) = createBinaryDataForSend(data)
|
||||
|
||||
self.postWait.append(b64Data!)
|
||||
postWait.append(b64Data!)
|
||||
}
|
||||
}
|
||||
|
||||
if !self.waitingForPost {
|
||||
self.flushWaitingForPost()
|
||||
if !waitingForPost {
|
||||
flushWaitingForPost()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,15 +650,15 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
/// Only call on emitQueue
|
||||
private func sendWebSocketMessage(str:String, withType type:PacketType,
|
||||
datas:ContiguousArray<NSData>? = nil) {
|
||||
SocketLogger.log("Sending ws: \(str) as type: \(type.rawValue)", client: self)
|
||||
SocketLogger.log("Sending ws: %@ as type: %@", client: self, args: str, type.rawValue)
|
||||
|
||||
self.ws?.writeString("\(type.rawValue)\(str)")
|
||||
ws?.writeString("\(type.rawValue)\(str)")
|
||||
|
||||
if datas != nil {
|
||||
for data in datas! {
|
||||
let (data, nilString) = self.createBinaryDataForSend(data)
|
||||
let (data, nilString) = createBinaryDataForSend(data)
|
||||
if data != nil {
|
||||
self.ws?.writeData(data!)
|
||||
ws?.writeData(data!)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -613,32 +666,30 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
|
||||
// Starts the ping timer
|
||||
private func startPingTimer() {
|
||||
if self.pingInterval == nil {
|
||||
if pingInterval == nil {
|
||||
return
|
||||
}
|
||||
|
||||
self.pingTimer?.invalidate()
|
||||
pingTimer?.invalidate()
|
||||
dispatch_async(dispatch_get_main_queue()) {[weak self] in
|
||||
if let this = self {
|
||||
this.pingTimer = NSTimer.scheduledTimerWithTimeInterval(NSTimeInterval(this.pingInterval!),
|
||||
target: this,
|
||||
this.pingTimer = NSTimer.scheduledTimerWithTimeInterval(this.pingInterval!, target: this,
|
||||
selector: Selector("sendPing"), userInfo: nil, repeats: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func stopPolling() {
|
||||
self.session.invalidateAndCancel()
|
||||
session.invalidateAndCancel()
|
||||
}
|
||||
|
||||
private func upgradeTransport() {
|
||||
if self.websocketConnected {
|
||||
if websocketConnected {
|
||||
SocketLogger.log("Upgrading transport to WebSockets", client: self)
|
||||
|
||||
// Do a fast upgrade
|
||||
// At this point, we should not send anymore polling messages-
|
||||
self.fastUpgrade = true
|
||||
self.sendPollMessage("", withType: PacketType.NOOP)
|
||||
fastUpgrade = true
|
||||
sendPollMessage("", withType: PacketType.NOOP)
|
||||
// After this point, we should not send anymore polling messages
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,13 +697,15 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
Write a message, independent of transport.
|
||||
*/
|
||||
public func write(msg:String, withType type:PacketType, withData data:ContiguousArray<NSData>?) {
|
||||
dispatch_async(self.emitQueue) {[weak self] in
|
||||
dispatch_async(emitQueue) {[weak self] in
|
||||
if let this = self where this.connected {
|
||||
if this.websocket {
|
||||
SocketLogger.log("Writing ws: \(msg):\(data)", client: this)
|
||||
SocketLogger.log("Writing ws: %@ has data: %@", client: this,
|
||||
args: msg, data == nil ? false : true)
|
||||
this.sendWebSocketMessage(msg, withType: type, datas: data)
|
||||
} else {
|
||||
SocketLogger.log("Writing poll: \(msg):\(data)", client: this)
|
||||
SocketLogger.log("Writing poll: %@ has data: %@", client: this,
|
||||
args: msg, data == nil ? false : true)
|
||||
this.sendPollMessage(msg, withType: type, datas: data)
|
||||
}
|
||||
}
|
||||
@@ -672,56 +725,56 @@ public final class SocketEngine: NSObject, WebSocketDelegate, SocketLogClient {
|
||||
}
|
||||
}
|
||||
|
||||
self.write(msg, withType: pType, withData: arr)
|
||||
write(msg, withType: pType, withData: arr)
|
||||
}
|
||||
}
|
||||
|
||||
// Delagate methods
|
||||
|
||||
public func websocketDidConnect(socket:WebSocket) {
|
||||
self.websocketConnected = true
|
||||
websocketConnected = true
|
||||
|
||||
if !self.forceWebsockets {
|
||||
self.probing = true
|
||||
self.probeWebSocket()
|
||||
if !forceWebsockets {
|
||||
probing = true
|
||||
probeWebSocket()
|
||||
} else {
|
||||
self._connected = true
|
||||
self.probing = false
|
||||
self._polling = false
|
||||
_connected = true
|
||||
probing = false
|
||||
_polling = false
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidDisconnect(socket:WebSocket, error:NSError?) {
|
||||
self.websocketConnected = false
|
||||
self.probing = false
|
||||
websocketConnected = false
|
||||
probing = false
|
||||
|
||||
if self.closed {
|
||||
self.client?.engineDidClose("Disconnect")
|
||||
if closed {
|
||||
client?.engineDidClose("Disconnect")
|
||||
return
|
||||
}
|
||||
|
||||
if self.websocket {
|
||||
self.pingTimer?.invalidate()
|
||||
self._connected = false
|
||||
self._websocket = false
|
||||
if websocket {
|
||||
pingTimer?.invalidate()
|
||||
_connected = false
|
||||
_websocket = false
|
||||
|
||||
let reason = error?.localizedDescription ?? "Socket Disconnected"
|
||||
|
||||
if error != nil {
|
||||
self.client?.didError(reason)
|
||||
client?.didError(reason)
|
||||
}
|
||||
|
||||
self.client?.engineDidClose(reason)
|
||||
client?.engineDidClose(reason)
|
||||
} else {
|
||||
self.flushProbeWait()
|
||||
flushProbeWait()
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidReceiveMessage(socket:WebSocket, text:String) {
|
||||
self.parseEngineMessage(text, fromPolling: false)
|
||||
parseEngineMessage(text, fromPolling: false)
|
||||
}
|
||||
|
||||
public func websocketDidReceiveData(socket:WebSocket, data:NSData) {
|
||||
self.parseEngineData(data)
|
||||
parseEngineData(data)
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,6 @@ import Foundation
|
||||
|
||||
@objc public protocol SocketEngineClient {
|
||||
var handleQueue:dispatch_queue_attr_t! {get}
|
||||
var emitQueue:dispatch_queue_attr_t! {get}
|
||||
var socketURL:String {get}
|
||||
var secure:Bool {get}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
import Foundation
|
||||
|
||||
private func emitAckCallback(socket:SocketIOClient, num:Int)
|
||||
// Curried
|
||||
(items:AnyObject...) -> Void {
|
||||
socket.emitAck(num, withData: items)
|
||||
}
|
||||
|
||||
@@ -31,9 +31,8 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
private var _connecting = false
|
||||
private var currentReconnectAttempt = 0
|
||||
private var handlers = ContiguousArray<SocketEventHandler>()
|
||||
private var params:[String: AnyObject]?
|
||||
private var connectParams:[String: AnyObject]?
|
||||
private var _secure = false
|
||||
private var _sid:String?
|
||||
private var _reconnecting = false
|
||||
private var reconnectTimer:NSTimer?
|
||||
|
||||
@@ -50,27 +49,27 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
public let handleQueue = dispatch_queue_create("handleQueue", DISPATCH_QUEUE_SERIAL)
|
||||
public let emitQueue = dispatch_queue_create("emitQueue", DISPATCH_QUEUE_SERIAL)
|
||||
public var closed:Bool {
|
||||
return self._closed
|
||||
return _closed
|
||||
}
|
||||
public var connected:Bool {
|
||||
return self._connected
|
||||
return _connected
|
||||
}
|
||||
public var connecting:Bool {
|
||||
return self._connecting
|
||||
return _connecting
|
||||
}
|
||||
public var engine:SocketEngine?
|
||||
public var nsp = "/"
|
||||
public var opts:[String: AnyObject]?
|
||||
public var reconnects = true
|
||||
public var reconnecting:Bool {
|
||||
return self._reconnecting
|
||||
return _reconnecting
|
||||
}
|
||||
public var reconnectWait = 10
|
||||
public var secure:Bool {
|
||||
return self._secure
|
||||
return _secure
|
||||
}
|
||||
public var sid:String? {
|
||||
return self._sid
|
||||
return engine?.sid
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,14 +86,13 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
self.socketURL = socketURL
|
||||
self.opts = opts
|
||||
|
||||
|
||||
// Set options
|
||||
if let sessionDelegate = opts?["sessionDelegate"] as? NSURLSessionDelegate {
|
||||
self.sessionDelegate = sessionDelegate
|
||||
}
|
||||
|
||||
if let connectParams = opts?["connectParams"] as? [String: AnyObject] {
|
||||
self.params = connectParams
|
||||
self.connectParams = connectParams
|
||||
}
|
||||
|
||||
if let log = opts?["log"] as? Bool {
|
||||
@@ -132,12 +130,18 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
|
||||
deinit {
|
||||
SocketLogger.log("Client is being deinit", client: self)
|
||||
engine?.close(fast: true)
|
||||
}
|
||||
|
||||
private func addEngine() {
|
||||
SocketLogger.log("Adding engine", client: self)
|
||||
|
||||
self.engine = SocketEngine(client: self, opts: self.opts)
|
||||
engine = SocketEngine(client: self, opts: opts)
|
||||
}
|
||||
|
||||
private func clearReconnectTimer() {
|
||||
reconnectTimer?.invalidate()
|
||||
reconnectTimer = nil
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,34 +152,35 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
public func close(#fast:Bool) {
|
||||
SocketLogger.log("Closing socket", client: self)
|
||||
|
||||
self.reconnects = false
|
||||
self._connecting = false
|
||||
self._connected = false
|
||||
self._reconnecting = false
|
||||
self.engine?.close(fast: fast)
|
||||
self.engine = nil
|
||||
reconnects = false
|
||||
_connecting = false
|
||||
_connected = false
|
||||
_reconnecting = false
|
||||
engine?.close(fast: fast)
|
||||
engine = nil
|
||||
}
|
||||
|
||||
/**
|
||||
Connect to the server.
|
||||
*/
|
||||
public func connect() {
|
||||
self.connect(timeoutAfter: 0, withTimeoutHandler: nil)
|
||||
connect(timeoutAfter: 0, withTimeoutHandler: nil)
|
||||
}
|
||||
|
||||
/**
|
||||
Connect to the server. If we aren't connected after timeoutAfter, call handler
|
||||
*/
|
||||
public func connect(#timeoutAfter:Int, withTimeoutHandler handler:(() -> Void)?) {
|
||||
if self.closed {
|
||||
if closed {
|
||||
SocketLogger.log("Warning! This socket was previously closed. This might be dangerous!", client: self)
|
||||
self._closed = false
|
||||
} else if self.connected {
|
||||
_closed = false
|
||||
} else if connected {
|
||||
return
|
||||
}
|
||||
|
||||
self.addEngine()
|
||||
self.engine?.open(opts: self.params)
|
||||
_connecting = true
|
||||
addEngine()
|
||||
engine?.open(opts: connectParams)
|
||||
|
||||
if timeoutAfter == 0 {
|
||||
return
|
||||
@@ -195,7 +200,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
}
|
||||
|
||||
private func createOnAck(event:String, items:[AnyObject]) -> OnAckCallback {
|
||||
return {[weak self, ack = ++self.currentAck] timeout, callback in
|
||||
return {[weak self, ack = ++currentAck] timeout, callback in
|
||||
if let this = self {
|
||||
this.ackHandlers.addAck(ack, callback: callback)
|
||||
|
||||
@@ -217,43 +222,41 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
func didConnect() {
|
||||
SocketLogger.log("Socket connected", client: self)
|
||||
|
||||
self._closed = false
|
||||
self._connected = true
|
||||
self._connecting = false
|
||||
self._reconnecting = false
|
||||
self.currentReconnectAttempt = 0
|
||||
self.reconnectTimer?.invalidate()
|
||||
self.reconnectTimer = nil
|
||||
self._sid = self.engine?.sid
|
||||
_closed = false
|
||||
_connected = true
|
||||
_connecting = false
|
||||
_reconnecting = false
|
||||
currentReconnectAttempt = 0
|
||||
clearReconnectTimer()
|
||||
|
||||
// Don't handle as internal because something crazy could happen where
|
||||
// we disconnect before it's handled
|
||||
self.handleEvent("connect", data: nil, isInternalMessage: false)
|
||||
handleEvent("connect", data: nil, isInternalMessage: false)
|
||||
}
|
||||
|
||||
func didDisconnect(reason:String) {
|
||||
if self.closed {
|
||||
if closed {
|
||||
return
|
||||
}
|
||||
|
||||
SocketLogger.log("Disconnected: \(reason)", client: self)
|
||||
SocketLogger.log("Disconnected: %@", client: self, args: reason)
|
||||
|
||||
self._closed = true
|
||||
self._connected = false
|
||||
self.reconnects = false
|
||||
self._connecting = false
|
||||
self._reconnecting = false
|
||||
_closed = true
|
||||
_connected = false
|
||||
reconnects = false
|
||||
_connecting = false
|
||||
_reconnecting = false
|
||||
|
||||
// Make sure the engine is actually dead.
|
||||
self.engine?.close(fast: true)
|
||||
self.handleEvent("disconnect", data: [reason], isInternalMessage: true)
|
||||
engine?.close(fast: true)
|
||||
handleEvent("disconnect", data: [reason], isInternalMessage: true)
|
||||
}
|
||||
|
||||
/// error
|
||||
public func didError(reason:AnyObject) {
|
||||
SocketLogger.err("Error: \(reason)", client: self)
|
||||
SocketLogger.err("%@", client: self, args: reason)
|
||||
|
||||
self.handleEvent("error", data: reason as? [AnyObject] ?? [reason],
|
||||
handleEvent("error", data: reason as? [AnyObject] ?? [reason],
|
||||
isInternalMessage: true)
|
||||
}
|
||||
|
||||
@@ -261,18 +264,18 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
Same as close
|
||||
*/
|
||||
public func disconnect(#fast:Bool) {
|
||||
self.close(fast: fast)
|
||||
close(fast: fast)
|
||||
}
|
||||
|
||||
/**
|
||||
Send a message to the server
|
||||
*/
|
||||
public func emit(event:String, _ items:AnyObject...) {
|
||||
if !self.connected {
|
||||
if !connected {
|
||||
return
|
||||
}
|
||||
|
||||
dispatch_async(self.emitQueue) {[weak self] in
|
||||
dispatch_async(emitQueue) {[weak self] in
|
||||
self?._emit(event, items)
|
||||
}
|
||||
}
|
||||
@@ -281,11 +284,11 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
Same as emit, but meant for Objective-C
|
||||
*/
|
||||
public func emit(event:String, withItems items:[AnyObject]) {
|
||||
if !self.connected {
|
||||
if !connected {
|
||||
return
|
||||
}
|
||||
|
||||
dispatch_async(self.emitQueue) {[weak self] in
|
||||
dispatch_async(emitQueue) {[weak self] in
|
||||
self?._emit(event, items)
|
||||
}
|
||||
}
|
||||
@@ -295,47 +298,47 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
an ack.
|
||||
*/
|
||||
public func emitWithAck(event:String, _ items:AnyObject...) -> OnAckCallback {
|
||||
if !self.connected {
|
||||
if !connected {
|
||||
return createOnAck(event, items: items)
|
||||
}
|
||||
|
||||
return self.createOnAck(event, items: items)
|
||||
return createOnAck(event, items: items)
|
||||
}
|
||||
|
||||
/**
|
||||
Same as emitWithAck, but for Objective-C
|
||||
*/
|
||||
public func emitWithAck(event:String, withItems items:[AnyObject]) -> OnAckCallback {
|
||||
if !self.connected {
|
||||
return self.createOnAck(event, items: items)
|
||||
if !connected {
|
||||
return createOnAck(event, items: items)
|
||||
}
|
||||
|
||||
return self.createOnAck(event, items: items)
|
||||
return createOnAck(event, items: items)
|
||||
}
|
||||
|
||||
private func _emit(event:String, _ args:[AnyObject], ack:Int? = nil) {
|
||||
if !self.connected {
|
||||
if !connected {
|
||||
return
|
||||
}
|
||||
|
||||
let packet = SocketPacket(type: nil, data: args, nsp: self.nsp, id: ack)
|
||||
let packet = SocketPacket(type: nil, data: args, nsp: nsp, id: ack)
|
||||
let str:String
|
||||
|
||||
SocketParser.parseForEmit(packet)
|
||||
str = packet.createMessageForEvent(event)
|
||||
|
||||
SocketLogger.log("Emitting: \(str)", client: self)
|
||||
SocketLogger.log("Emitting: %@", client: self, args: str)
|
||||
|
||||
if packet.type == SocketPacket.PacketType.BINARY_EVENT {
|
||||
self.engine?.send(str, withData: packet.binary)
|
||||
engine?.send(str, withData: packet.binary)
|
||||
} else {
|
||||
self.engine?.send(str, withData: nil)
|
||||
engine?.send(str, withData: nil)
|
||||
}
|
||||
}
|
||||
|
||||
// If the server wants to know that the client received data
|
||||
func emitAck(ack:Int, withData args:[AnyObject]) {
|
||||
dispatch_async(self.emitQueue) {[weak self] in
|
||||
dispatch_async(emitQueue) {[weak self] in
|
||||
if let this = self where this.connected {
|
||||
let packet = SocketPacket(type: nil, data: args, nsp: this.nsp, id: ack)
|
||||
let str:String
|
||||
@@ -343,7 +346,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
SocketParser.parseForEmit(packet)
|
||||
str = packet.createAck()
|
||||
|
||||
SocketLogger.log("Emitting Ack: \(str)", client: this)
|
||||
SocketLogger.log("Emitting Ack: %@", client: this, args: str)
|
||||
|
||||
if packet.type == SocketPacket.PacketType.BINARY_ACK {
|
||||
this.engine?.send(str, withData: packet.binary)
|
||||
@@ -356,22 +359,23 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
}
|
||||
|
||||
public func engineDidClose(reason:String) {
|
||||
self._connected = false
|
||||
self._connecting = false
|
||||
_connected = false
|
||||
_connecting = false
|
||||
|
||||
if self.closed || !self.reconnects {
|
||||
self.didDisconnect("Engine closed")
|
||||
} else if !self.reconnecting {
|
||||
self.handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
||||
self.tryReconnect()
|
||||
if closed || !reconnects {
|
||||
didDisconnect(reason)
|
||||
} else if !reconnecting {
|
||||
handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
||||
tryReconnect()
|
||||
}
|
||||
}
|
||||
|
||||
// Called when the socket gets an ack for something it sent
|
||||
func handleAck(ack:Int, data:AnyObject?) {
|
||||
SocketLogger.log("Handling ack: \(ack) with data: \(data)", client: self)
|
||||
SocketLogger.log("Handling ack: %@ with data: %@", client: self,
|
||||
args: ack, data ?? "")
|
||||
|
||||
self.ackHandlers.executeAck(ack,
|
||||
ackHandlers.executeAck(ack,
|
||||
items: (data as? [AnyObject]?) ?? (data != nil ? [data!] : nil))
|
||||
}
|
||||
|
||||
@@ -381,19 +385,20 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
public func handleEvent(event:String, data:[AnyObject]?, isInternalMessage:Bool = false,
|
||||
wantsAck ack:Int? = nil) {
|
||||
// println("Should do event: \(event) with data: \(data)")
|
||||
if !self.connected && !isInternalMessage {
|
||||
if !connected && !isInternalMessage {
|
||||
return
|
||||
}
|
||||
|
||||
SocketLogger.log("Handling event: \(event) with data: \(data)", client: self)
|
||||
SocketLogger.log("Handling event: %@ with data: %@", client: self,
|
||||
args: event, data ?? "")
|
||||
|
||||
if self.anyHandler != nil {
|
||||
if anyHandler != nil {
|
||||
dispatch_async(dispatch_get_main_queue()) {[weak self] in
|
||||
self?.anyHandler?(SocketAnyEvent(event: event, items: data))
|
||||
}
|
||||
}
|
||||
|
||||
for handler in self.handlers {
|
||||
for handler in handlers {
|
||||
if handler.event == event {
|
||||
if ack != nil {
|
||||
handler.executeCallback(data, withAck: ack!, withSocket: self)
|
||||
@@ -404,11 +409,24 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
}
|
||||
}
|
||||
|
||||
func joinNamespace() {
|
||||
/**
|
||||
Leaves nsp and goes back to /
|
||||
*/
|
||||
public func leaveNamespace() {
|
||||
if nsp != "/" {
|
||||
engine?.send("1/\(nsp)", withData: nil)
|
||||
nsp = "/"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Joins nsp if it is not /
|
||||
*/
|
||||
public func joinNamespace() {
|
||||
SocketLogger.log("Joining namespace", client: self)
|
||||
|
||||
if self.nsp != "/" {
|
||||
self.engine?.send("0/\(self.nsp)", withData: nil)
|
||||
if nsp != "/" {
|
||||
engine?.send("0/\(nsp)", withData: nil)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,33 +434,41 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
Removes handler(s)
|
||||
*/
|
||||
public func off(event:String) {
|
||||
SocketLogger.log("Removing handler for event: \(event)", client: self)
|
||||
SocketLogger.log("Removing handler for event: %@", client: self, args: event)
|
||||
|
||||
self.handlers = self.handlers.filter {$0.event == event ? false : true}
|
||||
handlers = handlers.filter {$0.event == event ? false : true}
|
||||
}
|
||||
|
||||
/**
|
||||
Adds a handler for an event.
|
||||
*/
|
||||
public func on(name:String, callback:NormalCallback) {
|
||||
SocketLogger.log("Adding handler for event: \(name)", client: self)
|
||||
public func on(event:String, callback:NormalCallback) {
|
||||
SocketLogger.log("Adding handler for event: %@", client: self, args: event)
|
||||
|
||||
let handler = SocketEventHandler(event: name, callback: callback)
|
||||
self.handlers.append(handler)
|
||||
let handler = SocketEventHandler(event: event, callback: callback)
|
||||
handlers.append(handler)
|
||||
}
|
||||
|
||||
/**
|
||||
Removes all handlers.
|
||||
Can be used after disconnecting to break any potential remaining retain cycles.
|
||||
*/
|
||||
public func removeAllHandlers() {
|
||||
handlers.removeAll(keepCapacity: false)
|
||||
}
|
||||
|
||||
/**
|
||||
Adds a handler that will be called on every event.
|
||||
*/
|
||||
public func onAny(handler:(SocketAnyEvent) -> Void) {
|
||||
self.anyHandler = handler
|
||||
anyHandler = handler
|
||||
}
|
||||
|
||||
/**
|
||||
Same as connect
|
||||
*/
|
||||
public func open() {
|
||||
self.connect()
|
||||
connect()
|
||||
}
|
||||
|
||||
public func parseSocketMessage(msg:String) {
|
||||
@@ -457,29 +483,31 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
Trieds to reconnect to the server.
|
||||
*/
|
||||
public func reconnect() {
|
||||
self._connected = false
|
||||
self._connecting = false
|
||||
self._reconnecting = false
|
||||
_connected = false
|
||||
_connecting = false
|
||||
_reconnecting = false
|
||||
|
||||
self.engine?.stopPolling()
|
||||
self.tryReconnect()
|
||||
engine?.stopPolling()
|
||||
tryReconnect()
|
||||
}
|
||||
|
||||
// We lost connection and should attempt to reestablish
|
||||
@objc private func tryReconnect() {
|
||||
if self.reconnectAttempts != -1 && self.currentReconnectAttempt + 1 > self.reconnectAttempts {
|
||||
self.didDisconnect("Reconnect Failed")
|
||||
if reconnectAttempts != -1 && currentReconnectAttempt + 1 > reconnectAttempts || !reconnects {
|
||||
clearReconnectTimer()
|
||||
didDisconnect("Reconnect Failed")
|
||||
|
||||
return
|
||||
} else if self.connected {
|
||||
self._connecting = false
|
||||
self._reconnecting = false
|
||||
} else if connected {
|
||||
_connecting = false
|
||||
_reconnecting = false
|
||||
return
|
||||
}
|
||||
|
||||
if self.reconnectTimer == nil {
|
||||
if reconnectTimer == nil {
|
||||
SocketLogger.log("Starting reconnect", client: self)
|
||||
|
||||
self._reconnecting = true
|
||||
_reconnecting = true
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {[weak self] in
|
||||
if let this = self {
|
||||
@@ -490,10 +518,10 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketLogClient
|
||||
}
|
||||
|
||||
SocketLogger.log("Trying to reconnect", client: self)
|
||||
self.handleEvent("reconnectAttempt", data: [self.reconnectAttempts - self.currentReconnectAttempt],
|
||||
handleEvent("reconnectAttempt", data: [reconnectAttempts - currentReconnectAttempt],
|
||||
isInternalMessage: true)
|
||||
|
||||
self.currentReconnectAttempt++
|
||||
self.connect()
|
||||
currentReconnectAttempt++
|
||||
connect()
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,8 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
private let MESSAGE_LENGTH_MAX = 10000
|
||||
|
||||
protocol SocketLogClient {
|
||||
var log:Bool {get set}
|
||||
var logType:String {get}
|
||||
@@ -32,23 +34,41 @@ protocol SocketLogClient {
|
||||
final class SocketLogger {
|
||||
private static let printQueue = dispatch_queue_create("printQueue", DISPATCH_QUEUE_SERIAL)
|
||||
|
||||
static func log(message:String, client:SocketLogClient, altType:String? = nil) {
|
||||
private static func shorten(item:AnyObject) -> CVarArgType {
|
||||
var str = toString(item)
|
||||
|
||||
if count(str) > MESSAGE_LENGTH_MAX {
|
||||
let endIndex = advance(str.startIndex, MESSAGE_LENGTH_MAX)
|
||||
|
||||
str = str.substringToIndex(endIndex)
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
static func log(message:String, client:SocketLogClient, altType:String? = nil, args:AnyObject...) {
|
||||
if !client.log {
|
||||
return
|
||||
}
|
||||
|
||||
dispatch_async(printQueue) {[type = client.logType] in
|
||||
NSLog("%@: %@", altType ?? type, message)
|
||||
let newArgs = args.map(SocketLogger.shorten)
|
||||
let replaced = String(format: message, arguments: newArgs)
|
||||
|
||||
NSLog("%@: %@", altType ?? type, replaced)
|
||||
}
|
||||
}
|
||||
|
||||
static func err(message:String, client:SocketLogClient, altType:String? = nil) {
|
||||
static func err(message:String, client:SocketLogClient, altType:String? = nil, args:AnyObject...) {
|
||||
if !client.log {
|
||||
return
|
||||
}
|
||||
|
||||
dispatch_async(printQueue) {[type = client.logType] in
|
||||
NSLog("ERROR %@: %@", altType ?? type, message)
|
||||
let newArgs = args.map(SocketLogger.shorten)
|
||||
let replaced = String(format: message, arguments: newArgs)
|
||||
|
||||
NSLog("ERROR %@: %@", altType ?? type, replaced)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,10 +32,10 @@ final class SocketPacket: Printable {
|
||||
var better = "SocketPacket {type: ~~0; data: ~~1; " +
|
||||
"id: ~~2; placeholders: ~~3;}"
|
||||
|
||||
better = better["~~0"] ~= (self.type != nil ? String(self.type!.rawValue) : "nil")
|
||||
better = better["~~1"] ~= (self.data != nil ? "\(self.data!)" : "nil")
|
||||
better = better["~~2"] ~= (self.id != nil ? String(self.id!) : "nil")
|
||||
better = better["~~3"] ~= (self.placeholders != nil ? String(self.placeholders!) : "nil")
|
||||
better = better["~~0"] ~= (type != nil ? String(type!.rawValue) : "nil")
|
||||
better = better["~~1"] ~= (data != nil ? "\(data!)" : "nil")
|
||||
better = better["~~2"] ~= (id != nil ? String(id!) : "nil")
|
||||
better = better["~~3"] ~= (placeholders != nil ? String(placeholders!) : "nil")
|
||||
|
||||
return better
|
||||
}
|
||||
@@ -77,15 +77,15 @@ final class SocketPacket: Printable {
|
||||
}
|
||||
|
||||
func addData(data:NSData) -> Bool {
|
||||
if self.placeholders == self.currentPlace {
|
||||
if placeholders == currentPlace {
|
||||
return true
|
||||
}
|
||||
|
||||
self.binary.append(data)
|
||||
self.currentPlace++
|
||||
binary.append(data)
|
||||
currentPlace++
|
||||
|
||||
if self.placeholders == self.currentPlace {
|
||||
self.currentPlace = 0
|
||||
if placeholders == currentPlace {
|
||||
currentPlace = 0
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -95,85 +95,88 @@ final class SocketPacket: Printable {
|
||||
func createMessageForEvent(event:String) -> String {
|
||||
let message:String
|
||||
|
||||
if self.binary.count == 0 {
|
||||
self.type = PacketType.EVENT
|
||||
if binary.count == 0 {
|
||||
type = PacketType.EVENT
|
||||
|
||||
if self.nsp == "/" {
|
||||
if self.id == nil {
|
||||
if nsp == "/" {
|
||||
if id == nil {
|
||||
message = "2[\"\(event)\""
|
||||
} else {
|
||||
message = "2\(self.id!)[\"\(event)\""
|
||||
message = "2\(id!)[\"\(event)\""
|
||||
}
|
||||
} else {
|
||||
if self.id == nil {
|
||||
message = "2/\(self.nsp),[\"\(event)\""
|
||||
if id == nil {
|
||||
message = "2/\(nsp),[\"\(event)\""
|
||||
} else {
|
||||
message = "2/\(self.nsp),\(self.id!)[\"\(event)\""
|
||||
message = "2/\(nsp),\(id!)[\"\(event)\""
|
||||
}
|
||||
}
|
||||
} else {
|
||||
self.type = PacketType.BINARY_EVENT
|
||||
type = PacketType.BINARY_EVENT
|
||||
|
||||
if self.nsp == "/" {
|
||||
if self.id == nil {
|
||||
message = "5\(self.binary.count)-[\"\(event)\""
|
||||
if nsp == "/" {
|
||||
if id == nil {
|
||||
message = "5\(binary.count)-[\"\(event)\""
|
||||
} else {
|
||||
message = "5\(self.binary.count)-\(self.id!)[\"\(event)\""
|
||||
message = "5\(binary.count)-\(id!)[\"\(event)\""
|
||||
}
|
||||
} else {
|
||||
if self.id == nil {
|
||||
message = "5\(self.binary.count)-/\(self.nsp),[\"\(event)\""
|
||||
if id == nil {
|
||||
message = "5\(binary.count)-/\(nsp),[\"\(event)\""
|
||||
} else {
|
||||
message = "5\(self.binary.count)-/\(self.nsp),\(self.id!)[\"\(event)\""
|
||||
message = "5\(binary.count)-/\(nsp),\(id!)[\"\(event)\""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return self.completeMessage(message)
|
||||
return completeMessage(message)
|
||||
}
|
||||
|
||||
func createAck() -> String {
|
||||
var msg:String
|
||||
|
||||
if self.binary.count == 0 {
|
||||
self.type = PacketType.ACK
|
||||
if binary.count == 0 {
|
||||
type = PacketType.ACK
|
||||
|
||||
if nsp == "/" {
|
||||
msg = "3\(self.id!)["
|
||||
msg = "3\(id!)["
|
||||
} else {
|
||||
msg = "3/\(self.nsp),\(self.id!)["
|
||||
msg = "3/\(nsp),\(id!)["
|
||||
}
|
||||
} else {
|
||||
self.type = PacketType.BINARY_ACK
|
||||
type = PacketType.BINARY_ACK
|
||||
|
||||
if nsp == "/" {
|
||||
msg = "6\(self.binary.count)-\(self.id!)["
|
||||
msg = "6\(binary.count)-\(id!)["
|
||||
} else {
|
||||
msg = "6\(self.binary.count)-/\(self.nsp),\(self.id!)["
|
||||
msg = "6\(binary.count)-/\(nsp),\(id!)["
|
||||
}
|
||||
}
|
||||
|
||||
return self.completeMessage(msg, ack: true)
|
||||
return completeMessage(msg, ack: true)
|
||||
}
|
||||
|
||||
private func completeMessage(var message:String, ack:Bool = false) -> String {
|
||||
var err:NSError?
|
||||
|
||||
if self.data == nil || self.data!.count == 0 {
|
||||
if data == nil || data!.count == 0 {
|
||||
return message + "]"
|
||||
} else if !ack {
|
||||
message += ","
|
||||
}
|
||||
|
||||
for arg in self.data! {
|
||||
for arg in data! {
|
||||
if arg is NSDictionary || arg is [AnyObject] {
|
||||
let jsonSend = NSJSONSerialization.dataWithJSONObject(arg,
|
||||
options: NSJSONWritingOptions(0), error: &err)
|
||||
let jsonString = NSString(data: jsonSend!, encoding: NSUTF8StringEncoding)
|
||||
|
||||
message += jsonString! as String + ","
|
||||
} else if arg is String {
|
||||
message += "\"\(arg)\","
|
||||
} else if var str = arg as? String {
|
||||
str = str["\n"] ~= "\\\\n"
|
||||
str = str["\r"] ~= "\\\\r"
|
||||
|
||||
message += "\"\(str)\","
|
||||
} else if arg is NSNull {
|
||||
message += "null,"
|
||||
} else {
|
||||
@@ -189,23 +192,23 @@ final class SocketPacket: Printable {
|
||||
}
|
||||
|
||||
func fillInPlaceholders() {
|
||||
var newArr = NSMutableArray(array: self.data!)
|
||||
var newArr = NSMutableArray(array: data!)
|
||||
|
||||
for i in 0..<self.data!.count {
|
||||
if let str = self.data?[i] as? String, num = str["~~(\\d)"].groups() {
|
||||
newArr[i] = self.binary[num[1].toInt()!]
|
||||
} else if self.data?[i] is NSDictionary || self.data?[i] is NSArray {
|
||||
newArr[i] = self._fillInPlaceholders(self.data![i])
|
||||
for i in 0..<data!.count {
|
||||
if let str = data?[i] as? String, num = str["~~(\\d)"].groups() {
|
||||
newArr[i] = binary[num[1].toInt()!]
|
||||
} else if data?[i] is NSDictionary || data?[i] is NSArray {
|
||||
newArr[i] = _fillInPlaceholders(data![i])
|
||||
}
|
||||
}
|
||||
|
||||
self.data = newArr as [AnyObject]
|
||||
data = newArr as [AnyObject]
|
||||
}
|
||||
|
||||
private func _fillInPlaceholders(data:AnyObject) -> AnyObject {
|
||||
if let str = data as? String {
|
||||
if let num = str["~~(\\d)"].groups() {
|
||||
return self.binary[num[1].toInt()!]
|
||||
return binary[num[1].toInt()!]
|
||||
} else {
|
||||
return str
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ class SocketParser {
|
||||
}
|
||||
|
||||
if ++i < arr.count {
|
||||
let d = String(arr[i...arr.count-1])
|
||||
let d = str[advance(str.startIndex, i)...advance(str.startIndex, count(str)-1)]
|
||||
let noPlaceholders = d["(\\{\"_placeholder\":true,\"num\":(\\d*)\\})"] ~= "\"~~$2\""
|
||||
let data = SocketParser.parseData(noPlaceholders) as? [AnyObject] ?? [noPlaceholders]
|
||||
|
||||
@@ -185,7 +185,7 @@ class SocketParser {
|
||||
return nsp == "" && socket.nsp != "/"
|
||||
}
|
||||
|
||||
SocketLogger.log("Parsing \(stringMessage)", client: socket, altType: "SocketParser")
|
||||
SocketLogger.log("Parsing %@", client: socket, altType: "SocketParser", args: stringMessage)
|
||||
|
||||
let p:SocketPacket
|
||||
|
||||
@@ -196,10 +196,7 @@ class SocketParser {
|
||||
return
|
||||
}
|
||||
|
||||
// Don't call SocketPacket.description unless we need to
|
||||
if socket.log {
|
||||
SocketLogger.log("Decoded packet as: \(p)", client: socket, altType: "SocketParser")
|
||||
}
|
||||
SocketLogger.log("Decoded packet as: %@", client: socket, altType: "SocketParser", args: p)
|
||||
|
||||
if p.type == SocketPacket.PacketType.EVENT {
|
||||
if checkNSP(p.nsp) {
|
||||
|
||||
+359
-109
@@ -7,6 +7,7 @@
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import Foundation
|
||||
import CoreFoundation
|
||||
|
||||
public protocol WebSocketDelegate: class {
|
||||
func websocketDidConnect(socket: WebSocket)
|
||||
@@ -15,6 +16,10 @@ public protocol WebSocketDelegate: class {
|
||||
func websocketDidReceiveData(socket: WebSocket, data: NSData)
|
||||
}
|
||||
|
||||
public protocol WebSocketPongDelegate: class {
|
||||
func websocketDidReceivePong(socket: WebSocket)
|
||||
}
|
||||
|
||||
public class WebSocket : NSObject, NSStreamDelegate {
|
||||
|
||||
enum OpCode : UInt8 {
|
||||
@@ -78,69 +83,63 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
var buffer: NSMutableData?
|
||||
}
|
||||
|
||||
private var cookies:[NSHTTPCookie]?
|
||||
public weak var delegate: WebSocketDelegate?
|
||||
public weak var pongDelegate: WebSocketPongDelegate?
|
||||
public var onConnect: ((Void) -> Void)?
|
||||
public var onDisconnect: ((NSError?) -> Void)?
|
||||
public var onText: ((String) -> Void)?
|
||||
public var onData: ((NSData) -> Void)?
|
||||
public var onPong: ((Void) -> Void)?
|
||||
public var headers = Dictionary<String,String>()
|
||||
public var voipEnabled = false
|
||||
public var selfSignedSSL = false
|
||||
public var security: Security?
|
||||
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 readStack = Array<WSResponse>()
|
||||
private var inputQueue = Array<NSData>()
|
||||
private var fragBuffer: NSData?
|
||||
public var headers = Dictionary<String,String>()
|
||||
public var voipEnabled = false
|
||||
public var selfSignedSSL = false
|
||||
private var connectedBlock: ((Void) -> Void)? = nil
|
||||
private var disconnectedBlock: ((NSError?) -> Void)? = nil
|
||||
private var receivedTextBlock: ((String) -> Void)? = nil
|
||||
private var receivedDataBlock: ((NSData) -> Void)? = nil
|
||||
public var isConnected :Bool {
|
||||
return connected
|
||||
}
|
||||
private var certValidated = false
|
||||
private var didDisconnect = false
|
||||
|
||||
//init the websocket with a url
|
||||
public init(url: NSURL) {
|
||||
self.url = url
|
||||
}
|
||||
|
||||
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)
|
||||
optionalProtocols = protocols
|
||||
}
|
||||
//closure based instead of the delegate
|
||||
public convenience init(url: NSURL, protocols: Array<String>, connect:((Void) -> Void), disconnect:((NSError?) -> Void), text:((String) -> Void), data:(NSData) -> Void) {
|
||||
self.init(url: url, protocols: protocols)
|
||||
connectedBlock = connect
|
||||
disconnectedBlock = disconnect
|
||||
receivedTextBlock = text
|
||||
receivedDataBlock = data
|
||||
}
|
||||
//same as above, just shorter
|
||||
public convenience init(url: NSURL, connect:((Void) -> Void), disconnect:((NSError?) -> Void), text:((String) -> Void)) {
|
||||
self.init(url: url)
|
||||
connectedBlock = connect
|
||||
disconnectedBlock = disconnect
|
||||
receivedTextBlock = text
|
||||
}
|
||||
//same as above, just shorter
|
||||
public convenience init(url: NSURL, connect:((Void) -> Void), disconnect:((NSError?) -> Void), data:((NSData) -> Void)) {
|
||||
self.init(url: url)
|
||||
connectedBlock = connect
|
||||
disconnectedBlock = disconnect
|
||||
receivedDataBlock = data
|
||||
}
|
||||
|
||||
///Connect to the websocket server on a background thread
|
||||
public func connect() {
|
||||
if isCreated {
|
||||
return
|
||||
}
|
||||
dispatch_async(queue,{
|
||||
self.didDisconnect = false
|
||||
})
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), {
|
||||
self.isCreated = true
|
||||
self.createHTTPRequest()
|
||||
self.isCreated = false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -171,7 +170,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
|
||||
let str: NSString = url.absoluteString!
|
||||
let urlRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault, "GET",
|
||||
url, kCFHTTPVersion1_1)
|
||||
url, kCFHTTPVersion1_1).takeRetainedValue()
|
||||
|
||||
var port = url.port
|
||||
if port == nil {
|
||||
@@ -202,14 +201,14 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
self.addHeader(urlRequest, key: key, val: value)
|
||||
}
|
||||
|
||||
let serializedRequest: NSData = CFHTTPMessageCopySerializedMessage(urlRequest.takeUnretainedValue()).takeUnretainedValue()
|
||||
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: Unmanaged<CFHTTPMessage>,key: String, val: String) {
|
||||
private func addHeader(urlRequest: CFHTTPMessage,key: String, val: String) {
|
||||
let nsKey: NSString = key
|
||||
let nsVal: NSString = val
|
||||
CFHTTPMessageSetHeaderFieldValue(urlRequest.takeUnretainedValue(),
|
||||
CFHTTPMessageSetHeaderFieldValue(urlRequest,
|
||||
nsKey,
|
||||
nsVal)
|
||||
}
|
||||
@@ -234,14 +233,16 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
var writeStream: Unmanaged<CFWriteStream>?
|
||||
let h: NSString = url.host!
|
||||
CFStreamCreatePairWithSocketToHost(nil, h, UInt32(port), &readStream, &writeStream)
|
||||
inputStream = readStream!.takeUnretainedValue()
|
||||
outputStream = writeStream!.takeUnretainedValue()
|
||||
inputStream = readStream!.takeRetainedValue()
|
||||
outputStream = writeStream!.takeRetainedValue()
|
||||
|
||||
inputStream!.delegate = self
|
||||
outputStream!.delegate = self
|
||||
if url.scheme == "wss" || url.scheme == "https" {
|
||||
inputStream!.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
|
||||
outputStream!.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)
|
||||
@@ -249,8 +250,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
if self.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)
|
||||
inputStream!.setProperty(settings, forKey: kCFStreamPropertySSLSettings as! String)
|
||||
outputStream!.setProperty(settings, forKey: kCFStreamPropertySSLSettings as! String)
|
||||
}
|
||||
isRunLoop = true
|
||||
inputStream!.scheduleInRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
@@ -266,6 +267,20 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
//delegate for the stream methods. Processes incoming bytes
|
||||
public func stream(aStream: NSStream, handleEvent eventCode: NSStreamEvent) {
|
||||
|
||||
if let sec = security where !certValidated && (eventCode == .HasBytesAvailable || eventCode == .HasSpaceAvailable) {
|
||||
var possibleTrust: AnyObject? = aStream.propertyForKey(kCFStreamPropertySSLPeerTrust as! String)
|
||||
if let trust: AnyObject = possibleTrust {
|
||||
var domain: AnyObject? = aStream.propertyForKey(kCFStreamSSLPeerName as! String)
|
||||
if sec.isValid(trust as! SecTrustRef, domain: domain as! String?) {
|
||||
certValidated = true
|
||||
} else {
|
||||
let error = self.errorWithDetail("Invalid SSL certificate", code: 1)
|
||||
doDisconnect(error)
|
||||
disconnectStream(error)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if eventCode == .HasBytesAvailable {
|
||||
if(aStream == inputStream) {
|
||||
processInputStream()
|
||||
@@ -281,20 +296,19 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
if writeQueue != nil {
|
||||
writeQueue!.waitUntilAllOperationsAreFinished()
|
||||
}
|
||||
inputStream!.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
outputStream!.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
inputStream!.close()
|
||||
outputStream!.close()
|
||||
inputStream = nil
|
||||
if let stream = inputStream {
|
||||
stream.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
stream.close()
|
||||
}
|
||||
if let stream = outputStream {
|
||||
stream.removeFromRunLoop(NSRunLoop.currentRunLoop(), forMode: NSDefaultRunLoopMode)
|
||||
stream.close()
|
||||
}
|
||||
outputStream = nil
|
||||
isRunLoop = false
|
||||
certValidated = false
|
||||
self.doDisconnect(error)
|
||||
connected = false
|
||||
dispatch_async(queue,{
|
||||
if let disconnectBlock = self.disconnectedBlock {
|
||||
disconnectBlock(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
})
|
||||
}
|
||||
|
||||
///handles the incoming bytes and sending them to the proper processing method
|
||||
@@ -306,14 +320,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
if !connected {
|
||||
connected = processHTTP(buffer, bufferLen: length)
|
||||
if !connected {
|
||||
dispatch_async(queue,{
|
||||
//self.workaroundMethod()
|
||||
let error = self.errorWithDetail("Invalid HTTP upgrade", code: 1)
|
||||
if let disconnect = self.disconnectedBlock {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
})
|
||||
self.doDisconnect(self.errorWithDetail("Invalid HTTP upgrade", code: 1))
|
||||
}
|
||||
} else {
|
||||
var process = false
|
||||
@@ -363,8 +370,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
if totalSize > 0 {
|
||||
if validateResponse(buffer, bufferLen: totalSize) {
|
||||
dispatch_async(queue,{
|
||||
//self.workaroundMethod()
|
||||
if let connectBlock = self.connectedBlock {
|
||||
if let connectBlock = self.onConnect {
|
||||
connectBlock()
|
||||
}
|
||||
self.delegate?.websocketDidConnect(self)
|
||||
@@ -428,10 +434,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
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)
|
||||
if let disconnect = self.disconnectedBlock {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
self.doDisconnect(error)
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -440,20 +443,14 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
receivedOpcode != OpCode.TextFrame.rawValue && receivedOpcode != OpCode.Pong.rawValue) {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("unknown opcode: \(receivedOpcode)", code: errCode)
|
||||
if let disconnect = self.disconnectedBlock {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
self.doDisconnect(error)
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
if isControlFrame && isFin == 0 {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("control frames can't be fragmented", code: errCode)
|
||||
if let disconnect = self.disconnectedBlock {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
self.doDisconnect(error)
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -463,7 +460,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
code = CloseCode.ProtocolError.rawValue
|
||||
} else if payloadLen > 1 {
|
||||
var codeBuffer = UnsafePointer<UInt16>((buffer+offset))
|
||||
code = codeBuffer[0].byteSwapped
|
||||
code = codeBuffer[0].bigEndian
|
||||
if code < 1000 || (code > 1003 && code < 1007) || (code > 1011 && code < 3000) {
|
||||
code = CloseCode.ProtocolError.rawValue
|
||||
}
|
||||
@@ -480,10 +477,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
}
|
||||
let error = self.errorWithDetail("connection closed by server", code: code)
|
||||
if let disconnect = self.disconnectedBlock {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
self.doDisconnect(error)
|
||||
writeError(code)
|
||||
return
|
||||
}
|
||||
@@ -494,13 +488,17 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
var dataLength = UInt64(payloadLen)
|
||||
if dataLength == 127 {
|
||||
let bytes = UnsafePointer<UInt64>((buffer+offset))
|
||||
dataLength = bytes[0].byteSwapped
|
||||
dataLength = bytes[0].bigEndian
|
||||
offset += sizeof(UInt64)
|
||||
} else if dataLength == 126 {
|
||||
let bytes = UnsafePointer<UInt16>((buffer+offset))
|
||||
dataLength = UInt64(bytes[0].byteSwapped)
|
||||
dataLength = UInt64(bytes[0].bigEndian)
|
||||
offset += sizeof(UInt16)
|
||||
}
|
||||
if bufferLen < offset {
|
||||
fragBuffer = NSData(bytes: buffer, length: bufferLen)
|
||||
return
|
||||
}
|
||||
var len = dataLength
|
||||
if dataLength > UInt64(bufferLen) {
|
||||
len = UInt64(bufferLen-offset)
|
||||
@@ -513,7 +511,14 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
data = NSData(bytes: UnsafePointer<UInt8>((buffer+offset)), length: Int(len))
|
||||
}
|
||||
if receivedOpcode == OpCode.Pong.rawValue {
|
||||
let step = offset + Int(len)
|
||||
dispatch_async(queue,{
|
||||
if let pongBlock = self.onPong {
|
||||
pongBlock()
|
||||
}
|
||||
self.pongDelegate?.websocketDidReceivePong(self)
|
||||
})
|
||||
|
||||
let step = Int(offset+numericCast(len))
|
||||
let extra = bufferLen-step
|
||||
if extra > 0 {
|
||||
processRawMessage((buffer+step), bufferLen: extra)
|
||||
@@ -527,10 +532,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)
|
||||
if let disconnect = self.disconnectedBlock {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
self.doDisconnect(error)
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -540,10 +542,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("first frame can't be a continue frame",
|
||||
code: errCode)
|
||||
if let disconnect = self.disconnectedBlock {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
self.doDisconnect(error)
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -559,10 +558,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
let error = self.errorWithDetail("second and beyond of fragment message must be a continue frame",
|
||||
code: errCode)
|
||||
if let disconnect = self.disconnectedBlock {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
self.doDisconnect(error)
|
||||
writeError(errCode)
|
||||
return
|
||||
}
|
||||
@@ -578,7 +574,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
processResponse(response!)
|
||||
}
|
||||
|
||||
let step = offset + Int(len)
|
||||
let step = Int(offset+numericCast(len))
|
||||
let extra = bufferLen-step
|
||||
if(extra > 0) {
|
||||
processExtra((buffer+step), bufferLen: extra)
|
||||
@@ -609,16 +605,15 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
return false
|
||||
}
|
||||
dispatch_async(queue,{
|
||||
if let textBlock = self.receivedTextBlock{
|
||||
textBlock(str! as String)
|
||||
if let textBlock = self.onText {
|
||||
textBlock(str! as! String)
|
||||
}
|
||||
self.delegate?.websocketDidReceiveMessage(self, text: str! as String)
|
||||
self.delegate?.websocketDidReceiveMessage(self, 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.workaroundMethod()
|
||||
if let dataBlock = self.receivedDataBlock{
|
||||
if let dataBlock = self.onData {
|
||||
dataBlock(data)
|
||||
}
|
||||
self.delegate?.websocketDidReceiveData(self, data: data)
|
||||
@@ -641,10 +636,10 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
private func writeError(code: UInt16) {
|
||||
let buf = NSMutableData(capacity: sizeof(UInt16))
|
||||
var buffer = UnsafeMutablePointer<UInt16>(buf!.bytes)
|
||||
buffer[0] = code.byteSwapped
|
||||
buffer[0] = code.bigEndian
|
||||
dequeueWrite(NSData(bytes: buffer, length: sizeof(UInt16)), code: .ConnectionClose)
|
||||
}
|
||||
///used to write things to the stream in a
|
||||
///used to write things to the stream
|
||||
private func dequeueWrite(data: NSData, code: OpCode) {
|
||||
if writeQueue == nil {
|
||||
writeQueue = NSOperationQueue()
|
||||
@@ -676,12 +671,12 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
} else if dataLength <= Int(UInt16.max) {
|
||||
buffer[1] = 126
|
||||
var sizeBuffer = UnsafeMutablePointer<UInt16>((buffer+offset))
|
||||
sizeBuffer[0] = UInt16(dataLength).byteSwapped
|
||||
sizeBuffer[0] = UInt16(dataLength).bigEndian
|
||||
offset += sizeof(UInt16)
|
||||
} else {
|
||||
buffer[1] = 127
|
||||
var sizeBuffer = UnsafeMutablePointer<UInt64>((buffer+offset))
|
||||
sizeBuffer[0] = UInt64(dataLength).byteSwapped
|
||||
sizeBuffer[0] = UInt64(dataLength).bigEndian
|
||||
offset += sizeof(UInt64)
|
||||
}
|
||||
buffer[1] |= self.MaskMask
|
||||
@@ -708,10 +703,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
let errCode = InternalErrorCode.OutputStreamWriteError.rawValue
|
||||
error = self.errorWithDetail("output stream error during write", code: errCode)
|
||||
}
|
||||
if let disconnect = self.disconnectedBlock {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
self.doDisconnect(error)
|
||||
break
|
||||
} else {
|
||||
total += len!
|
||||
@@ -724,4 +716,262 @@ 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
|
||||
if let disconnect = self.onDisconnect {
|
||||
disconnect(error)
|
||||
}
|
||||
self.delegate?.websocketDidDisconnect(self, error: error)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Security.swift
|
||||
// Starscream
|
||||
//
|
||||
// Created by Dalton Cherry on 5/16/15.
|
||||
// Copyright (c) 2015 Vluxe. All rights reserved.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import Foundation
|
||||
import Security
|
||||
|
||||
public class SSLCert {
|
||||
var certData: NSData?
|
||||
var key: SecKeyRef?
|
||||
|
||||
/**
|
||||
Designated init for certificates
|
||||
|
||||
:param: data is the binary data of the certificate
|
||||
|
||||
:returns: a representation security object to be used with
|
||||
*/
|
||||
public init(data: NSData) {
|
||||
self.certData = data
|
||||
}
|
||||
|
||||
/**
|
||||
Designated init for public keys
|
||||
|
||||
:param: key is the public key to be used
|
||||
|
||||
:returns: a representation security object to be used with
|
||||
*/
|
||||
public init(key: SecKeyRef) {
|
||||
self.key = key
|
||||
}
|
||||
}
|
||||
|
||||
public class Security {
|
||||
public var validatedDN = true //should the domain name be validated?
|
||||
|
||||
var isReady = false //is the key processing done?
|
||||
var certificates: [NSData]? //the certificates
|
||||
var pubKeys: [SecKeyRef]? //the public keys
|
||||
var usePublicKeys = false //use public keys or certificate validation?
|
||||
|
||||
/**
|
||||
Use certs from main app bundle
|
||||
|
||||
:param: 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
|
||||
*/
|
||||
public convenience init(usePublicKeys: Bool = false) {
|
||||
let paths = NSBundle.mainBundle().pathsForResourcesOfType("cer", inDirectory: ".")
|
||||
var collect = Array<SSLCert>()
|
||||
for path in paths {
|
||||
if let d = NSData(contentsOfFile: path as! String) {
|
||||
collect.append(SSLCert(data: d))
|
||||
}
|
||||
}
|
||||
self.init(certs:collect, usePublicKeys: usePublicKeys)
|
||||
}
|
||||
|
||||
/**
|
||||
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
|
||||
|
||||
:returns: a representation security object to be used with
|
||||
*/
|
||||
public init(certs: [SSLCert], usePublicKeys: Bool) {
|
||||
self.usePublicKeys = usePublicKeys
|
||||
|
||||
if self.usePublicKeys {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), {
|
||||
var collect = Array<SecKeyRef>()
|
||||
for cert in certs {
|
||||
if let data = cert.certData where cert.key == nil {
|
||||
cert.key = self.extractPublicKey(data)
|
||||
}
|
||||
if let k = cert.key {
|
||||
collect.append(k)
|
||||
}
|
||||
}
|
||||
self.pubKeys = collect
|
||||
self.isReady = true
|
||||
})
|
||||
} else {
|
||||
var collect = Array<NSData>()
|
||||
for cert in certs {
|
||||
if let d = cert.certData {
|
||||
collect.append(d)
|
||||
}
|
||||
}
|
||||
self.certificates = collect
|
||||
self.isReady = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Valid the trust and domain name.
|
||||
|
||||
:param: trust is the serverTrust to validate
|
||||
:param: domain is the CN domain to validate
|
||||
|
||||
:returns: if the key was successfully validated
|
||||
*/
|
||||
public func isValid(trust: SecTrustRef, domain: String?) -> Bool {
|
||||
|
||||
var tries = 0
|
||||
while(!self.isReady) {
|
||||
usleep(1000)
|
||||
tries += 1
|
||||
if tries > 5 {
|
||||
return false //doesn't appear it is going to ever be ready...
|
||||
}
|
||||
}
|
||||
var policy: SecPolicyRef
|
||||
if self.validatedDN {
|
||||
policy = SecPolicyCreateSSL(1, domain).takeRetainedValue()
|
||||
} else {
|
||||
policy = SecPolicyCreateBasicX509().takeRetainedValue()
|
||||
}
|
||||
SecTrustSetPolicies(trust,policy)
|
||||
if self.usePublicKeys {
|
||||
if let keys = self.pubKeys {
|
||||
var trustedCount = 0
|
||||
let serverPubKeys = publicKeyChainForTrust(trust)
|
||||
for serverKey in serverPubKeys as [AnyObject] {
|
||||
for key in keys as [AnyObject] {
|
||||
if serverKey.isEqual(key) {
|
||||
trustedCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if trustedCount == serverPubKeys.count {
|
||||
return true
|
||||
}
|
||||
}
|
||||
} else if let certs = self.certificates {
|
||||
let serverCerts = certificateChainForTrust(trust)
|
||||
var collect = Array<SecCertificate>()
|
||||
for cert in certs {
|
||||
collect.append(SecCertificateCreateWithData(nil,cert).takeRetainedValue())
|
||||
}
|
||||
SecTrustSetAnchorCertificates(trust,collect)
|
||||
var result: SecTrustResultType = 0
|
||||
SecTrustEvaluate(trust,&result)
|
||||
let r = Int(result)
|
||||
if r == kSecTrustResultUnspecified || r == kSecTrustResultProceed {
|
||||
var trustedCount = 0
|
||||
for serverCert in serverCerts {
|
||||
for cert in certs {
|
||||
if cert == serverCert {
|
||||
trustedCount++
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if trustedCount == serverCerts.count {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
Get the public key from a certificate data
|
||||
|
||||
:param: data is the certificate to pull the public key from
|
||||
|
||||
:returns: a public key
|
||||
*/
|
||||
func extractPublicKey(data: NSData) -> SecKeyRef? {
|
||||
var publicKey: NSData?
|
||||
let possibleCert = SecCertificateCreateWithData(nil,data)
|
||||
if let cert = possibleCert {
|
||||
return extractPublicKeyFromCert(cert.takeRetainedValue(),policy: SecPolicyCreateBasicX509().takeRetainedValue())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/**
|
||||
Get the public key from a certificate
|
||||
|
||||
:param: data is the certificate to pull the public key from
|
||||
|
||||
:returns: a public key
|
||||
*/
|
||||
func extractPublicKeyFromCert(cert: SecCertificate, policy: SecPolicy) -> SecKeyRef? {
|
||||
var possibleTrust: Unmanaged<SecTrust>?
|
||||
SecTrustCreateWithCertificates(cert,policy, &possibleTrust)
|
||||
if let trust = possibleTrust {
|
||||
let t = trust.takeRetainedValue()
|
||||
var result: SecTrustResultType = 0
|
||||
SecTrustEvaluate(t,&result)
|
||||
return SecTrustCopyPublicKey(t).takeRetainedValue()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
/**
|
||||
Get the certificate chain for the trust
|
||||
|
||||
:param: trust is the trust to lookup the certificate chain for
|
||||
|
||||
:returns: the certificate chain for the trust
|
||||
*/
|
||||
func certificateChainForTrust(trust: SecTrustRef) -> Array<NSData> {
|
||||
var collect = Array<NSData>()
|
||||
for var i = 0; i < SecTrustGetCertificateCount(trust); i++ {
|
||||
let cert = SecTrustGetCertificateAtIndex(trust,i)
|
||||
collect.append(SecCertificateCopyData(cert.takeRetainedValue()).takeRetainedValue())
|
||||
}
|
||||
return collect
|
||||
}
|
||||
|
||||
/**
|
||||
Get the public key chain for the trust
|
||||
|
||||
:param: 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
|
||||
*/
|
||||
func publicKeyChainForTrust(trust: SecTrustRef) -> Array<SecKeyRef> {
|
||||
var collect = Array<SecKeyRef>()
|
||||
let policy = SecPolicyCreateBasicX509().takeRetainedValue()
|
||||
for var i = 0; i < SecTrustGetCertificateCount(trust); i++ {
|
||||
let cert = SecTrustGetCertificateAtIndex(trust,i)
|
||||
if let key = extractPublicKeyFromCert(cert.takeRetainedValue(), policy: policy) {
|
||||
collect.append(key)
|
||||
}
|
||||
}
|
||||
return collect
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user