Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7c824c3c5 | ||
|
|
89ab458a5f | ||
|
|
bd7f94333d | ||
|
|
4de7a48e87 | ||
|
|
e3c8cc7fd9 | ||
|
|
4a9013d986 | ||
|
|
2910355245 | ||
|
|
5e1dc53304 | ||
|
|
e567067d44 | ||
|
|
518c256cc2 | ||
|
|
07f2ca5f16 | ||
|
|
c364f6a832 | ||
|
|
e2bf84f576 | ||
|
|
437c983533 | ||
|
|
14b4df3836 | ||
|
|
b6cb0b2c7b | ||
|
|
3ec1b93f8e | ||
|
|
ee63c4e386 | ||
|
|
6147cda561 | ||
|
|
fcfb409282 | ||
|
|
d03d77aff8 | ||
|
|
637e0bb14c | ||
|
|
32ba61fb09 | ||
|
|
a9aa28ae77 | ||
|
|
99adb49736 | ||
|
|
21d242ba6a | ||
|
|
10d24c47ec | ||
|
|
604c30bf28 | ||
|
|
1d56759276 | ||
|
|
af77e984ab | ||
|
|
1af7bd842e | ||
|
|
7bd019fb28 | ||
|
|
cc449a49ea | ||
|
|
b65b63a9f0 | ||
|
|
87c86f8aeb | ||
|
|
c9b60445ca | ||
|
|
f15a6dc491 | ||
|
|
7fb2193032 | ||
|
|
e56741b669 | ||
|
|
559fbc0286 | ||
|
|
a9ac86ba3d | ||
|
|
dce28b2dac | ||
|
|
8345eae28c | ||
|
|
9cc60ab63d | ||
|
|
22030e1153 | ||
|
|
73b042b41e | ||
|
|
f52607f722 | ||
|
|
f00ed17783 | ||
|
|
5840d2b61b | ||
|
|
17d3e659c1 | ||
|
|
05c0874f32 | ||
|
|
2e5442d386 | ||
|
|
f9ae0cfdb3 | ||
|
|
7ad90de184 | ||
|
|
4383ddfe65 | ||
|
|
45373ad680 | ||
|
|
5ced8a5a9e | ||
|
|
6fd3294fba | ||
|
|
bfa163f3c2 | ||
|
|
d8826a9db3 | ||
|
|
b9e3de2d50 | ||
|
|
e163598ee6 | ||
|
|
2c059e1a6e | ||
|
|
6f21059ff8 | ||
|
|
58a5a17464 | ||
|
|
cb0a6f5460 | ||
|
|
b919d3e411 | ||
|
|
02f30a81dd | ||
|
|
e57bcba47d | ||
|
|
71f9058723 | ||
|
|
0564ded492 | ||
|
|
ff48d3a186 | ||
|
|
4fa3225cba | ||
|
|
ee24943c72 | ||
|
|
3d47ff469f |
No files matched your search
+4
-8
@@ -2,12 +2,8 @@ language: objective-c
|
||||
xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder
|
||||
xcode_scheme: SocketIO-iOS
|
||||
osx_image: xcode7.3
|
||||
before_install:
|
||||
- cd Socket.IO-Test-Server/
|
||||
- npm install
|
||||
- cd ..
|
||||
install: node Socket.IO-Test-Server/main.js &
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- development
|
||||
script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test -parallelize
|
||||
cache:
|
||||
directories:
|
||||
- Socket.IO-Test-Server/node_modules
|
||||
@@ -5,7 +5,9 @@ Socket.IO-client for iOS/OS X.
|
||||
|
||||
##Example
|
||||
```swift
|
||||
let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8080")!, options: [.Log(true), .ForcePolling(true)])
|
||||
import SocketIO
|
||||
|
||||
let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8080")!, config: [.Log(true), .ForcePolling(true)])
|
||||
|
||||
socket.on("connect") {data, ack in
|
||||
print("socket connected")
|
||||
@@ -26,8 +28,9 @@ socket.connect()
|
||||
|
||||
##Objective-C Example
|
||||
```objective-c
|
||||
@import SocketIO;
|
||||
NSURL* url = [[NSURL alloc] initWithString:@"http://localhost:8080"];
|
||||
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url options:@{@"log": @YES, @"forcePolling": @YES}];
|
||||
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @YES, @"forcePolling": @YES}];
|
||||
|
||||
[socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
|
||||
NSLog(@"socket connected");
|
||||
@@ -88,21 +91,21 @@ Carthage
|
||||
-----------------
|
||||
Add this line to your `Cartfile`:
|
||||
```
|
||||
github "socketio/socket.io-client-swift" ~> 6.1.2 # Or latest version
|
||||
github "socketio/socket.io-client-swift" ~> 7.0.1 # Or latest version
|
||||
```
|
||||
|
||||
Run `carthage update --platform ios,macosx`.
|
||||
|
||||
CocoaPods 0.36.0 or later (iOS 8+)
|
||||
CocoaPods 1.0.0 or later
|
||||
------------------
|
||||
Create `Podfile` and add `pod 'Socket.IO-Client-Swift'`:
|
||||
|
||||
```ruby
|
||||
source 'https://github.com/CocoaPods/Specs.git'
|
||||
platform :ios, '8.0'
|
||||
use_frameworks!
|
||||
|
||||
pod 'Socket.IO-Client-Swift', '~> 6.1.2' # Or latest version
|
||||
target 'YourApp' do
|
||||
pod 'Socket.IO-Client-Swift', '~> 7.0.1' # Or latest version
|
||||
end
|
||||
```
|
||||
|
||||
Install pods:
|
||||
@@ -115,13 +118,13 @@ Import the module:
|
||||
|
||||
Swift:
|
||||
```swift
|
||||
import SocketIOClientSwift
|
||||
import SocketIO
|
||||
```
|
||||
|
||||
Objective-C:
|
||||
|
||||
```Objective-C
|
||||
#import <SocketIOClientSwift/SocketIOClientSwift-Swift.h>
|
||||
@import SocketIO;
|
||||
```
|
||||
|
||||
CocoaSeeds
|
||||
@@ -130,7 +133,7 @@ CocoaSeeds
|
||||
Add this line to your `Seedfile`:
|
||||
|
||||
```
|
||||
github "socketio/socket.io-client-swift", "v6.1.2", :files => "Source/*.swift" # Or latest version
|
||||
github "socketio/socket.io-client-swift", "v7.0.1", :files => "Source/*.swift" # Or latest version
|
||||
```
|
||||
|
||||
Run `seed install`.
|
||||
@@ -139,7 +142,7 @@ Run `seed install`.
|
||||
##API
|
||||
Constructors
|
||||
-----------
|
||||
`init(var socketURL: NSURL, options: Set<SocketIOClientOption> = [])` - Creates a new SocketIOClient. options is a Set of SocketIOClientOption. If your socket.io server is secure, you need to specify `https` in your socketURL.
|
||||
`init(var socketURL: NSURL, config: SocketIOClientConfiguration = [])` - Creates a new SocketIOClient. If your socket.io server is secure, you need to specify `https` in your socketURL.
|
||||
|
||||
`convenience init(socketURL: NSURL, options: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys.
|
||||
|
||||
@@ -165,7 +168,8 @@ case ReconnectAttempts(Int) // How many times to reconnect. Default is `-1` (inf
|
||||
case ReconnectWait(Int) // Amount of time to wait between reconnects. Default is `10`
|
||||
case SessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.
|
||||
case Secure(Bool) // If the connection should use TLS. Default is false.
|
||||
case SelfSigned(Bool) // Sets WebSocket.selfSignedSSL (Don't do this, iOS will yell at you)
|
||||
case Security(SSLSecurity) // Allows you to set which certs are valid. Useful for SSL pinning.
|
||||
case SelfSigned(Bool) // Sets WebSocket.selfSignedSSL. Use this if you're using self-signed certs.
|
||||
case VoipEnabled(Bool) // Only use this option if you're using the client with VoIP services. Changes the way the WebSocket is created. Default is false
|
||||
```
|
||||
Methods
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Socket.IO-Client-Swift"
|
||||
s.module_name = "SocketIOClientSwift"
|
||||
s.version = "6.1.2"
|
||||
s.version = "7.0.1"
|
||||
s.summary = "Socket.IO-client for iOS and OS X"
|
||||
s.description = <<-DESC
|
||||
Socket.IO-client for iOS and OS X.
|
||||
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.10'
|
||||
s.tvos.deployment_target = '9.0'
|
||||
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.2' }
|
||||
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v7.0.1' }
|
||||
s.source_files = "Source/**/*.swift"
|
||||
s.requires_arc = true
|
||||
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
|
||||
|
||||
@@ -7,105 +7,70 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
572EF2251B51F16C00EEBB58 /* SocketIOClientSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */; };
|
||||
572EF21F1B51F16C00EEBB58 /* SocketIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
||||
572EF23D1B51F18A00EEBB58 /* SocketIO-Mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
572EF2431B51F18A00EEBB58 /* SocketIOClientSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */; };
|
||||
57634A111BD9B46A00E19CD7 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; };
|
||||
57634A111BD9B46A00E19CD7 /* SocketIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
57634A231BD9B46D00E19CD7 /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
||||
57634A2A1BD9B46D00E19CD7 /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; };
|
||||
57634A2F1BD9B46D00E19CD7 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
||||
57634A321BD9B46D00E19CD7 /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
|
||||
57634A3F1BD9B4BF00E19CD7 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57634A161BD9B46A00E19CD7 /* SocketIO.framework */; };
|
||||
6CA08A961D615C040061FD2A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CA08A951D615C040061FD2A /* Security.framework */; };
|
||||
6CA08A981D615C0B0061FD2A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CA08A971D615C0B0061FD2A /* Security.framework */; };
|
||||
6CA08A9A1D615C140061FD2A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CA08A991D615C140061FD2A /* Security.framework */; };
|
||||
740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */; };
|
||||
740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */; };
|
||||
740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */; };
|
||||
74171E631C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; };
|
||||
74171E641C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; };
|
||||
74171E651C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; };
|
||||
74171E671C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; };
|
||||
74171E681C10CD240062D398 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E501C10CD240062D398 /* SocketAckEmitter.swift */; };
|
||||
74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; };
|
||||
74171E6A1C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; };
|
||||
74171E6B1C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; };
|
||||
74171E6D1C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; };
|
||||
74171E6E1C10CD240062D398 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E511C10CD240062D398 /* SocketAckManager.swift */; };
|
||||
74171E6F1C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; };
|
||||
74171E701C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; };
|
||||
74171E711C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; };
|
||||
74171E731C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; };
|
||||
74171E741C10CD240062D398 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E521C10CD240062D398 /* SocketAnyEvent.swift */; };
|
||||
74171E751C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; };
|
||||
74171E761C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; };
|
||||
74171E771C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; };
|
||||
74171E791C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; };
|
||||
74171E7A1C10CD240062D398 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E531C10CD240062D398 /* SocketEngine.swift */; };
|
||||
74171E7B1C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; };
|
||||
74171E7C1C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; };
|
||||
74171E7D1C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; };
|
||||
74171E7F1C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; };
|
||||
74171E801C10CD240062D398 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E541C10CD240062D398 /* SocketEngineClient.swift */; };
|
||||
74171E811C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; };
|
||||
74171E821C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; };
|
||||
74171E831C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; };
|
||||
74171E851C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; };
|
||||
74171E861C10CD240062D398 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E551C10CD240062D398 /* SocketEnginePacketType.swift */; };
|
||||
74171E871C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; };
|
||||
74171E881C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; };
|
||||
74171E891C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; };
|
||||
74171E8B1C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; };
|
||||
74171E8C1C10CD240062D398 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E561C10CD240062D398 /* SocketEngineSpec.swift */; };
|
||||
74171E8D1C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; };
|
||||
74171E8E1C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; };
|
||||
74171E8F1C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; };
|
||||
74171E911C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; };
|
||||
74171E921C10CD240062D398 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E571C10CD240062D398 /* SocketEventHandler.swift */; };
|
||||
74171E991C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; };
|
||||
74171E9A1C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; };
|
||||
74171E9B1C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; };
|
||||
74171E9D1C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; };
|
||||
74171E9E1C10CD240062D398 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E591C10CD240062D398 /* SocketIOClient.swift */; };
|
||||
74171E9F1C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; };
|
||||
74171EA01C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; };
|
||||
74171EA11C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; };
|
||||
74171EA31C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; };
|
||||
74171EA41C10CD240062D398 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */; };
|
||||
74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; };
|
||||
74171EA61C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; };
|
||||
74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; };
|
||||
74171EA81C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; };
|
||||
74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; };
|
||||
74171EAA1C10CD240062D398 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */; };
|
||||
74171EAB1C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; };
|
||||
74171EAC1C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; };
|
||||
74171EAD1C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; };
|
||||
74171EAF1C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; };
|
||||
74171EB01C10CD240062D398 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5C1C10CD240062D398 /* SocketLogger.swift */; };
|
||||
74171EB11C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; };
|
||||
74171EB21C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; };
|
||||
74171EB31C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; };
|
||||
74171EB51C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; };
|
||||
74171EB61C10CD240062D398 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5D1C10CD240062D398 /* SocketPacket.swift */; };
|
||||
74171EB71C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; };
|
||||
74171EB81C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; };
|
||||
74171EB91C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; };
|
||||
74171EBB1C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; };
|
||||
74171EBC1C10CD240062D398 /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParsable.swift */; };
|
||||
74171EBD1C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; };
|
||||
74171EBE1C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; };
|
||||
74171EBF1C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; };
|
||||
74171EC11C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; };
|
||||
74171EC21C10CD240062D398 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5F1C10CD240062D398 /* SocketStringReader.swift */; };
|
||||
74171EC31C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; };
|
||||
74171EC41C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; };
|
||||
74171EC51C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; };
|
||||
74171EC71C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; };
|
||||
74171EC81C10CD240062D398 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E601C10CD240062D398 /* SocketTypes.swift */; };
|
||||
74171ECF1C10CD240062D398 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E621C10CD240062D398 /* WebSocket.swift */; };
|
||||
74171ED01C10CD240062D398 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E621C10CD240062D398 /* WebSocket.swift */; };
|
||||
74171ED11C10CD240062D398 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E621C10CD240062D398 /* WebSocket.swift */; };
|
||||
74171ED31C10CD240062D398 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E621C10CD240062D398 /* WebSocket.swift */; };
|
||||
74171ED41C10CD240062D398 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E621C10CD240062D398 /* WebSocket.swift */; };
|
||||
741F39EE1BD025D80026C9CC /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; };
|
||||
741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; };
|
||||
7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7420CB781C49629E00956AA4 /* SocketEnginePollable.swift */; };
|
||||
@@ -120,15 +85,25 @@
|
||||
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
|
||||
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
||||
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
||||
747BC5991D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */; };
|
||||
747BC59A1D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */; };
|
||||
747BC59B1D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */; };
|
||||
747BC59F1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 747BC59E1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift */; };
|
||||
749642B51D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */; };
|
||||
749642B61D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */; };
|
||||
749642B71D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */; };
|
||||
749642B81D3FCE5500DD32D1 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B41D3FCE5500DD32D1 /* WebSocket.swift */; };
|
||||
749642B91D3FCE5500DD32D1 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B41D3FCE5500DD32D1 /* WebSocket.swift */; };
|
||||
749642BA1D3FCE5500DD32D1 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 749642B41D3FCE5500DD32D1 /* WebSocket.swift */; };
|
||||
74ABF7771C3991C10078C657 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */; };
|
||||
74BC45AB1D0C6675008CC431 /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */; };
|
||||
74BC45AC1D0C6675008CC431 /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */; };
|
||||
74BC45AD1D0C6675008CC431 /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */; };
|
||||
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
||||
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
||||
CEBA56961CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; };
|
||||
CEBA56971CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; };
|
||||
CEBA56981CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; };
|
||||
CEBA569A1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; };
|
||||
CEBA569B1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; };
|
||||
CEBA569C1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; };
|
||||
CEBA569A1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */; };
|
||||
CEBA569B1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */; };
|
||||
CEBA569C1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -156,18 +131,20 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
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>"; };
|
||||
572EF21E1B51F16C00EEBB58 /* SocketIO.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SocketIO.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>"; };
|
||||
572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
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>"; };
|
||||
57634A161BD9B46A00E19CD7 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
57634A3B1BD9B46D00E19CD7 /* SocketIO-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
6CA08A951D615C040061FD2A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
|
||||
6CA08A971D615C0B0061FD2A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
|
||||
6CA08A991D615C140061FD2A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
|
||||
740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SocketEngineWebsocket.swift; path = Source/SocketEngineWebsocket.swift; sourceTree = "<group>"; };
|
||||
74171E501C10CD240062D398 /* SocketAckEmitter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckEmitter.swift; path = Source/SocketAckEmitter.swift; sourceTree = "<group>"; };
|
||||
74171E511C10CD240062D398 /* SocketAckManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckManager.swift; path = Source/SocketAckManager.swift; sourceTree = "<group>"; };
|
||||
@@ -185,7 +162,6 @@
|
||||
74171E5E1C10CD240062D398 /* SocketParsable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketParsable.swift; path = Source/SocketParsable.swift; sourceTree = "<group>"; };
|
||||
74171E5F1C10CD240062D398 /* SocketStringReader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketStringReader.swift; path = Source/SocketStringReader.swift; sourceTree = "<group>"; };
|
||||
74171E601C10CD240062D398 /* SocketTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketTypes.swift; path = Source/SocketTypes.swift; sourceTree = "<group>"; };
|
||||
74171E621C10CD240062D398 /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Source/WebSocket.swift; sourceTree = "<group>"; };
|
||||
741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketEngineTest.swift; sourceTree = "<group>"; };
|
||||
7420CB781C49629E00956AA4 /* SocketEnginePollable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEnginePollable.swift; path = Source/SocketEnginePollable.swift; sourceTree = "<group>"; };
|
||||
742D150B1CA5794B00BD987D /* SocketObjectiveCTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SocketObjectiveCTest.m; sourceTree = "<group>"; };
|
||||
@@ -193,10 +169,14 @@
|
||||
74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketParserTest.swift; sourceTree = "<group>"; };
|
||||
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespacePacketTest.swift; sourceTree = "<group>"; };
|
||||
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketSideEffectTest.swift; sourceTree = "<group>"; };
|
||||
747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientConfiguration.swift; path = Source/SocketIOClientConfiguration.swift; sourceTree = "<group>"; };
|
||||
747BC59E1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketIOClientConfigurationTest.swift; sourceTree = "<group>"; };
|
||||
749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Source/SSLSecurity.swift; sourceTree = "<group>"; };
|
||||
749642B41D3FCE5500DD32D1 /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Source/WebSocket.swift; sourceTree = "<group>"; };
|
||||
74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientSpec.swift; path = Source/SocketIOClientSpec.swift; sourceTree = "<group>"; };
|
||||
74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketClientManager.swift; path = Source/SocketClientManager.swift; sourceTree = "<group>"; };
|
||||
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = "<group>"; };
|
||||
CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NSCharacterSet.swift; path = Source/NSCharacterSet.swift; sourceTree = "<group>"; };
|
||||
CEBA56991CDA0B8200BA0389 /* String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = String.swift; path = Source/String.swift; sourceTree = "<group>"; };
|
||||
CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketExtensions.swift; path = Source/SocketExtensions.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -204,6 +184,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
6CA08A961D615C040061FD2A /* Security.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -211,7 +192,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF2251B51F16C00EEBB58 /* SocketIOClientSwift.framework in Frameworks */,
|
||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -219,6 +200,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
6CA08A981D615C0B0061FD2A /* Security.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -226,7 +208,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF2431B51F18A00EEBB58 /* SocketIOClientSwift.framework in Frameworks */,
|
||||
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -234,6 +216,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
6CA08A9A1D615C140061FD2A /* Security.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -251,21 +234,21 @@
|
||||
572EF20D1B51F12F00EEBB58 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
5764DF7B1B51F24A004FF46E /* Source */,
|
||||
6CA08A9B1D615C190061FD2A /* Frameworks */,
|
||||
572EF21A1B51F16C00EEBB58 /* Products */,
|
||||
572EF21B1B51F16C00EEBB58 /* SocketIO-iOS */,
|
||||
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */,
|
||||
572EF2391B51F18A00EEBB58 /* SocketIO-Mac */,
|
||||
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */,
|
||||
572EF21A1B51F16C00EEBB58 /* Products */,
|
||||
5764DF7B1B51F24A004FF46E /* Source */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF21A1B51F16C00EEBB58 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */,
|
||||
572EF2191B51F16C00EEBB58 /* SocketIO.framework */,
|
||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */,
|
||||
572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */,
|
||||
572EF2381B51F18A00EEBB58 /* SocketIO.framework */,
|
||||
572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */,
|
||||
57634A161BD9B46A00E19CD7 /* SocketIO.framework */,
|
||||
57634A3B1BD9B46D00E19CD7 /* SocketIO-tvOSTests.xctest */,
|
||||
@@ -276,7 +259,7 @@
|
||||
572EF21B1B51F16C00EEBB58 /* SocketIO-iOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */,
|
||||
572EF21E1B51F16C00EEBB58 /* SocketIO.h */,
|
||||
572EF21C1B51F16C00EEBB58 /* Supporting Files */,
|
||||
);
|
||||
path = "SocketIO-iOS";
|
||||
@@ -290,22 +273,6 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
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 = (
|
||||
@@ -330,6 +297,7 @@
|
||||
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */,
|
||||
741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */,
|
||||
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */,
|
||||
747BC59E1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift */,
|
||||
742D150B1CA5794B00BD987D /* SocketObjectiveCTest.m */,
|
||||
74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */,
|
||||
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */,
|
||||
@@ -349,10 +317,10 @@
|
||||
5764DF7B1B51F24A004FF46E /* Source */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CEBA569E1CDA0C0C00BA0389 /* utils */,
|
||||
74171E501C10CD240062D398 /* SocketAckEmitter.swift */,
|
||||
74171E511C10CD240062D398 /* SocketAckManager.swift */,
|
||||
74171E521C10CD240062D398 /* SocketAnyEvent.swift */,
|
||||
74BC45AA1D0C6675008CC431 /* SocketClientManager.swift */,
|
||||
74171E531C10CD240062D398 /* SocketEngine.swift */,
|
||||
74171E541C10CD240062D398 /* SocketEngineClient.swift */,
|
||||
74171E551C10CD240062D398 /* SocketEnginePacketType.swift */,
|
||||
@@ -360,7 +328,9 @@
|
||||
74171E561C10CD240062D398 /* SocketEngineSpec.swift */,
|
||||
740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */,
|
||||
74171E571C10CD240062D398 /* SocketEventHandler.swift */,
|
||||
CEBA56991CDA0B8200BA0389 /* SocketExtensions.swift */,
|
||||
74171E591C10CD240062D398 /* SocketIOClient.swift */,
|
||||
747BC5981D5F943500CA5FA4 /* SocketIOClientConfiguration.swift */,
|
||||
74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */,
|
||||
74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */,
|
||||
74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */,
|
||||
@@ -369,18 +339,52 @@
|
||||
74171E5E1C10CD240062D398 /* SocketParsable.swift */,
|
||||
74171E5F1C10CD240062D398 /* SocketStringReader.swift */,
|
||||
74171E601C10CD240062D398 /* SocketTypes.swift */,
|
||||
74171E621C10CD240062D398 /* WebSocket.swift */,
|
||||
74B4AD1B1D09A5C30062A523 /* Websocket */,
|
||||
);
|
||||
name = Source;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CEBA569E1CDA0C0C00BA0389 /* utils */ = {
|
||||
6CA08A9B1D615C190061FD2A /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */,
|
||||
CEBA56991CDA0B8200BA0389 /* String.swift */,
|
||||
6CA08A9E1D615C340061FD2A /* tvOS */,
|
||||
6CA08A9D1D615C2C0061FD2A /* Mac */,
|
||||
6CA08A9C1D615C270061FD2A /* iOS */,
|
||||
);
|
||||
name = utils;
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6CA08A9C1D615C270061FD2A /* iOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6CA08A951D615C040061FD2A /* Security.framework */,
|
||||
);
|
||||
name = iOS;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6CA08A9D1D615C2C0061FD2A /* Mac */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6CA08A971D615C0B0061FD2A /* Security.framework */,
|
||||
);
|
||||
name = Mac;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
6CA08A9E1D615C340061FD2A /* tvOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6CA08A991D615C140061FD2A /* Security.framework */,
|
||||
);
|
||||
name = tvOS;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
74B4AD1B1D09A5C30062A523 /* Websocket */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
749642B31D3FCE5500DD32D1 /* SSLSecurity.swift */,
|
||||
749642B41D3FCE5500DD32D1 /* WebSocket.swift */,
|
||||
);
|
||||
name = Websocket;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
@@ -390,7 +394,7 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */,
|
||||
572EF21F1B51F16C00EEBB58 /* SocketIO.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -406,7 +410,7 @@
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
57634A111BD9B46A00E19CD7 /* SocketIO-iOS.h in Headers */,
|
||||
57634A111BD9B46A00E19CD7 /* SocketIO.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -428,7 +432,7 @@
|
||||
);
|
||||
name = "SocketIO-iOS";
|
||||
productName = "SocketIO-iOS";
|
||||
productReference = 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */;
|
||||
productReference = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
572EF2231B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
||||
@@ -464,7 +468,7 @@
|
||||
);
|
||||
name = "SocketIO-Mac";
|
||||
productName = "SocketIO-Mac";
|
||||
productReference = 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */;
|
||||
productReference = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
572EF2411B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
||||
@@ -618,11 +622,10 @@
|
||||
files = (
|
||||
740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
||||
74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
CEBA569A1CDA0B8200BA0389 /* String.swift in Sources */,
|
||||
CEBA569A1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */,
|
||||
74171E751C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
||||
CEBA56961CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */,
|
||||
74ABF7771C3991C10078C657 /* SocketIOClientSpec.swift in Sources */,
|
||||
74171E871C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171E631C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
@@ -630,14 +633,17 @@
|
||||
74171EC31C10CD240062D398 /* SocketTypes.swift in Sources */,
|
||||
74171EAB1C10CD240062D398 /* SocketLogger.swift in Sources */,
|
||||
74171E991C10CD240062D398 /* SocketIOClient.swift in Sources */,
|
||||
749642B81D3FCE5500DD32D1 /* WebSocket.swift in Sources */,
|
||||
74171E8D1C10CD240062D398 /* SocketEventHandler.swift in Sources */,
|
||||
74171E7B1C10CD240062D398 /* SocketEngineClient.swift in Sources */,
|
||||
74171ECF1C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EB11C10CD240062D398 /* SocketPacket.swift in Sources */,
|
||||
749642B51D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */,
|
||||
74171EB71C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171E811C10CD240062D398 /* SocketEnginePacketType.swift in Sources */,
|
||||
74171E6F1C10CD240062D398 /* SocketAnyEvent.swift in Sources */,
|
||||
747BC5991D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */,
|
||||
74171E9F1C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
74BC45AB1D0C6675008CC431 /* SocketClientManager.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -646,26 +652,9 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */,
|
||||
74171EA61C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
74171E881C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171ED01C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EA01C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
74171E701C10CD240062D398 /* SocketAnyEvent.swift in Sources */,
|
||||
74171EC41C10CD240062D398 /* SocketTypes.swift in Sources */,
|
||||
74171E8E1C10CD240062D398 /* SocketEventHandler.swift in Sources */,
|
||||
74171E7C1C10CD240062D398 /* SocketEngineClient.swift in Sources */,
|
||||
74171E821C10CD240062D398 /* SocketEnginePacketType.swift in Sources */,
|
||||
74171EB21C10CD240062D398 /* SocketPacket.swift in Sources */,
|
||||
741F39EE1BD025D80026C9CC /* SocketEngineTest.swift in Sources */,
|
||||
74171EBE1C10CD240062D398 /* SocketStringReader.swift in Sources */,
|
||||
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */,
|
||||
74171E6A1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
74171E761C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
74171E641C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
74171EB81C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171EAC1C10CD240062D398 /* SocketLogger.swift in Sources */,
|
||||
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */,
|
||||
74171E9A1C10CD240062D398 /* SocketIOClient.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -675,11 +664,10 @@
|
||||
files = (
|
||||
740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
||||
7471CCEA1C39926300364B59 /* SocketIOClientSpec.swift in Sources */,
|
||||
CEBA569B1CDA0B8200BA0389 /* String.swift in Sources */,
|
||||
CEBA569B1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */,
|
||||
74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
74171E771C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
7420CB7A1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
||||
CEBA56971CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */,
|
||||
74171E6B1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
74171E891C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171E651C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
@@ -687,14 +675,17 @@
|
||||
74171EC51C10CD240062D398 /* SocketTypes.swift in Sources */,
|
||||
74171EAD1C10CD240062D398 /* SocketLogger.swift in Sources */,
|
||||
74171E9B1C10CD240062D398 /* SocketIOClient.swift in Sources */,
|
||||
749642B91D3FCE5500DD32D1 /* WebSocket.swift in Sources */,
|
||||
74171E8F1C10CD240062D398 /* SocketEventHandler.swift in Sources */,
|
||||
74171E7D1C10CD240062D398 /* SocketEngineClient.swift in Sources */,
|
||||
74171ED11C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EB31C10CD240062D398 /* SocketPacket.swift in Sources */,
|
||||
749642B61D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */,
|
||||
74171EB91C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171E831C10CD240062D398 /* SocketEnginePacketType.swift in Sources */,
|
||||
74171E711C10CD240062D398 /* SocketAnyEvent.swift in Sources */,
|
||||
747BC59A1D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */,
|
||||
74171EA11C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
74BC45AC1D0C6675008CC431 /* SocketClientManager.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -705,8 +696,8 @@
|
||||
742D150C1CA5794B00BD987D /* SocketObjectiveCTest.m in Sources */,
|
||||
74321DCB1C2D939A00CF6F43 /* SocketAckManagerTest.swift in Sources */,
|
||||
74321DCC1C2D939A00CF6F43 /* SocketParserTest.swift in Sources */,
|
||||
747BC59F1D5F9BA200CA5FA4 /* SocketIOClientConfigurationTest.swift in Sources */,
|
||||
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */,
|
||||
74171EA81C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */,
|
||||
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */,
|
||||
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */,
|
||||
@@ -719,11 +710,10 @@
|
||||
files = (
|
||||
740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
||||
7471CCEB1C39926C00364B59 /* SocketIOClientSpec.swift in Sources */,
|
||||
CEBA569C1CDA0B8200BA0389 /* String.swift in Sources */,
|
||||
CEBA569C1CDA0B8200BA0389 /* SocketExtensions.swift in Sources */,
|
||||
74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
74171E791C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
7420CB7B1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
||||
CEBA56981CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */,
|
||||
74171E6D1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
74171E8B1C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171E671C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
@@ -731,14 +721,17 @@
|
||||
74171EC71C10CD240062D398 /* SocketTypes.swift in Sources */,
|
||||
74171EAF1C10CD240062D398 /* SocketLogger.swift in Sources */,
|
||||
74171E9D1C10CD240062D398 /* SocketIOClient.swift in Sources */,
|
||||
749642BA1D3FCE5500DD32D1 /* WebSocket.swift in Sources */,
|
||||
74171E911C10CD240062D398 /* SocketEventHandler.swift in Sources */,
|
||||
74171E7F1C10CD240062D398 /* SocketEngineClient.swift in Sources */,
|
||||
74171ED31C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EB51C10CD240062D398 /* SocketPacket.swift in Sources */,
|
||||
749642B71D3FCE5500DD32D1 /* SSLSecurity.swift in Sources */,
|
||||
74171EBB1C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171E851C10CD240062D398 /* SocketEnginePacketType.swift in Sources */,
|
||||
74171E731C10CD240062D398 /* SocketAnyEvent.swift in Sources */,
|
||||
747BC59B1D5F943500CA5FA4 /* SocketIOClientConfiguration.swift in Sources */,
|
||||
74171EA31C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
74BC45AD1D0C6675008CC431 /* SocketClientManager.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -747,26 +740,9 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
57634A231BD9B46D00E19CD7 /* SocketSideEffectTest.swift in Sources */,
|
||||
74171EAA1C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
74171E8C1C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171ED41C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EA41C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
74171E741C10CD240062D398 /* SocketAnyEvent.swift in Sources */,
|
||||
74171EC81C10CD240062D398 /* SocketTypes.swift in Sources */,
|
||||
74171E921C10CD240062D398 /* SocketEventHandler.swift in Sources */,
|
||||
74171E801C10CD240062D398 /* SocketEngineClient.swift in Sources */,
|
||||
74171E861C10CD240062D398 /* SocketEnginePacketType.swift in Sources */,
|
||||
74171EB61C10CD240062D398 /* SocketPacket.swift in Sources */,
|
||||
57634A2A1BD9B46D00E19CD7 /* SocketEngineTest.swift in Sources */,
|
||||
74171EC21C10CD240062D398 /* SocketStringReader.swift in Sources */,
|
||||
57634A2F1BD9B46D00E19CD7 /* SocketBasicPacketTest.swift in Sources */,
|
||||
74171E6E1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
74171E7A1C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
74171E681C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
74171EBC1C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171EB01C10CD240062D398 /* SocketLogger.swift in Sources */,
|
||||
57634A321BD9B46D00E19CD7 /* SocketNamespacePacketTest.swift in Sources */,
|
||||
74171E9E1C10CD240062D398 /* SocketIOClient.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -802,7 +778,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = SocketIOClientSwift;
|
||||
PRODUCT_NAME = SocketIO;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
@@ -817,7 +793,7 @@
|
||||
ENABLE_BITCODE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_NAME = SocketIOClientSwift;
|
||||
PRODUCT_NAME = SocketIO;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
@@ -828,6 +804,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -884,6 +861,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
APPLICATION_EXTENSION_API_ONLY = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -970,7 +948,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist";
|
||||
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
@@ -1015,7 +993,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist";
|
||||
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
@@ -1385,7 +1363,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist";
|
||||
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
@@ -1430,7 +1408,7 @@
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
INFOPLIST_FILE = "SocketIO-iOSTests/Info.plist";
|
||||
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -57,7 +57,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -79,7 +79,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -97,7 +97,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -58,7 +58,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -80,7 +80,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -98,7 +98,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
@testable import SocketIO
|
||||
|
||||
class SocketAckManagerTest: XCTestCase {
|
||||
var ackManager = SocketAckManager()
|
||||
|
||||
|
||||
func testAddAcks() {
|
||||
let callbackExpection = self.expectationWithDescription("callbackExpection")
|
||||
let itemsArray = ["Hi", "ho"]
|
||||
@@ -19,8 +19,8 @@ class SocketAckManagerTest: XCTestCase {
|
||||
callbackExpection.fulfill()
|
||||
}
|
||||
ackManager.addAck(1, callback: callback)
|
||||
ackManager.executeAck(1, items: itemsArray)
|
||||
ackManager.executeAck(1, items: itemsArray, onQueue: dispatch_get_main_queue())
|
||||
waitForExpectationsWithTimeout(3.0, handler: nil)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
@testable import SocketIO
|
||||
|
||||
class SocketBasicPacketTest: XCTestCase {
|
||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
@testable import SocketIO
|
||||
|
||||
class SocketEngineTest: XCTestCase {
|
||||
var client: SocketIOClient!
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// TestSocketIOClientConfiguration.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 8/13/16.
|
||||
//
|
||||
//
|
||||
|
||||
import XCTest
|
||||
import SocketIO
|
||||
|
||||
class TestSocketIOClientConfiguration: XCTestCase {
|
||||
var config = [] as SocketIOClientConfiguration
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
config = [.Log(false), .ForceNew(true)]
|
||||
}
|
||||
|
||||
func testReplaceSameOption() {
|
||||
config.insert(.Log(true))
|
||||
|
||||
XCTAssertEqual(config.count, 2)
|
||||
|
||||
switch config[0] {
|
||||
case let .Log(log):
|
||||
XCTAssertTrue(log)
|
||||
default:
|
||||
XCTFail()
|
||||
}
|
||||
}
|
||||
|
||||
func testIgnoreIfExisting() {
|
||||
config.insert(.ForceNew(false), replacing: false)
|
||||
|
||||
XCTAssertEqual(config.count, 2)
|
||||
|
||||
switch config[1] {
|
||||
case let .ForceNew(new):
|
||||
XCTAssertTrue(new)
|
||||
default:
|
||||
XCTFail()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
@testable import SocketIO
|
||||
|
||||
class SocketNamespacePacketTest: XCTestCase {
|
||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
@import SocketIOClientSwift;
|
||||
@import SocketIO;
|
||||
|
||||
@interface SocketObjectiveCTest : XCTestCase
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
- (void)setUp {
|
||||
[super setUp];
|
||||
NSURL* url = [[NSURL alloc] initWithString:@"http://localhost"];
|
||||
self.socket = [[SocketIOClient alloc] initWithSocketURL:url options:nil];
|
||||
self.socket = [[SocketIOClient alloc] initWithSocketURL:url config:nil];
|
||||
}
|
||||
|
||||
- (void)testOnSyntax {
|
||||
@@ -44,4 +44,10 @@
|
||||
[self.socket off:@"test"];
|
||||
}
|
||||
|
||||
- (void)testSocketManager {
|
||||
SocketClientManager* manager = [SocketClientManager sharedManager];
|
||||
[manager addSocket:self.socket labeledAs:@"test"];
|
||||
[manager removeSocketWithLabel:@"test"];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -7,13 +7,13 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
@testable import SocketIO
|
||||
|
||||
class SocketParserTest: XCTestCase {
|
||||
let testSocket = SocketIOClient(socketURL: NSURL())
|
||||
|
||||
//Format key: message; namespace-data-binary-id
|
||||
static let packetTypes: Dictionary<String, (String, [AnyObject], [NSData], Int)> = [
|
||||
static let packetTypes: [String: (String, [AnyObject], [NSData], Int)] = [
|
||||
"0": ("/", [], [], -1), "1": ("/", [], [], -1),
|
||||
"25[\"test\"]": ("/", ["test"], [], 5),
|
||||
"2[\"test\",\"~~0\"]": ("/", ["test", "~~0"], [], -1),
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
@testable import SocketIO
|
||||
|
||||
class SocketSideEffectTest: XCTestCase {
|
||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
@@ -153,4 +153,16 @@ class SocketSideEffectTest: XCTestCase {
|
||||
socket.parseBinaryData(data2)
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testSocketManager() {
|
||||
let manager = SocketClientManager.sharedManager
|
||||
manager["test"] = socket
|
||||
|
||||
XCTAssert(manager["test"] === socket, "failed to get socket")
|
||||
|
||||
manager["test"] = nil
|
||||
|
||||
XCTAssert(manager["test"] == nil, "socket not removed")
|
||||
|
||||
}
|
||||
}
|
||||
File renamed without changes.
@@ -1,24 +0,0 @@
|
||||
<?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>$(PRODUCT_BUNDLE_IDENTIFIER)</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>
|
||||
@@ -1,31 +0,0 @@
|
||||
//
|
||||
// NSCharacterSet.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Yannick Loriot on 5/4/16.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
extension NSCharacterSet {
|
||||
class var allowedURLCharacterSet: NSCharacterSet {
|
||||
return NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// SSLSecurity.swift
|
||||
// Starscream
|
||||
//
|
||||
// Created by Dalton Cherry on 5/16/15.
|
||||
// Copyright (c) 2014-2015 Dalton Cherry.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
import Foundation
|
||||
import Security
|
||||
|
||||
public class SSLCert : NSObject {
|
||||
var certData: NSData?
|
||||
var key: SecKeyRef?
|
||||
|
||||
/**
|
||||
Designated init for certificates
|
||||
|
||||
- parameter 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
|
||||
|
||||
- parameter 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 SSLSecurity : NSObject {
|
||||
public var validatedDN = true //should the domain name be validated?
|
||||
|
||||
var isReady = false //is the key processing done?
|
||||
var certificates: [NSData]? //the certificates
|
||||
@nonobjc var pubKeys: [SecKeyRef]? //the public keys
|
||||
var usePublicKeys = false //use public keys or certificate validation?
|
||||
|
||||
/**
|
||||
Use certs from main app bundle
|
||||
|
||||
- parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation
|
||||
|
||||
- returns: a representation security object to be used with
|
||||
*/
|
||||
public convenience init(usePublicKeys: Bool = false) {
|
||||
let paths = NSBundle.mainBundle().pathsForResourcesOfType("cer", inDirectory: ".")
|
||||
|
||||
let certs = paths.reduce([SSLCert]()) { (certs: [SSLCert], path: String) -> [SSLCert] in
|
||||
var certs = certs
|
||||
if let data = NSData(contentsOfFile: path) {
|
||||
certs.append(SSLCert(data: data))
|
||||
}
|
||||
return certs
|
||||
}
|
||||
|
||||
self.init(certs: certs, usePublicKeys: usePublicKeys)
|
||||
}
|
||||
|
||||
/**
|
||||
Designated init
|
||||
|
||||
- parameter keys: is the certificates or public keys to use
|
||||
- parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation
|
||||
|
||||
- returns: a representation security object to be used with
|
||||
*/
|
||||
public init(certs: [SSLCert], usePublicKeys: Bool) {
|
||||
self.usePublicKeys = usePublicKeys
|
||||
|
||||
super.init()
|
||||
|
||||
if self.usePublicKeys {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0)) {
|
||||
let pubKeys = certs.reduce([SecKeyRef]()) { (pubKeys: [SecKeyRef], cert: SSLCert) -> [SecKeyRef] in
|
||||
var pubKeys = pubKeys
|
||||
if let data = cert.certData where cert.key == nil {
|
||||
cert.key = self.extractPublicKey(data)
|
||||
}
|
||||
if let key = cert.key {
|
||||
pubKeys.append(key)
|
||||
}
|
||||
return pubKeys
|
||||
}
|
||||
|
||||
self.pubKeys = pubKeys
|
||||
self.isReady = true
|
||||
}
|
||||
} else {
|
||||
let certificates = certs.reduce([NSData]()) { (certificates: [NSData], cert: SSLCert) -> [NSData] in
|
||||
var certificates = certificates
|
||||
if let data = cert.certData {
|
||||
certificates.append(data)
|
||||
}
|
||||
return certificates
|
||||
}
|
||||
self.certificates = certificates
|
||||
self.isReady = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Valid the trust and domain name.
|
||||
|
||||
- parameter trust: is the serverTrust to validate
|
||||
- parameter 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(true, domain)
|
||||
} else {
|
||||
policy = SecPolicyCreateBasicX509()
|
||||
}
|
||||
SecTrustSetPolicies(trust,policy)
|
||||
if self.usePublicKeys {
|
||||
if let keys = self.pubKeys {
|
||||
let serverPubKeys = publicKeyChainForTrust(trust)
|
||||
for serverKey in serverPubKeys as [AnyObject] {
|
||||
for key in keys as [AnyObject] {
|
||||
if serverKey.isEqual(key) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let certs = self.certificates {
|
||||
let serverCerts = certificateChainForTrust(trust)
|
||||
var collect = [SecCertificate]()
|
||||
for cert in certs {
|
||||
collect.append(SecCertificateCreateWithData(nil,cert)!)
|
||||
}
|
||||
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 += 1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if trustedCount == serverCerts.count {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
Get the public key from a certificate data
|
||||
|
||||
- parameter data: is the certificate to pull the public key from
|
||||
|
||||
- returns: a public key
|
||||
*/
|
||||
func extractPublicKey(data: NSData) -> SecKeyRef? {
|
||||
guard let cert = SecCertificateCreateWithData(nil, data) else { return nil }
|
||||
|
||||
return extractPublicKeyFromCert(cert, policy: SecPolicyCreateBasicX509())
|
||||
}
|
||||
|
||||
/**
|
||||
Get the public key from a certificate
|
||||
|
||||
- parameter data: is the certificate to pull the public key from
|
||||
|
||||
- returns: a public key
|
||||
*/
|
||||
func extractPublicKeyFromCert(cert: SecCertificate, policy: SecPolicy) -> SecKeyRef? {
|
||||
var possibleTrust: SecTrust?
|
||||
SecTrustCreateWithCertificates(cert, policy, &possibleTrust)
|
||||
|
||||
guard let trust = possibleTrust else { return nil }
|
||||
|
||||
var result: SecTrustResultType = 0
|
||||
SecTrustEvaluate(trust, &result)
|
||||
return SecTrustCopyPublicKey(trust)
|
||||
}
|
||||
|
||||
/**
|
||||
Get the certificate chain for the trust
|
||||
|
||||
- parameter trust: is the trust to lookup the certificate chain for
|
||||
|
||||
- returns: the certificate chain for the trust
|
||||
*/
|
||||
func certificateChainForTrust(trust: SecTrustRef) -> [NSData] {
|
||||
let certificates = (0..<SecTrustGetCertificateCount(trust)).reduce([NSData]()) { (certificates: [NSData], index: Int) -> [NSData] in
|
||||
var certificates = certificates
|
||||
let cert = SecTrustGetCertificateAtIndex(trust, index)
|
||||
certificates.append(SecCertificateCopyData(cert!))
|
||||
return certificates
|
||||
}
|
||||
|
||||
return certificates
|
||||
}
|
||||
|
||||
/**
|
||||
Get the public key chain for the trust
|
||||
|
||||
- parameter trust: is the trust to lookup the certificate chain and extract the public keys
|
||||
|
||||
- returns: the public keys from the certifcate chain for the trust
|
||||
*/
|
||||
@nonobjc func publicKeyChainForTrust(trust: SecTrustRef) -> [SecKeyRef] {
|
||||
let policy = SecPolicyCreateBasicX509()
|
||||
let keys = (0..<SecTrustGetCertificateCount(trust)).reduce([SecKeyRef]()) { (keys: [SecKeyRef], index: Int) -> [SecKeyRef] in
|
||||
var keys = keys
|
||||
let cert = SecTrustGetCertificateAtIndex(trust, index)
|
||||
if let key = extractPublicKeyFromCert(cert!, policy: policy) {
|
||||
keys.append(key)
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
private struct SocketAck : Hashable, Equatable {
|
||||
private struct SocketAck : Hashable {
|
||||
let ack: Int
|
||||
var callback: AckCallback!
|
||||
var hashValue: Int {
|
||||
@@ -56,18 +56,20 @@ struct SocketAckManager {
|
||||
acks.insert(SocketAck(ack: ack, callback: callback))
|
||||
}
|
||||
|
||||
mutating func executeAck(ack: Int, items: [AnyObject]) {
|
||||
/// Should be called on handle queue
|
||||
mutating func executeAck(ack: Int, items: [AnyObject], onQueue: dispatch_queue_t) {
|
||||
let callback = acks.remove(SocketAck(ack: ack))
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
|
||||
dispatch_async(onQueue) {
|
||||
callback?.callback(items)
|
||||
}
|
||||
}
|
||||
|
||||
mutating func timeoutAck(ack: Int) {
|
||||
/// Should be called on handle queue
|
||||
mutating func timeoutAck(ack: Int, onQueue: dispatch_queue_t) {
|
||||
let callback = acks.remove(SocketAck(ack: ack))
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
dispatch_async(onQueue) {
|
||||
callback?.callback(["NO ACK"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
//
|
||||
// SocketClientManager.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 6/11/16.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
/**
|
||||
Experimental socket manager.
|
||||
|
||||
API subject to change.
|
||||
|
||||
Can be used to persist sockets across ViewControllers.
|
||||
|
||||
Sockets are strongly stored, so be sure to remove them once they are no
|
||||
longer needed.
|
||||
|
||||
Example usage:
|
||||
```
|
||||
let manager = SocketClientManager.sharedManager
|
||||
manager["room1"] = socket1
|
||||
manager["room2"] = socket2
|
||||
manager.removeSocket(socket: socket2)
|
||||
manager["room1"]?.emit("hello")
|
||||
```
|
||||
*/
|
||||
public final class SocketClientManager : NSObject {
|
||||
public static let sharedManager = SocketClientManager()
|
||||
|
||||
private var sockets = [String: SocketIOClient]()
|
||||
|
||||
public subscript(string: String) -> SocketIOClient? {
|
||||
get {
|
||||
return sockets[string]
|
||||
}
|
||||
|
||||
set(socket) {
|
||||
sockets[string] = socket
|
||||
}
|
||||
}
|
||||
|
||||
public func addSocket(socket: SocketIOClient, labeledAs label: String) {
|
||||
sockets[label] = socket
|
||||
}
|
||||
|
||||
public func removeSocket(withLabel label: String) -> SocketIOClient? {
|
||||
return sockets.removeValueForKey(label)
|
||||
}
|
||||
|
||||
public func removeSocket(socket: SocketIOClient) -> SocketIOClient? {
|
||||
var returnSocket: SocketIOClient?
|
||||
|
||||
for (label, dictSocket) in sockets where dictSocket === socket {
|
||||
returnSocket = sockets.removeValueForKey(label)
|
||||
}
|
||||
|
||||
return returnSocket
|
||||
}
|
||||
|
||||
public func removeSockets() {
|
||||
sockets.removeAll()
|
||||
}
|
||||
}
|
||||
+111
-99
@@ -24,7 +24,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWebsocket {
|
||||
public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePollable, SocketEngineWebsocket {
|
||||
public let emitQueue = dispatch_queue_create("com.socketio.engineEmitQueue", DISPATCH_QUEUE_SERIAL)
|
||||
public let handleQueue = dispatch_queue_create("com.socketio.engineHandleQueue", DISPATCH_QUEUE_SERIAL)
|
||||
public let parseQueue = dispatch_queue_create("com.socketio.engineParseQueue", DISPATCH_QUEUE_SERIAL)
|
||||
@@ -76,14 +76,15 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
private var pongsMissedMax = 0
|
||||
private var probeWait = ProbeWaitQueue()
|
||||
private var secure = false
|
||||
private var security: SSLSecurity?
|
||||
private var selfSigned = false
|
||||
private var voipEnabled = false
|
||||
|
||||
public init(client: SocketEngineClient, url: NSURL, options: Set<SocketIOClientOption>) {
|
||||
public init(client: SocketEngineClient, url: NSURL, config: SocketIOClientConfiguration) {
|
||||
self.client = client
|
||||
self.url = url
|
||||
|
||||
for option in options {
|
||||
for option in config {
|
||||
switch option {
|
||||
case let .ConnectParams(params):
|
||||
connectParams = params
|
||||
@@ -101,10 +102,16 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
forceWebsockets = force
|
||||
case let .Path(path):
|
||||
socketPath = path
|
||||
|
||||
if !socketPath.hasSuffix("/") {
|
||||
socketPath += "/"
|
||||
}
|
||||
case let .VoipEnabled(enable):
|
||||
voipEnabled = enable
|
||||
case let .Secure(secure):
|
||||
self.secure = secure
|
||||
case let .Security(security):
|
||||
self.security = security
|
||||
case let .SelfSigned(selfSigned):
|
||||
self.selfSigned = selfSigned
|
||||
default:
|
||||
@@ -114,11 +121,13 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
|
||||
super.init()
|
||||
|
||||
sessionDelegate = sessionDelegate ?? self
|
||||
|
||||
(urlPolling, urlWebSocket) = createURLs()
|
||||
}
|
||||
|
||||
public convenience init(client: SocketEngineClient, url: NSURL, options: NSDictionary?) {
|
||||
self.init(client: client, url: url, options: options?.toSocketOptionsSet() ?? [])
|
||||
self.init(client: client, url: url, config: options?.toSocketConfiguration() ?? [])
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -128,42 +137,42 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
}
|
||||
|
||||
private func checkAndHandleEngineError(msg: String) {
|
||||
guard let stringData = msg.dataUsingEncoding(NSUTF8StringEncoding,
|
||||
allowLossyConversion: false) else { return }
|
||||
|
||||
do {
|
||||
if let dict = try NSJSONSerialization.JSONObjectWithData(stringData, options: .MutableContainers) as? NSDictionary {
|
||||
guard let error = dict["message"] as? String else { return }
|
||||
|
||||
/*
|
||||
0: Unknown transport
|
||||
1: Unknown sid
|
||||
2: Bad handshake request
|
||||
3: Bad request
|
||||
*/
|
||||
didError(error)
|
||||
}
|
||||
let dict = try msg.toNSDictionary()
|
||||
guard let error = dict["message"] as? String else { return }
|
||||
|
||||
/*
|
||||
0: Unknown transport
|
||||
1: Unknown sid
|
||||
2: Bad handshake request
|
||||
3: Bad request
|
||||
*/
|
||||
didError(error)
|
||||
} catch {
|
||||
didError("Got unknown error from server \(msg)")
|
||||
client?.engineDidError("Got unknown error from server \(msg)")
|
||||
}
|
||||
}
|
||||
|
||||
private func checkIfMessageIsBase64Binary(message: String) -> Bool {
|
||||
if message.hasPrefix("b4") {
|
||||
// binary in base64 string
|
||||
let noPrefix = message[message.startIndex.advancedBy(2)..<message.endIndex]
|
||||
|
||||
if let data = NSData(base64EncodedString: noPrefix,
|
||||
options: .IgnoreUnknownCharacters) {
|
||||
client?.parseEngineBinaryData(data)
|
||||
}
|
||||
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
private func handleBase64(message: String) {
|
||||
// binary in base64 string
|
||||
let noPrefix = message[message.startIndex.advancedBy(2)..<message.endIndex]
|
||||
|
||||
if let data = NSData(base64EncodedString: noPrefix, options: .IgnoreUnknownCharacters) {
|
||||
client?.parseEngineBinaryData(data)
|
||||
}
|
||||
}
|
||||
|
||||
private func closeOutEngine(reason: String) {
|
||||
sid = ""
|
||||
closed = true
|
||||
invalidated = true
|
||||
connected = false
|
||||
|
||||
ws?.disconnect()
|
||||
stopPolling()
|
||||
client?.engineDidClose(reason)
|
||||
}
|
||||
|
||||
/// Starts the connection to the server
|
||||
public func connect() {
|
||||
if connected {
|
||||
@@ -171,7 +180,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
disconnect("reconnect")
|
||||
}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Starting engine", type: logType)
|
||||
DefaultSocketLogger.Logger.log("Starting engine. Server: %@", type: logType, args: url)
|
||||
DefaultSocketLogger.Logger.log("Handshaking", type: logType)
|
||||
|
||||
resetEngine()
|
||||
@@ -196,9 +205,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
}
|
||||
}
|
||||
|
||||
dispatch_async(emitQueue) {
|
||||
self.doLongPoll(reqPolling)
|
||||
}
|
||||
doLongPoll(reqPolling)
|
||||
}
|
||||
|
||||
private func createURLs() -> (NSURL, NSURL) {
|
||||
@@ -252,50 +259,46 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
}
|
||||
}
|
||||
|
||||
ws?.queue = handleQueue
|
||||
ws?.callbackQueue = handleQueue
|
||||
ws?.voipEnabled = voipEnabled
|
||||
ws?.delegate = self
|
||||
ws?.selfSignedSSL = selfSigned
|
||||
ws?.security = security
|
||||
|
||||
ws?.connect()
|
||||
}
|
||||
|
||||
public func didError(error: String) {
|
||||
DefaultSocketLogger.Logger.error(error, type: logType)
|
||||
DefaultSocketLogger.Logger.error("%@", type: logType, args: error)
|
||||
client?.engineDidError(error)
|
||||
disconnect(error)
|
||||
}
|
||||
|
||||
public func disconnect(reason: String) {
|
||||
func postSendClose(data: NSData?, _ res: NSURLResponse?, _ err: NSError?) {
|
||||
sid = ""
|
||||
closed = true
|
||||
invalidated = true
|
||||
connected = false
|
||||
|
||||
ws?.disconnect()
|
||||
stopPolling()
|
||||
client?.engineDidClose(reason)
|
||||
}
|
||||
guard connected else { return closeOutEngine(reason) }
|
||||
|
||||
DefaultSocketLogger.Logger.log("Engine is being closed.", type: logType)
|
||||
|
||||
if closed {
|
||||
client?.engineDidClose(reason)
|
||||
return
|
||||
return closeOutEngine(reason)
|
||||
}
|
||||
|
||||
if websocket {
|
||||
sendWebSocketMessage("", withType: .Close, withData: [])
|
||||
postSendClose(nil, nil, nil)
|
||||
closeOutEngine(reason)
|
||||
} else {
|
||||
// We need to take special care when we're polling that we send it ASAP
|
||||
// Also make sure we're on the emitQueue since we're touching postWait
|
||||
dispatch_sync(emitQueue) {
|
||||
self.postWait.append(String(SocketEnginePacketType.Close.rawValue))
|
||||
let req = self.createRequestForPostWithPostWait()
|
||||
self.doRequest(req, withCallback: postSendClose)
|
||||
}
|
||||
disconnectPolling(reason)
|
||||
}
|
||||
}
|
||||
|
||||
// We need to take special care when we're polling that we send it ASAP
|
||||
// Also make sure we're on the emitQueue since we're touching postWait
|
||||
private func disconnectPolling(reason: String) {
|
||||
dispatch_sync(emitQueue) {
|
||||
self.postWait.append(String(SocketEnginePacketType.Close.rawValue))
|
||||
let req = self.createRequestForPostWithPostWait()
|
||||
self.doRequest(req) {_, _, _ in }
|
||||
self.closeOutEngine(reason)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +338,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
guard let ws = self.ws else { return }
|
||||
|
||||
for msg in postWait {
|
||||
ws.writeString(fixDoubleUTF8(msg))
|
||||
ws.writeString(msg)
|
||||
}
|
||||
|
||||
postWait.removeAll(keepCapacity: true)
|
||||
@@ -354,39 +357,40 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
}
|
||||
|
||||
private func handleOpen(openData: String) {
|
||||
let mesData = openData.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
|
||||
do {
|
||||
let json = try NSJSONSerialization.JSONObjectWithData(mesData,
|
||||
options: NSJSONReadingOptions.AllowFragments) as? NSDictionary
|
||||
if let sid = json?["sid"] as? String {
|
||||
let upgradeWs: Bool
|
||||
|
||||
self.sid = sid
|
||||
connected = true
|
||||
|
||||
if let upgrades = json?["upgrades"] as? [String] {
|
||||
upgradeWs = upgrades.contains("websocket")
|
||||
} else {
|
||||
upgradeWs = false
|
||||
}
|
||||
|
||||
if let pingInterval = json?["pingInterval"] as? Double, pingTimeout = json?["pingTimeout"] as? Double {
|
||||
self.pingInterval = pingInterval / 1000.0
|
||||
self.pingTimeout = pingTimeout / 1000.0
|
||||
}
|
||||
|
||||
if !forcePolling && !forceWebsockets && upgradeWs {
|
||||
createWebsocketAndConnect()
|
||||
}
|
||||
|
||||
sendPing()
|
||||
|
||||
if !forceWebsockets {
|
||||
doPoll()
|
||||
}
|
||||
|
||||
client?.engineDidOpen("Connect")
|
||||
let json = try openData.toNSDictionary()
|
||||
guard let sid = json[sid] as? String else {
|
||||
client?.engineDidError("Open packet contained no sid")
|
||||
return
|
||||
}
|
||||
|
||||
let upgradeWs: Bool
|
||||
|
||||
self.sid = sid
|
||||
connected = true
|
||||
|
||||
if let upgrades = json["upgrades"] as? [String] {
|
||||
upgradeWs = upgrades.contains("websocket")
|
||||
} else {
|
||||
upgradeWs = false
|
||||
}
|
||||
|
||||
if let pingInterval = json["pingInterval"] as? Double, pingTimeout = json["pingTimeout"] as? Double {
|
||||
self.pingInterval = pingInterval / 1000.0
|
||||
self.pingTimeout = pingTimeout / 1000.0
|
||||
}
|
||||
|
||||
if !forcePolling && !forceWebsockets && upgradeWs {
|
||||
createWebsocketAndConnect()
|
||||
}
|
||||
|
||||
sendPing()
|
||||
|
||||
if !forceWebsockets {
|
||||
doPoll()
|
||||
}
|
||||
|
||||
client?.engineDidOpen("Connect")
|
||||
} catch {
|
||||
didError("Error parsing open packet")
|
||||
}
|
||||
@@ -411,11 +415,13 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
|
||||
let reader = SocketStringReader(message: message)
|
||||
let fixedString: String
|
||||
|
||||
if message.hasPrefix("b4") {
|
||||
return handleBase64(message)
|
||||
}
|
||||
|
||||
guard let type = SocketEnginePacketType(rawValue: Int(reader.currentCharacter) ?? -1) else {
|
||||
if !checkIfMessageIsBase64Binary(message) {
|
||||
checkAndHandleEngineError(message)
|
||||
}
|
||||
checkAndHandleEngineError(message)
|
||||
|
||||
return
|
||||
}
|
||||
@@ -452,7 +458,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
invalidated = false
|
||||
session = NSURLSession(configuration: .defaultSessionConfiguration(),
|
||||
delegate: sessionDelegate,
|
||||
delegateQueue: NSOperationQueue())
|
||||
delegateQueue: NSOperationQueue.mainQueue())
|
||||
sid = ""
|
||||
waitingForPoll = false
|
||||
waitingForPost = false
|
||||
@@ -535,15 +541,21 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
||||
connected = false
|
||||
websocket = false
|
||||
|
||||
let reason = error?.localizedDescription ?? "Socket Disconnected"
|
||||
|
||||
if error != nil {
|
||||
if let reason = error?.localizedDescription {
|
||||
didError(reason)
|
||||
} else {
|
||||
client?.engineDidClose("Socket Disconnected")
|
||||
}
|
||||
|
||||
client?.engineDidClose(reason)
|
||||
} else {
|
||||
flushProbeWait()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension SocketEngine {
|
||||
public func URLSession(session: NSURLSession, didBecomeInvalidWithError error: NSError?) {
|
||||
DefaultSocketLogger.Logger.error("Engine URLSession became invalid", type: "SocketEngine")
|
||||
|
||||
didError("Engine URLSession became invalid")
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,8 @@ extension SocketEnginePollable {
|
||||
}
|
||||
|
||||
func createRequestForPostWithPostWait() -> NSURLRequest {
|
||||
defer { postWait.removeAll(keepCapacity: true) }
|
||||
|
||||
var postStr = ""
|
||||
|
||||
for packet in postWait {
|
||||
@@ -69,18 +71,13 @@ extension SocketEnginePollable {
|
||||
|
||||
DefaultSocketLogger.Logger.log("Created POST string: %@", type: "SocketEnginePolling", args: postStr)
|
||||
|
||||
postWait.removeAll(keepCapacity: false)
|
||||
|
||||
let req = NSMutableURLRequest(URL: urlPollingWithSid)
|
||||
let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
|
||||
|
||||
addHeaders(req)
|
||||
|
||||
req.HTTPMethod = "POST"
|
||||
req.setValue("text/plain; charset=UTF-8", forHTTPHeaderField: "Content-Type")
|
||||
|
||||
let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding,
|
||||
allowLossyConversion: false)!
|
||||
|
||||
req.HTTPBody = postData
|
||||
req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length")
|
||||
|
||||
@@ -88,11 +85,10 @@ extension SocketEnginePollable {
|
||||
}
|
||||
|
||||
public func doPoll() {
|
||||
if websocket || waitingForPoll || !connected || closed {
|
||||
return
|
||||
}
|
||||
if websocket || waitingForPoll || !connected || closed { return }
|
||||
|
||||
waitingForPoll = true
|
||||
|
||||
let req = NSMutableURLRequest(URL: urlPollingWithSid)
|
||||
|
||||
addHeaders(req)
|
||||
@@ -101,7 +97,6 @@ extension SocketEnginePollable {
|
||||
|
||||
func doRequest(req: NSURLRequest, withCallback callback: (NSData?, NSURLResponse?, NSError?) -> Void) {
|
||||
if !polling || closed || invalidated || fastUpgrade {
|
||||
DefaultSocketLogger.Logger.error("Tried to do polling request when not supposed to", type: "SocketEnginePolling")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -123,7 +118,7 @@ extension SocketEnginePollable {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
DefaultSocketLogger.Logger.log("Got polling response", type: "SocketEnginePolling")
|
||||
|
||||
if let str = String(data: data!, encoding: NSUTF8StringEncoding) {
|
||||
@@ -213,9 +208,7 @@ extension SocketEnginePollable {
|
||||
fixedMessage = message
|
||||
}
|
||||
|
||||
let strMsg = "\(type.rawValue)\(fixedMessage)"
|
||||
|
||||
postWait.append(strMsg)
|
||||
postWait.append(String(type.rawValue) + fixedMessage)
|
||||
|
||||
for data in datas {
|
||||
if case let .Right(bin) = createBinaryDataForSend(data) {
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
//
|
||||
// SocketExtensions.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 7/1/2016.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
enum JSONError : ErrorType {
|
||||
case notArray
|
||||
case notNSDictionary
|
||||
}
|
||||
|
||||
extension Array where Element: AnyObject {
|
||||
func toJSON() throws -> NSData {
|
||||
return try NSJSONSerialization.dataWithJSONObject(self as NSArray, options: NSJSONWritingOptions(rawValue: 0))
|
||||
}
|
||||
}
|
||||
|
||||
extension NSCharacterSet {
|
||||
static var allowedURLCharacterSet: NSCharacterSet {
|
||||
return NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
|
||||
}
|
||||
}
|
||||
|
||||
extension NSDictionary {
|
||||
private static func keyValueToSocketIOClientOption(key: String, value: AnyObject) -> SocketIOClientOption? {
|
||||
switch (key, value) {
|
||||
case let ("connectParams", params as [String: AnyObject]):
|
||||
return .ConnectParams(params)
|
||||
case let ("cookies", cookies as [NSHTTPCookie]):
|
||||
return .Cookies(cookies)
|
||||
case let ("doubleEncodeUTF8", encode as Bool):
|
||||
return .DoubleEncodeUTF8(encode)
|
||||
case let ("extraHeaders", headers as [String: String]):
|
||||
return .ExtraHeaders(headers)
|
||||
case let ("forceNew", force as Bool):
|
||||
return .ForceNew(force)
|
||||
case let ("forcePolling", force as Bool):
|
||||
return .ForcePolling(force)
|
||||
case let ("forceWebsockets", force as Bool):
|
||||
return .ForceWebsockets(force)
|
||||
case let ("handleQueue", queue as dispatch_queue_t):
|
||||
return .HandleQueue(queue)
|
||||
case let ("log", log as Bool):
|
||||
return .Log(log)
|
||||
case let ("logger", logger as SocketLogger):
|
||||
return .Logger(logger)
|
||||
case let ("nsp", nsp as String):
|
||||
return .Nsp(nsp)
|
||||
case let ("path", path as String):
|
||||
return .Path(path)
|
||||
case let ("reconnects", reconnects as Bool):
|
||||
return .Reconnects(reconnects)
|
||||
case let ("reconnectAttempts", attempts as Int):
|
||||
return .ReconnectAttempts(attempts)
|
||||
case let ("reconnectWait", wait as Int):
|
||||
return .ReconnectWait(wait)
|
||||
case let ("secure", secure as Bool):
|
||||
return .Secure(secure)
|
||||
case let ("security", security as SSLSecurity):
|
||||
return .Security(security)
|
||||
case let ("selfSigned", selfSigned as Bool):
|
||||
return .SelfSigned(selfSigned)
|
||||
case let ("sessionDelegate", delegate as NSURLSessionDelegate):
|
||||
return .SessionDelegate(delegate)
|
||||
case let ("voipEnabled", enable as Bool):
|
||||
return .VoipEnabled(enable)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func toSocketConfiguration() -> SocketIOClientConfiguration {
|
||||
var options = [] as SocketIOClientConfiguration
|
||||
|
||||
for (rawKey, value) in self {
|
||||
if let key = rawKey as? String, opt = NSDictionary.keyValueToSocketIOClientOption(key, value: value) {
|
||||
options.insert(opt)
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
}
|
||||
|
||||
extension String {
|
||||
func toArray() throws -> [AnyObject] {
|
||||
guard let stringData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) else { return [] }
|
||||
guard let array = try NSJSONSerialization.JSONObjectWithData(stringData, options: .MutableContainers) as? [AnyObject] else {
|
||||
throw JSONError.notArray
|
||||
}
|
||||
|
||||
return array
|
||||
}
|
||||
|
||||
func toNSDictionary() throws -> NSDictionary {
|
||||
guard let binData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) else { return [:] }
|
||||
guard let json = try NSJSONSerialization.JSONObjectWithData(binData, options: .AllowFragments) as? NSDictionary else {
|
||||
throw JSONError.notNSDictionary
|
||||
}
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
func urlEncode() -> String? {
|
||||
return stringByAddingPercentEncodingWithAllowedCharacters(.allowedURLCharacterSet)
|
||||
}
|
||||
}
|
||||
+35
-30
@@ -42,13 +42,11 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
|
||||
public var forceNew = false
|
||||
public var nsp = "/"
|
||||
public var options: Set<SocketIOClientOption>
|
||||
public var config: SocketIOClientConfiguration
|
||||
public var reconnects = true
|
||||
public var reconnectWait = 10
|
||||
public var sid: String? {
|
||||
return nsp + "#" + (engine?.sid ?? "")
|
||||
}
|
||||
|
||||
private let ackQueue = dispatch_queue_create("com.socketio.ackQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let emitQueue = dispatch_queue_create("com.socketio.emitQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let logType = "SocketIOClient"
|
||||
private let parseQueue = dispatch_queue_create("com.socketio.parseQueue", DISPATCH_QUEUE_SERIAL)
|
||||
@@ -65,16 +63,20 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
|
||||
var waitingPackets = [SocketPacket]()
|
||||
|
||||
public var sid: String? {
|
||||
return nsp + "#" + (engine?.sid ?? "")
|
||||
}
|
||||
|
||||
/// Type safe way to create a new SocketIOClient. opts can be omitted
|
||||
public init(socketURL: NSURL, options: Set<SocketIOClientOption> = []) {
|
||||
self.options = options
|
||||
public init(socketURL: NSURL, config: SocketIOClientConfiguration = []) {
|
||||
self.config = config
|
||||
self.socketURL = socketURL
|
||||
|
||||
if socketURL.absoluteString.hasPrefix("https://") {
|
||||
self.options.insertIgnore(.Secure(true))
|
||||
self.config.insert(.Secure(true))
|
||||
}
|
||||
|
||||
for option in options {
|
||||
for option in config {
|
||||
switch option {
|
||||
case let .Reconnects(reconnects):
|
||||
self.reconnects = reconnects
|
||||
@@ -97,15 +99,15 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
}
|
||||
}
|
||||
|
||||
self.options.insertIgnore(.Path("/socket.io/"))
|
||||
self.config.insert(.Path("/socket.io/"), replacing: false)
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
/// Not so type safe way to create a SocketIOClient, meant for Objective-C compatiblity.
|
||||
/// If using Swift it's recommended to use `init(socketURL: NSURL, options: Set<SocketIOClientOption>)`
|
||||
public convenience init(socketURL: NSURL, options: NSDictionary?) {
|
||||
self.init(socketURL: socketURL, options: options?.toSocketOptionsSet() ?? [])
|
||||
public convenience init(socketURL: NSURL, config: NSDictionary?) {
|
||||
self.init(socketURL: socketURL, config: config?.toSocketConfiguration() ?? [])
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -116,7 +118,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
private func addEngine() -> SocketEngineSpec {
|
||||
DefaultSocketLogger.Logger.log("Adding engine", type: logType)
|
||||
|
||||
engine = SocketEngine(client: self, url: socketURL, options: options)
|
||||
engine = SocketEngine(client: self, url: socketURL, config: config)
|
||||
|
||||
return engine!
|
||||
}
|
||||
@@ -162,14 +164,18 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
|
||||
return {[weak self, ack = currentAck] timeout, callback in
|
||||
if let this = self {
|
||||
this.ackHandlers.addAck(ack, callback: callback)
|
||||
dispatch_sync(this.ackQueue) {
|
||||
this.ackHandlers.addAck(ack, callback: callback)
|
||||
}
|
||||
|
||||
|
||||
this._emit(items, ack: ack)
|
||||
|
||||
if timeout != 0 {
|
||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
||||
|
||||
dispatch_after(time, this.handleQueue) {
|
||||
this.ackHandlers.timeoutAck(ack)
|
||||
dispatch_after(time, this.ackQueue) {
|
||||
this.ackHandlers.timeoutAck(ack, onQueue: this.handleQueue)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -197,8 +203,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
handleEvent("disconnect", data: [reason], isInternalMessage: true)
|
||||
}
|
||||
|
||||
/// Disconnects the socket. Only reconnect the same socket if you know what you're doing.
|
||||
/// Will turn off automatic reconnects.
|
||||
/// Disconnects the socket.
|
||||
public func disconnect() {
|
||||
assert(status != .NotConnected, "Tried closing a NotConnected client")
|
||||
|
||||
@@ -295,7 +300,9 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
|
||||
DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "")
|
||||
|
||||
ackHandlers.executeAck(ack, items: data)
|
||||
dispatch_async(ackQueue) {
|
||||
self.ackHandlers.executeAck(ack, items: data, onQueue: self.handleQueue)
|
||||
}
|
||||
}
|
||||
|
||||
/// Causes an event to be handled. Only use if you know what you're doing.
|
||||
@@ -407,18 +414,16 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
}
|
||||
|
||||
private func tryReconnectWithReason(reason: String) {
|
||||
if reconnecting {
|
||||
DefaultSocketLogger.Logger.log("Starting reconnect", type: logType)
|
||||
handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
||||
|
||||
_tryReconnect()
|
||||
}
|
||||
guard reconnecting else { return }
|
||||
|
||||
DefaultSocketLogger.Logger.log("Starting reconnect", type: logType)
|
||||
handleEvent("reconnect", data: [reason], isInternalMessage: true)
|
||||
|
||||
_tryReconnect()
|
||||
}
|
||||
|
||||
private func _tryReconnect() {
|
||||
if !reconnecting {
|
||||
return
|
||||
}
|
||||
guard reconnecting else { return }
|
||||
|
||||
if reconnectAttempts != -1 && currentReconnectAttempt + 1 > reconnectAttempts || !reconnects {
|
||||
return didDisconnect("Reconnect Failed")
|
||||
@@ -431,9 +436,9 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
||||
currentReconnectAttempt += 1
|
||||
connect()
|
||||
|
||||
let dispatchAfter = dispatch_time(DISPATCH_TIME_NOW, Int64(UInt64(reconnectWait) * NSEC_PER_SEC))
|
||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(UInt64(reconnectWait) * NSEC_PER_SEC))
|
||||
|
||||
dispatch_after(dispatchAfter, dispatch_get_main_queue(), _tryReconnect)
|
||||
dispatch_after(time, dispatch_get_main_queue(), _tryReconnect)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -452,6 +457,6 @@ extension SocketIOClient {
|
||||
}
|
||||
|
||||
func emitTest(event: String, _ data: AnyObject...) {
|
||||
self._emit([event] + data)
|
||||
_emit([event] + data)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// SocketIOClientConfiguration.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 8/13/16.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
public struct SocketIOClientConfiguration : ArrayLiteralConvertible, CollectionType, MutableCollectionType {
|
||||
public typealias Element = SocketIOClientOption
|
||||
public typealias Index = Array<SocketIOClientOption>.Index
|
||||
public typealias Generator = Array<SocketIOClientOption>.Generator
|
||||
public typealias SubSequence = Array<SocketIOClientOption>.SubSequence
|
||||
|
||||
private var backingArray = [SocketIOClientOption]()
|
||||
|
||||
public var startIndex: Index {
|
||||
return backingArray.startIndex
|
||||
}
|
||||
|
||||
public var endIndex: Index {
|
||||
return backingArray.endIndex
|
||||
}
|
||||
|
||||
public var isEmpty: Bool {
|
||||
return backingArray.isEmpty
|
||||
}
|
||||
|
||||
public var count: Index.Distance {
|
||||
return backingArray.count
|
||||
}
|
||||
|
||||
public var first: Generator.Element? {
|
||||
return backingArray.first
|
||||
}
|
||||
|
||||
public subscript(position: Index) -> Generator.Element {
|
||||
get {
|
||||
return backingArray[position]
|
||||
}
|
||||
|
||||
set {
|
||||
backingArray[position] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
public subscript(bounds: Range<Index>) -> SubSequence {
|
||||
get {
|
||||
return backingArray[bounds]
|
||||
}
|
||||
|
||||
set {
|
||||
backingArray[bounds] = newValue
|
||||
}
|
||||
}
|
||||
|
||||
public init(arrayLiteral elements: Element...) {
|
||||
backingArray = elements
|
||||
}
|
||||
|
||||
public func generate() -> Generator {
|
||||
return backingArray.generate()
|
||||
}
|
||||
|
||||
public mutating func insert(element: Element, replacing replace: Bool = true) {
|
||||
for i in 0..<backingArray.count where backingArray[i] == element {
|
||||
guard replace else { return }
|
||||
|
||||
backingArray[i] = element
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
backingArray.append(element)
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
public func prefixUpTo(end: Index) -> SubSequence {
|
||||
return backingArray.prefixUpTo(end)
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
public func prefixThrough(position: Index) -> SubSequence {
|
||||
return backingArray.prefixThrough(position)
|
||||
}
|
||||
|
||||
@warn_unused_result
|
||||
public func suffixFrom(start: Index) -> SubSequence {
|
||||
return backingArray.suffixFrom(start)
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
protocol ClientOption : CustomStringConvertible, Hashable {
|
||||
protocol ClientOption : CustomStringConvertible, Equatable {
|
||||
func getSocketIOOptionValue() -> AnyObject
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ public enum SocketIOClientOption : ClientOption {
|
||||
case ReconnectAttempts(Int)
|
||||
case ReconnectWait(Int)
|
||||
case Secure(Bool)
|
||||
case Security(SSLSecurity)
|
||||
case SelfSigned(Bool)
|
||||
case SessionDelegate(NSURLSessionDelegate)
|
||||
case VoipEnabled(Bool)
|
||||
@@ -85,6 +86,8 @@ public enum SocketIOClientOption : ClientOption {
|
||||
description = "reconnectWait"
|
||||
case .Secure:
|
||||
description = "secure"
|
||||
case .Security:
|
||||
description = "security"
|
||||
case .SelfSigned:
|
||||
description = "selfSigned"
|
||||
case .SessionDelegate:
|
||||
@@ -96,10 +99,6 @@ public enum SocketIOClientOption : ClientOption {
|
||||
return description
|
||||
}
|
||||
|
||||
public var hashValue: Int {
|
||||
return description.hashValue
|
||||
}
|
||||
|
||||
func getSocketIOOptionValue() -> AnyObject {
|
||||
let value: AnyObject
|
||||
|
||||
@@ -136,6 +135,8 @@ public enum SocketIOClientOption : ClientOption {
|
||||
value = wait
|
||||
case let .Secure(secure):
|
||||
value = secure
|
||||
case let .Security(security):
|
||||
value = security
|
||||
case let .SelfSigned(signed):
|
||||
value = signed
|
||||
case let .SessionDelegate(delegate):
|
||||
@@ -151,70 +152,3 @@ public enum SocketIOClientOption : ClientOption {
|
||||
public func ==(lhs: SocketIOClientOption, rhs: SocketIOClientOption) -> Bool {
|
||||
return lhs.description == rhs.description
|
||||
}
|
||||
|
||||
extension Set where Element : ClientOption {
|
||||
mutating func insertIgnore(element: Element) {
|
||||
if !contains(element) {
|
||||
insert(element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension NSDictionary {
|
||||
private static func keyValueToSocketIOClientOption(key: String, value: AnyObject) -> SocketIOClientOption? {
|
||||
switch (key, value) {
|
||||
case let ("connectParams", params as [String: AnyObject]):
|
||||
return .ConnectParams(params)
|
||||
case let ("cookies", cookies as [NSHTTPCookie]):
|
||||
return .Cookies(cookies)
|
||||
case let ("doubleEncodeUTF8", encode as Bool):
|
||||
return .DoubleEncodeUTF8(encode)
|
||||
case let ("extraHeaders", headers as [String: String]):
|
||||
return .ExtraHeaders(headers)
|
||||
case let ("forceNew", force as Bool):
|
||||
return .ForceNew(force)
|
||||
case let ("forcePolling", force as Bool):
|
||||
return .ForcePolling(force)
|
||||
case let ("forceWebsockets", force as Bool):
|
||||
return .ForceWebsockets(force)
|
||||
case let ("handleQueue", queue as dispatch_queue_t):
|
||||
return .HandleQueue(queue)
|
||||
case let ("log", log as Bool):
|
||||
return .Log(log)
|
||||
case let ("logger", logger as SocketLogger):
|
||||
return .Logger(logger)
|
||||
case let ("nsp", nsp as String):
|
||||
return .Nsp(nsp)
|
||||
case let ("path", path as String):
|
||||
return .Path(path)
|
||||
case let ("reconnects", reconnects as Bool):
|
||||
return .Reconnects(reconnects)
|
||||
case let ("reconnectAttempts", attempts as Int):
|
||||
return .ReconnectAttempts(attempts)
|
||||
case let ("reconnectWait", wait as Int):
|
||||
return .ReconnectWait(wait)
|
||||
case let ("secure", secure as Bool):
|
||||
return .Secure(secure)
|
||||
case let ("selfSigned", selfSigned as Bool):
|
||||
return .SelfSigned(selfSigned)
|
||||
case let ("sessionDelegate", delegate as NSURLSessionDelegate):
|
||||
return .SessionDelegate(delegate)
|
||||
case let ("voipEnabled", enable as Bool):
|
||||
return .VoipEnabled(enable)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func toSocketOptionsSet() -> Set<SocketIOClientOption> {
|
||||
var options = Set<SocketIOClientOption>()
|
||||
|
||||
for (rawKey, value) in self {
|
||||
if let key = rawKey as? String, opt = NSDictionary.keyValueToSocketIOClientOption(key, value: value) {
|
||||
options.insertIgnore(opt)
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
}
|
||||
+16
-75
@@ -26,6 +26,10 @@
|
||||
import Foundation
|
||||
|
||||
struct SocketPacket {
|
||||
enum PacketType: Int {
|
||||
case Connect, Disconnect, Event, Ack, Error, BinaryEvent, BinaryAck
|
||||
}
|
||||
|
||||
private let placeholders: Int
|
||||
|
||||
private static let logType = "SocketPacket"
|
||||
@@ -34,9 +38,8 @@ struct SocketPacket {
|
||||
let id: Int
|
||||
let type: PacketType
|
||||
|
||||
enum PacketType: Int {
|
||||
case Connect, Disconnect, Event, Ack, Error, BinaryEvent, BinaryAck
|
||||
}
|
||||
var binary: [NSData]
|
||||
var data: [AnyObject]
|
||||
|
||||
var args: [AnyObject] {
|
||||
if type == .Event || type == .BinaryEvent && data.count != 0 {
|
||||
@@ -46,8 +49,6 @@ struct SocketPacket {
|
||||
}
|
||||
}
|
||||
|
||||
var binary: [NSData]
|
||||
var data: [AnyObject]
|
||||
var description: String {
|
||||
return "SocketPacket {type: \(String(type.rawValue)); data: " +
|
||||
"\(String(data)); id: \(id); placeholders: \(placeholders); nsp: \(nsp)}"
|
||||
@@ -94,11 +95,8 @@ struct SocketPacket {
|
||||
}
|
||||
|
||||
do {
|
||||
let jsonSend = try NSJSONSerialization.dataWithJSONObject(data,
|
||||
options: NSJSONWritingOptions(rawValue: 0))
|
||||
guard let jsonString = String(data: jsonSend, encoding: NSUTF8StringEncoding) else {
|
||||
return message + "[]"
|
||||
}
|
||||
let jsonSend = try data.toJSON()
|
||||
guard let jsonString = String(data: jsonSend, encoding: NSUTF8StringEncoding) else { return message + "[]" }
|
||||
|
||||
restOfMessage = jsonString
|
||||
} catch {
|
||||
@@ -111,73 +109,16 @@ struct SocketPacket {
|
||||
return message + restOfMessage
|
||||
}
|
||||
|
||||
private func createAck() -> String {
|
||||
let message: String
|
||||
|
||||
if type == .Ack {
|
||||
if nsp == "/" {
|
||||
message = "3\(id)"
|
||||
} else {
|
||||
message = "3\(nsp),\(id)"
|
||||
}
|
||||
} else {
|
||||
if nsp == "/" {
|
||||
message = "6\(binary.count)-\(id)"
|
||||
} else {
|
||||
message = "6\(binary.count)-\(nsp),\(id)"
|
||||
}
|
||||
}
|
||||
|
||||
return completeMessage(message)
|
||||
}
|
||||
|
||||
|
||||
private func createMessageForEvent() -> String {
|
||||
let message: String
|
||||
|
||||
if type == .Event {
|
||||
if nsp == "/" {
|
||||
if id == -1 {
|
||||
message = "2"
|
||||
} else {
|
||||
message = "2\(id)"
|
||||
}
|
||||
} else {
|
||||
if id == -1 {
|
||||
message = "2\(nsp),"
|
||||
} else {
|
||||
message = "2\(nsp),\(id)"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if nsp == "/" {
|
||||
if id == -1 {
|
||||
message = "5\(binary.count)-"
|
||||
} else {
|
||||
message = "5\(binary.count)-\(id)"
|
||||
}
|
||||
} else {
|
||||
if id == -1 {
|
||||
message = "5\(binary.count)-\(nsp),"
|
||||
} else {
|
||||
message = "5\(binary.count)-\(nsp),\(id)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return completeMessage(message)
|
||||
}
|
||||
|
||||
private func createPacketString() -> String {
|
||||
let str: String
|
||||
let typeString = String(type.rawValue)
|
||||
// Binary count?
|
||||
let binaryCountString = typeString + (type == .BinaryEvent || type == .BinaryAck ? String(binary.count) + "-" : "")
|
||||
// Namespace?
|
||||
let nspString = binaryCountString + (nsp != "/" ? nsp + "," : "")
|
||||
// Ack number?
|
||||
let idString = nspString + (id != -1 ? String(id) : "")
|
||||
|
||||
if type == .Event || type == .BinaryEvent {
|
||||
str = createMessageForEvent()
|
||||
} else {
|
||||
str = createAck()
|
||||
}
|
||||
|
||||
return str
|
||||
return completeMessage(idString)
|
||||
}
|
||||
|
||||
// Called when we have all the binary data for a packet
|
||||
|
||||
+22
-31
@@ -32,8 +32,8 @@ extension SocketParsable {
|
||||
return nsp == self.nsp
|
||||
}
|
||||
|
||||
private func handleConnect(p: SocketPacket) {
|
||||
if p.nsp == "/" && nsp != "/" {
|
||||
private func handleConnect(packetNamespace: String) {
|
||||
if packetNamespace == "/" && nsp != "/" {
|
||||
joinNamespace(nsp)
|
||||
} else {
|
||||
didConnect()
|
||||
@@ -51,7 +51,7 @@ extension SocketParsable {
|
||||
case .BinaryAck where isCorrectNamespace(pack.nsp):
|
||||
waitingPackets.append(pack)
|
||||
case .Connect:
|
||||
handleConnect(pack)
|
||||
handleConnect(pack.nsp)
|
||||
case .Disconnect:
|
||||
didDisconnect("Got Disconnect")
|
||||
case .Error:
|
||||
@@ -63,13 +63,13 @@ extension SocketParsable {
|
||||
|
||||
/// Parses a messsage from the engine. Returning either a string error or a complete SocketPacket
|
||||
func parseString(message: String) -> Either<String, SocketPacket> {
|
||||
var parser = SocketStringReader(message: message)
|
||||
var reader = SocketStringReader(message: message)
|
||||
|
||||
guard let type = SocketPacket.PacketType(rawValue: Int(parser.read(1)) ?? -1) else {
|
||||
guard let type = SocketPacket.PacketType(rawValue: Int(reader.read(1)) ?? -1) else {
|
||||
return .Left("Invalid packet type")
|
||||
}
|
||||
|
||||
if !parser.hasNext {
|
||||
if !reader.hasNext {
|
||||
return .Right(SocketPacket(type: type, nsp: "/"))
|
||||
}
|
||||
|
||||
@@ -77,37 +77,37 @@ extension SocketParsable {
|
||||
var placeholders = -1
|
||||
|
||||
if type == .BinaryEvent || type == .BinaryAck {
|
||||
if let holders = Int(parser.readUntilStringOccurence("-")) {
|
||||
if let holders = Int(reader.readUntilStringOccurence("-")) {
|
||||
placeholders = holders
|
||||
} else {
|
||||
return .Left("Invalid packet")
|
||||
}
|
||||
}
|
||||
|
||||
if parser.currentCharacter == "/" {
|
||||
namespace = parser.readUntilStringOccurence(",") ?? parser.readUntilEnd()
|
||||
if reader.currentCharacter == "/" {
|
||||
namespace = reader.readUntilStringOccurence(",") ?? reader.readUntilEnd()
|
||||
}
|
||||
|
||||
if !parser.hasNext {
|
||||
if !reader.hasNext {
|
||||
return .Right(SocketPacket(type: type, nsp: namespace, placeholders: placeholders))
|
||||
}
|
||||
|
||||
var idString = ""
|
||||
|
||||
if type == .Error {
|
||||
parser.advanceIndexBy(-1)
|
||||
}
|
||||
|
||||
while parser.hasNext && type != .Error {
|
||||
if let int = Int(parser.read(1)) {
|
||||
idString += String(int)
|
||||
} else {
|
||||
parser.advanceIndexBy(-2)
|
||||
break
|
||||
reader.advanceIndexBy(-1)
|
||||
} else {
|
||||
while reader.hasNext {
|
||||
if let int = Int(reader.read(1)) {
|
||||
idString += String(int)
|
||||
} else {
|
||||
reader.advanceIndexBy(-2)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let d = message[parser.currentIndex.advancedBy(1)..<message.endIndex]
|
||||
let d = message[reader.currentIndex.advancedBy(1)..<message.endIndex]
|
||||
|
||||
switch parseData(d) {
|
||||
case let .Left(err):
|
||||
@@ -126,15 +126,8 @@ extension SocketParsable {
|
||||
|
||||
// Parses data for events
|
||||
private func parseData(data: String) -> Either<String, [AnyObject]> {
|
||||
let stringData = data.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
|
||||
|
||||
do {
|
||||
if let arr = try NSJSONSerialization.JSONObjectWithData(stringData!,
|
||||
options: NSJSONReadingOptions.MutableContainers) as? [AnyObject] {
|
||||
return .Right(arr)
|
||||
} else {
|
||||
return .Left("Expected data array")
|
||||
}
|
||||
return .Right(try data.toArray())
|
||||
} catch {
|
||||
return .Left("Error parsing data for packet")
|
||||
}
|
||||
@@ -162,9 +155,7 @@ extension SocketParsable {
|
||||
}
|
||||
|
||||
// Should execute event?
|
||||
guard waitingPackets[waitingPackets.count - 1].addData(data) else {
|
||||
return
|
||||
}
|
||||
guard waitingPackets[waitingPackets.count - 1].addData(data) else { return }
|
||||
|
||||
let packet = waitingPackets.removeLast()
|
||||
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
//
|
||||
// String.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Yannick Loriot on 5/4/16.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
import Foundation
|
||||
|
||||
extension String {
|
||||
func urlEncode() -> String? {
|
||||
return stringByAddingPercentEncodingWithAllowedCharacters(.allowedURLCharacterSet)
|
||||
}
|
||||
}
|
||||
+106
-303
@@ -23,6 +23,10 @@ import Foundation
|
||||
import CoreFoundation
|
||||
import Security
|
||||
|
||||
public let WebsocketDidConnectNotification = "WebsocketDidConnectNotification"
|
||||
public let WebsocketDidDisconnectNotification = "WebsocketDidDisconnectNotification"
|
||||
public let WebsocketDisconnectionErrorKeyName = "WebsocketDisconnectionErrorKeyName"
|
||||
|
||||
public protocol WebSocketDelegate: class {
|
||||
func websocketDidConnect(socket: WebSocket)
|
||||
func websocketDidDisconnect(socket: WebSocket, error: NSError?)
|
||||
@@ -34,44 +38,46 @@ public protocol WebSocketPongDelegate: class {
|
||||
func websocketDidReceivePong(socket: WebSocket)
|
||||
}
|
||||
|
||||
public class WebSocket : NSObject, NSStreamDelegate {
|
||||
public class WebSocket: NSObject, NSStreamDelegate {
|
||||
|
||||
enum OpCode : UInt8 {
|
||||
enum OpCode: UInt8 {
|
||||
case ContinueFrame = 0x0
|
||||
case TextFrame = 0x1
|
||||
case BinaryFrame = 0x2
|
||||
//3-7 are reserved.
|
||||
// 3-7 are reserved.
|
||||
case ConnectionClose = 0x8
|
||||
case Ping = 0x9
|
||||
case Pong = 0xA
|
||||
//B-F reserved.
|
||||
// B-F reserved.
|
||||
}
|
||||
|
||||
public enum CloseCode : UInt16 {
|
||||
public enum CloseCode: UInt16 {
|
||||
case Normal = 1000
|
||||
case GoingAway = 1001
|
||||
case ProtocolError = 1002
|
||||
case ProtocolUnhandledType = 1003
|
||||
// 1004 reserved.
|
||||
case NoStatusReceived = 1005
|
||||
//1006 reserved.
|
||||
// 1006 reserved.
|
||||
case Encoding = 1007
|
||||
case PolicyViolated = 1008
|
||||
case MessageTooBig = 1009
|
||||
}
|
||||
|
||||
public static let ErrorDomain = "WebSocket"
|
||||
public static let ErrorDomain = "WebSocket"
|
||||
|
||||
enum InternalErrorCode : UInt16 {
|
||||
enum InternalErrorCode: UInt16 {
|
||||
// 0-999 WebSocket status codes not used
|
||||
case OutputStreamWriteError = 1
|
||||
}
|
||||
|
||||
//Where the callback is executed. It defaults to the main UI thread queue.
|
||||
public var queue = dispatch_get_main_queue()
|
||||
/// Where the callback is executed. It defaults to the main UI thread queue.
|
||||
public var callbackQueue = dispatch_get_main_queue()
|
||||
|
||||
var optionalProtocols : [String]?
|
||||
//Constant Values.
|
||||
|
||||
// MARK: - Constants
|
||||
|
||||
let headerWSUpgradeName = "Upgrade"
|
||||
let headerWSUpgradeValue = "websocket"
|
||||
let headerWSHostName = "Host"
|
||||
@@ -90,6 +96,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
let MaskMask: UInt8 = 0x80
|
||||
let PayloadLenMask: UInt8 = 0x7F
|
||||
let MaxFrameSize: Int = 32
|
||||
let httpSwitchProtocolCode = 101
|
||||
let supportedSSLSchemes = ["wss", "https"]
|
||||
|
||||
class WSResponse {
|
||||
var isFin = false
|
||||
@@ -99,13 +107,24 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
var buffer: NSMutableData?
|
||||
}
|
||||
|
||||
// MARK: - Delegates
|
||||
|
||||
/// Responds to callback about new messages coming in over the WebSocket
|
||||
/// and also connection/disconnect messages.
|
||||
public weak var delegate: WebSocketDelegate?
|
||||
|
||||
/// Recives a callback for each pong message recived.
|
||||
public weak var pongDelegate: WebSocketPongDelegate?
|
||||
|
||||
|
||||
// MARK: - Block based API.
|
||||
|
||||
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 = [String: String]()
|
||||
public var voipEnabled = false
|
||||
public var selfSignedSSL = false
|
||||
@@ -116,12 +135,15 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
public var isConnected :Bool {
|
||||
return connected
|
||||
}
|
||||
public var currentURL: NSURL {return url}
|
||||
public var currentURL: NSURL { return url }
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private var url: NSURL
|
||||
private var inputStream: NSInputStream?
|
||||
private var outputStream: NSOutputStream?
|
||||
private var connected = false
|
||||
private var isCreated = false
|
||||
private var isConnecting = false
|
||||
private var writeQueue = NSOperationQueue()
|
||||
private var readStack = [WSResponse]()
|
||||
private var inputQueue = [NSData]()
|
||||
@@ -130,16 +152,18 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
private var didDisconnect = false
|
||||
private var readyToWrite = false
|
||||
private let mutex = NSLock()
|
||||
private let notificationCenter = NSNotificationCenter.defaultCenter()
|
||||
private var canDispatch: Bool {
|
||||
mutex.lock()
|
||||
let canWork = readyToWrite
|
||||
mutex.unlock()
|
||||
return canWork
|
||||
}
|
||||
//the shared processing queue used for all websocket
|
||||
|
||||
/// The shared processing queue used for all WebSocket.
|
||||
private static let sharedWorkQueue = dispatch_queue_create("com.vluxe.starscream.websocket", DISPATCH_QUEUE_SERIAL)
|
||||
|
||||
//used for setting protocols.
|
||||
/// Used for setting protocols.
|
||||
public init(url: NSURL, protocols: [String]? = nil) {
|
||||
self.url = url
|
||||
self.origin = url.absoluteString
|
||||
@@ -147,13 +171,13 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
optionalProtocols = protocols
|
||||
}
|
||||
|
||||
///Connect to the websocket server on a background thread
|
||||
/// Connect to the WebSocket server on a background thread.
|
||||
public func connect() {
|
||||
guard !isCreated else { return }
|
||||
guard !isConnecting else { return }
|
||||
didDisconnect = false
|
||||
isCreated = true
|
||||
isConnecting = true
|
||||
createHTTPRequest()
|
||||
isCreated = false
|
||||
isConnecting = false
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,7 +192,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
public func disconnect(forceTimeout forceTimeout: NSTimeInterval? = nil) {
|
||||
switch forceTimeout {
|
||||
case .Some(let seconds) where seconds > 0:
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(seconds * Double(NSEC_PER_SEC))), queue) { [weak self] in
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(seconds * Double(NSEC_PER_SEC))), callbackQueue) { [weak self] in
|
||||
self?.disconnectStream(nil)
|
||||
}
|
||||
fallthrough
|
||||
@@ -176,7 +200,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
writeError(CloseCode.Normal.rawValue)
|
||||
|
||||
default:
|
||||
self.disconnectStream(nil)
|
||||
disconnectStream(nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -185,6 +209,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
Write a string to the websocket. This sends it as a text frame.
|
||||
|
||||
If you supply a non-nil completion block, I will perform it when the write completes.
|
||||
|
||||
- parameter str: The string to write.
|
||||
- parameter completion: The (optional) completion handler.
|
||||
*/
|
||||
@@ -197,6 +222,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
Write binary data to the websocket. This sends it as a binary frame.
|
||||
|
||||
If you supply a non-nil completion block, I will perform it when the write completes.
|
||||
|
||||
- parameter data: The data to write.
|
||||
- parameter completion: The (optional) completion handler.
|
||||
*/
|
||||
@@ -205,14 +231,14 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
dequeueWrite(data, code: .BinaryFrame, writeCompletion: completion)
|
||||
}
|
||||
|
||||
//write a ping to the websocket. This sends it as a control frame.
|
||||
//yodel a sound to the planet. This sends it as an astroid. http://youtu.be/Eu5ZJELRiJ8?t=42s
|
||||
// Write a ping to the websocket. This sends it as a control frame.
|
||||
// Yodel a sound to the planet. This sends it as an astroid. http://youtu.be/Eu5ZJELRiJ8?t=42s
|
||||
public func writePing(data: NSData, completion: (() -> ())? = nil) {
|
||||
guard isConnected else { return }
|
||||
dequeueWrite(data, code: .Ping, writeCompletion: completion)
|
||||
}
|
||||
|
||||
//private method that starts the connection
|
||||
/// Private method that starts the connection.
|
||||
private func createHTTPRequest() {
|
||||
|
||||
let urlRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault, "GET",
|
||||
@@ -220,7 +246,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
|
||||
var port = url.port
|
||||
if port == nil {
|
||||
if ["wss", "https"].contains(url.scheme) {
|
||||
if supportedSSLSchemes.contains(url.scheme) {
|
||||
port = 443
|
||||
} else {
|
||||
port = 80
|
||||
@@ -246,12 +272,12 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
//Add a header to the CFHTTPMessage by using the NSString bridges to CFString
|
||||
/// Add a header to the CFHTTPMessage by using the NSString bridges to CFString.
|
||||
private func addHeader(urlRequest: CFHTTPMessage, key: NSString, val: NSString) {
|
||||
CFHTTPMessageSetHeaderFieldValue(urlRequest, key, val)
|
||||
}
|
||||
|
||||
//generate a websocket key as needed in rfc
|
||||
/// Generate a WebSocket key as needed in RFC.
|
||||
private func generateWebSocketKey() -> String {
|
||||
var key = ""
|
||||
let seed = 16
|
||||
@@ -264,7 +290,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
return baseKey!
|
||||
}
|
||||
|
||||
//Start the stream connection and write the data to the output stream
|
||||
/// Start the stream connection and write the data to the output stream.
|
||||
private func initStreamsWithData(data: NSData, _ port: Int) {
|
||||
//higher level API we will cut over to at some point
|
||||
//NSStream.getStreamsToHostWithName(url.host, port: url.port.integerValue, inputStream: &inputStream, outputStream: &outputStream)
|
||||
@@ -278,7 +304,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
guard let inStream = inputStream, let outStream = outputStream else { return }
|
||||
inStream.delegate = self
|
||||
outStream.delegate = self
|
||||
if ["wss", "https"].contains(url.scheme) {
|
||||
if supportedSSLSchemes.contains(url.scheme) {
|
||||
inStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
|
||||
outStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey)
|
||||
} else {
|
||||
@@ -289,7 +315,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
outStream.setProperty(NSStreamNetworkServiceTypeVoIP, forKey: NSStreamNetworkServiceType)
|
||||
}
|
||||
if selfSignedSSL {
|
||||
let settings: [NSObject: NSObject] = [kCFStreamSSLValidatesCertificateChain: NSNumber(bool:false), kCFStreamSSLPeerName: kCFNull]
|
||||
let settings: [NSObject: NSObject] = [kCFStreamSSLValidatesCertificateChain: NSNumber(bool: false), kCFStreamSSLPeerName: kCFNull]
|
||||
inStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String)
|
||||
outStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String)
|
||||
}
|
||||
@@ -320,23 +346,24 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
self.mutex.unlock()
|
||||
|
||||
let bytes = UnsafePointer<UInt8>(data.bytes)
|
||||
var out = timeout * 1000000 //wait 5 seconds before giving up
|
||||
var out = timeout * 1000000 // wait 5 seconds before giving up
|
||||
writeQueue.addOperationWithBlock { [weak self] in
|
||||
while !outStream.hasSpaceAvailable {
|
||||
usleep(100) //wait until the socket is ready
|
||||
usleep(100) // wait until the socket is ready
|
||||
out -= 100
|
||||
if out < 0 {
|
||||
self?.cleanupStream()
|
||||
self?.doDisconnect(self?.errorWithDetail("write wait timed out", code: 2))
|
||||
return
|
||||
} else if outStream.streamError != nil {
|
||||
return //disconnectStream will be called.
|
||||
return // disconnectStream will be called.
|
||||
}
|
||||
}
|
||||
outStream.write(bytes, maxLength: data.length)
|
||||
}
|
||||
}
|
||||
//delegate for the stream methods. Processes incoming bytes
|
||||
|
||||
// Delegate for the stream methods. Processes incoming bytes.
|
||||
public func stream(aStream: NSStream, handleEvent eventCode: NSStreamEvent) {
|
||||
|
||||
if let sec = security where !certValidated && [.HasBytesAvailable, .HasSpaceAvailable].contains(eventCode) {
|
||||
@@ -362,7 +389,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
disconnectStream(nil)
|
||||
}
|
||||
}
|
||||
//disconnect the stream object
|
||||
|
||||
/// Disconnect the stream object and notifies the delegate.
|
||||
private func disconnectStream(error: NSError?) {
|
||||
if error == nil {
|
||||
writeQueue.waitUntilAllOperationsAreFinished()
|
||||
@@ -388,7 +416,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
inputStream = nil
|
||||
}
|
||||
|
||||
///handles the incoming bytes and sending them to the proper processing method
|
||||
/// Handles the incoming bytes and sending them to the proper processing method.
|
||||
private func processInputStream() {
|
||||
let buf = NSMutableData(capacity: BUFFER_MAX)
|
||||
let buffer = UnsafeMutablePointer<UInt8>(buf!.bytes)
|
||||
@@ -404,7 +432,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
dequeueInput()
|
||||
}
|
||||
}
|
||||
///dequeue the incoming input so it is processed in order
|
||||
|
||||
/// Dequeue the incoming input so it is processed in order.
|
||||
private func dequeueInput() {
|
||||
while !inputQueue.isEmpty {
|
||||
let data = inputQueue[0]
|
||||
@@ -422,30 +451,32 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
} else {
|
||||
processRawMessagesInBuffer(buffer, bufferLen: length)
|
||||
}
|
||||
inputQueue = inputQueue.filter{$0 != data}
|
||||
inputQueue = inputQueue.filter{ $0 != data }
|
||||
}
|
||||
}
|
||||
|
||||
//handle checking the inital connection status
|
||||
// Handle checking the initial connection status.
|
||||
private func processTCPHandshake(buffer: UnsafePointer<UInt8>, bufferLen: Int) {
|
||||
let code = processHTTP(buffer, bufferLen: bufferLen)
|
||||
switch code {
|
||||
case 0:
|
||||
connected = true
|
||||
guard canDispatch else {return}
|
||||
dispatch_async(queue) { [weak self] in
|
||||
dispatch_async(callbackQueue) { [weak self] in
|
||||
guard let s = self else { return }
|
||||
s.onConnect?()
|
||||
s.delegate?.websocketDidConnect(s)
|
||||
s.notificationCenter.postNotificationName(WebsocketDidConnectNotification, object: self)
|
||||
}
|
||||
case -1:
|
||||
fragBuffer = NSData(bytes: buffer, length: bufferLen)
|
||||
break //do nothing, we are going to collect more data
|
||||
break // do nothing, we are going to collect more data
|
||||
default:
|
||||
doDisconnect(errorWithDetail("Invalid HTTP upgrade", code: UInt16(code)))
|
||||
}
|
||||
}
|
||||
///Finds the HTTP Packet in the TCP stream, by looking for the CRLF.
|
||||
|
||||
/// Finds the HTTP Packet in the TCP stream, by looking for the CRLF.
|
||||
private func processHTTP(buffer: UnsafePointer<UInt8>, bufferLen: Int) -> Int {
|
||||
let CRLFBytes = [UInt8(ascii: "\r"), UInt8(ascii: "\n"), UInt8(ascii: "\r"), UInt8(ascii: "\n")]
|
||||
var k = 0
|
||||
@@ -473,15 +504,15 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
return 0 //success
|
||||
}
|
||||
return -1 //was unable to find the full TCP header
|
||||
return -1 // Was unable to find the full TCP header.
|
||||
}
|
||||
|
||||
///validates the HTTP is a 101 as per the RFC spec
|
||||
/// Validates the HTTP is a 101 as per the RFC spec.
|
||||
private func validateResponse(buffer: UnsafePointer<UInt8>, bufferLen: Int) -> Int {
|
||||
let response = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, false).takeRetainedValue()
|
||||
CFHTTPMessageAppendBytes(response, buffer, bufferLen)
|
||||
let code = CFHTTPMessageGetResponseStatusCode(response)
|
||||
if code != 101 {
|
||||
if code != httpSwitchProtocolCode {
|
||||
return code
|
||||
}
|
||||
if let cfHeaders = CFHTTPMessageCopyAllHeaderFields(response) {
|
||||
@@ -495,12 +526,12 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
return -1
|
||||
}
|
||||
|
||||
///read a 16 bit big endian value from a buffer
|
||||
///read a 16-bit big endian value from a buffer
|
||||
private static func readUint16(buffer: UnsafePointer<UInt8>, offset: Int) -> UInt16 {
|
||||
return (UInt16(buffer[offset + 0]) << 8) | UInt16(buffer[offset + 1])
|
||||
}
|
||||
|
||||
///read a 64 bit big endian value from a buffer
|
||||
///read a 64-bit big endian value from a buffer
|
||||
private static func readUint64(buffer: UnsafePointer<UInt8>, offset: Int) -> UInt64 {
|
||||
var value = UInt64(0)
|
||||
for i in 0...7 {
|
||||
@@ -509,13 +540,13 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
return value
|
||||
}
|
||||
|
||||
///write a 16 bit big endian value to a buffer
|
||||
/// Write a 16-bit big endian value to a buffer.
|
||||
private static func writeUint16(buffer: UnsafeMutablePointer<UInt8>, offset: Int, value: UInt16) {
|
||||
buffer[offset + 0] = UInt8(value >> 8)
|
||||
buffer[offset + 1] = UInt8(value & 0xff)
|
||||
}
|
||||
|
||||
///write a 64 bit big endian value to a buffer
|
||||
/// Write a 64-bit big endian value to a buffer.
|
||||
private static func writeUint64(buffer: UnsafeMutablePointer<UInt8>, offset: Int, value: UInt64) {
|
||||
for i in 0...7 {
|
||||
buffer[offset + i] = UInt8((value >> (8*UInt64(7 - i))) & 0xff)
|
||||
@@ -580,17 +611,19 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
offset += 2
|
||||
}
|
||||
var closeReason = "connection closed by server"
|
||||
if payloadLen > 2 {
|
||||
let len = Int(payloadLen-2)
|
||||
let len = Int(payloadLen - 2)
|
||||
if len > 0 {
|
||||
let bytes = baseAddress + offset
|
||||
let str: NSString? = NSString(data: NSData(bytes: bytes, length: len), encoding: NSUTF8StringEncoding)
|
||||
if str == nil {
|
||||
if let customCloseReason = String(data: NSData(bytes: bytes, length: len), encoding: NSUTF8StringEncoding) {
|
||||
closeReason = customCloseReason
|
||||
} else {
|
||||
code = CloseCode.ProtocolError.rawValue
|
||||
}
|
||||
}
|
||||
}
|
||||
doDisconnect(errorWithDetail("connection closed by server", code: code))
|
||||
doDisconnect(errorWithDetail(closeReason, code: code))
|
||||
writeError(code)
|
||||
return emptyBuffer
|
||||
}
|
||||
@@ -623,7 +656,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
if receivedOpcode == .Pong {
|
||||
if canDispatch {
|
||||
dispatch_async(queue) { [weak self] in
|
||||
dispatch_async(callbackQueue) { [weak self] in
|
||||
guard let s = self else { return }
|
||||
s.onPong?()
|
||||
s.pongDelegate?.websocketDidReceivePong(s)
|
||||
@@ -633,7 +666,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
var response = readStack.last
|
||||
if isControlFrame {
|
||||
response = nil //don't append pings
|
||||
response = nil // Don't append pings.
|
||||
}
|
||||
if isFin == 0 && receivedOpcode == .ContinueFrame && response == nil {
|
||||
let errCode = CloseCode.ProtocolError.rawValue
|
||||
@@ -677,7 +710,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
processResponse(response)
|
||||
}
|
||||
|
||||
let step = Int(offset+numericCast(len))
|
||||
let step = Int(offset + numericCast(len))
|
||||
return buffer.fromOffset(step)
|
||||
}
|
||||
}
|
||||
@@ -693,11 +726,11 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
///process the finished response of a buffer
|
||||
/// Process the finished response of a buffer.
|
||||
private func processResponse(response: WSResponse) -> Bool {
|
||||
if response.isFin && response.bytesLeft <= 0 {
|
||||
if response.code == .Ping {
|
||||
let data = response.buffer! //local copy so it is perverse for writing
|
||||
let data = response.buffer! // local copy so it's not perverse for writing
|
||||
dequeueWrite(data, code: OpCode.Pong)
|
||||
} else if response.code == .TextFrame {
|
||||
let str: NSString? = NSString(data: response.buffer!, encoding: NSUTF8StringEncoding)
|
||||
@@ -706,7 +739,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
return false
|
||||
}
|
||||
if canDispatch {
|
||||
dispatch_async(queue) { [weak self] in
|
||||
dispatch_async(callbackQueue) { [weak self] in
|
||||
guard let s = self else { return }
|
||||
s.onText?(str! as String)
|
||||
s.delegate?.websocketDidReceiveMessage(s, text: str! as String)
|
||||
@@ -714,8 +747,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
} else if response.code == .BinaryFrame {
|
||||
if canDispatch {
|
||||
let data = response.buffer! //local copy so it is perverse for writing
|
||||
dispatch_async(queue) { [weak self] in
|
||||
let data = response.buffer! //local copy so it's not perverse for writing
|
||||
dispatch_async(callbackQueue) { [weak self] in
|
||||
guard let s = self else { return }
|
||||
s.onData?(data)
|
||||
s.delegate?.websocketDidReceiveData(s, data: data)
|
||||
@@ -728,21 +761,22 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
return false
|
||||
}
|
||||
|
||||
///Create an error
|
||||
/// Create an error.
|
||||
private func errorWithDetail(detail: String, code: UInt16) -> NSError {
|
||||
var details = [String: String]()
|
||||
details[NSLocalizedDescriptionKey] = detail
|
||||
return NSError(domain: WebSocket.ErrorDomain, code: Int(code), userInfo: details)
|
||||
}
|
||||
|
||||
///write a an error to the socket
|
||||
/// Write a an error to the socket.
|
||||
private func writeError(code: UInt16) {
|
||||
let buf = NSMutableData(capacity: sizeof(UInt16))
|
||||
let buffer = UnsafeMutablePointer<UInt8>(buf!.bytes)
|
||||
WebSocket.writeUint16(buffer, offset: 0, value: code)
|
||||
dequeueWrite(NSData(bytes: buffer, length: sizeof(UInt16)), code: .ConnectionClose)
|
||||
}
|
||||
///used to write things to the stream
|
||||
|
||||
/// Used to write things to the stream.
|
||||
private func dequeueWrite(data: NSData, code: OpCode, writeCompletion: (() -> ())? = nil) {
|
||||
writeQueue.addOperationWithBlock { [weak self] in
|
||||
//stream isn't ready, let's wait
|
||||
@@ -792,8 +826,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
total += len
|
||||
}
|
||||
if total >= offset {
|
||||
if let queue = self?.queue, callback = writeCompletion {
|
||||
dispatch_async(queue) {
|
||||
if let callbackQueue = self?.callbackQueue, callback = writeCompletion {
|
||||
dispatch_async(callbackQueue) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
@@ -805,19 +839,23 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
///used to preform the disconnect delegate
|
||||
/// Used to preform the disconnect delegate.
|
||||
private func doDisconnect(error: NSError?) {
|
||||
guard !didDisconnect else { return }
|
||||
didDisconnect = true
|
||||
connected = false
|
||||
guard canDispatch else {return}
|
||||
dispatch_async(queue) { [weak self] in
|
||||
dispatch_async(callbackQueue) { [weak self] in
|
||||
guard let s = self else { return }
|
||||
s.onDisconnect?(error)
|
||||
s.delegate?.websocketDidDisconnect(s, error: error)
|
||||
let userInfo = error.map{ [WebsocketDisconnectionErrorKeyName: $0] }
|
||||
s.notificationCenter.postNotificationName(WebsocketDidDisconnectNotification, object: self, userInfo: userInfo)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Deinit
|
||||
|
||||
deinit {
|
||||
mutex.lock()
|
||||
readyToWrite = false
|
||||
@@ -844,238 +882,3 @@ private extension UnsafeBufferPointer {
|
||||
}
|
||||
|
||||
private let emptyBuffer = UnsafeBufferPointer<UInt8>(start: nil, count: 0)
|
||||
|
||||
|
||||
public class SSLCert {
|
||||
var certData: NSData?
|
||||
var key: SecKeyRef?
|
||||
|
||||
/**
|
||||
Designated init for certificates
|
||||
|
||||
- parameter 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
|
||||
|
||||
- parameter 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 SSLSecurity {
|
||||
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
|
||||
|
||||
- parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation
|
||||
|
||||
- returns: a representation security object to be used with
|
||||
*/
|
||||
public convenience init(usePublicKeys: Bool = false) {
|
||||
let paths = NSBundle.mainBundle().pathsForResourcesOfType("cer", inDirectory: ".")
|
||||
|
||||
let certs = paths.reduce([SSLCert]()) { (certs: [SSLCert], path: String) -> [SSLCert] in
|
||||
var certs = certs
|
||||
if let data = NSData(contentsOfFile: path) {
|
||||
certs.append(SSLCert(data: data))
|
||||
}
|
||||
return certs
|
||||
}
|
||||
|
||||
self.init(certs: certs, usePublicKeys: usePublicKeys)
|
||||
}
|
||||
|
||||
/**
|
||||
Designated init
|
||||
|
||||
- parameter keys: is the certificates or public keys to use
|
||||
- parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation
|
||||
|
||||
- returns: a representation security object to be used with
|
||||
*/
|
||||
public init(certs: [SSLCert], usePublicKeys: Bool) {
|
||||
self.usePublicKeys = usePublicKeys
|
||||
|
||||
if self.usePublicKeys {
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0)) {
|
||||
let pubKeys = certs.reduce([SecKeyRef]()) { (pubKeys: [SecKeyRef], cert: SSLCert) -> [SecKeyRef] in
|
||||
var pubKeys = pubKeys
|
||||
if let data = cert.certData where cert.key == nil {
|
||||
cert.key = self.extractPublicKey(data)
|
||||
}
|
||||
if let key = cert.key {
|
||||
pubKeys.append(key)
|
||||
}
|
||||
return pubKeys
|
||||
}
|
||||
|
||||
self.pubKeys = pubKeys
|
||||
self.isReady = true
|
||||
}
|
||||
} else {
|
||||
let certificates = certs.reduce([NSData]()) { (certificates: [NSData], cert: SSLCert) -> [NSData] in
|
||||
var certificates = certificates
|
||||
if let data = cert.certData {
|
||||
certificates.append(data)
|
||||
}
|
||||
return certificates
|
||||
}
|
||||
self.certificates = certificates
|
||||
self.isReady = true
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Valid the trust and domain name.
|
||||
|
||||
- parameter trust: is the serverTrust to validate
|
||||
- parameter 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(true, domain)
|
||||
} else {
|
||||
policy = SecPolicyCreateBasicX509()
|
||||
}
|
||||
SecTrustSetPolicies(trust,policy)
|
||||
if self.usePublicKeys {
|
||||
if let keys = self.pubKeys {
|
||||
let serverPubKeys = publicKeyChainForTrust(trust)
|
||||
for serverKey in serverPubKeys as [AnyObject] {
|
||||
for key in keys as [AnyObject] {
|
||||
if serverKey.isEqual(key) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let certs = self.certificates {
|
||||
let serverCerts = certificateChainForTrust(trust)
|
||||
var collect = [SecCertificate]()
|
||||
for cert in certs {
|
||||
collect.append(SecCertificateCreateWithData(nil,cert)!)
|
||||
}
|
||||
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 += 1
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if trustedCount == serverCerts.count {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
Get the public key from a certificate data
|
||||
|
||||
- parameter data: is the certificate to pull the public key from
|
||||
|
||||
- returns: a public key
|
||||
*/
|
||||
func extractPublicKey(data: NSData) -> SecKeyRef? {
|
||||
guard let cert = SecCertificateCreateWithData(nil, data) else { return nil }
|
||||
|
||||
return extractPublicKeyFromCert(cert, policy: SecPolicyCreateBasicX509())
|
||||
}
|
||||
|
||||
/**
|
||||
Get the public key from a certificate
|
||||
|
||||
- parameter data: is the certificate to pull the public key from
|
||||
|
||||
- returns: a public key
|
||||
*/
|
||||
func extractPublicKeyFromCert(cert: SecCertificate, policy: SecPolicy) -> SecKeyRef? {
|
||||
var possibleTrust: SecTrust?
|
||||
SecTrustCreateWithCertificates(cert, policy, &possibleTrust)
|
||||
|
||||
guard let trust = possibleTrust else { return nil }
|
||||
|
||||
var result: SecTrustResultType = 0
|
||||
SecTrustEvaluate(trust, &result)
|
||||
return SecTrustCopyPublicKey(trust)
|
||||
}
|
||||
|
||||
/**
|
||||
Get the certificate chain for the trust
|
||||
|
||||
- parameter trust: is the trust to lookup the certificate chain for
|
||||
|
||||
- returns: the certificate chain for the trust
|
||||
*/
|
||||
func certificateChainForTrust(trust: SecTrustRef) -> [NSData] {
|
||||
let certificates = (0..<SecTrustGetCertificateCount(trust)).reduce([NSData]()) { (certificates: [NSData], index: Int) -> [NSData] in
|
||||
var certificates = certificates
|
||||
let cert = SecTrustGetCertificateAtIndex(trust, index)
|
||||
certificates.append(SecCertificateCopyData(cert!))
|
||||
return certificates
|
||||
}
|
||||
|
||||
return certificates
|
||||
}
|
||||
|
||||
/**
|
||||
Get the public key chain for the trust
|
||||
|
||||
- parameter trust: is the trust to lookup the certificate chain and extract the public keys
|
||||
|
||||
- returns: the public keys from the certifcate chain for the trust
|
||||
*/
|
||||
func publicKeyChainForTrust(trust: SecTrustRef) -> [SecKeyRef] {
|
||||
let policy = SecPolicyCreateBasicX509()
|
||||
let keys = (0..<SecTrustGetCertificateCount(trust)).reduce([SecKeyRef]()) { (keys: [SecKeyRef], index: Int) -> [SecKeyRef] in
|
||||
var keys = keys
|
||||
let cert = SecTrustGetCertificateAtIndex(trust, index)
|
||||
if let key = extractPublicKeyFromCert(cert!, policy: policy) {
|
||||
keys.append(key)
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
return keys
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user