Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff9c1bb67b | ||
|
|
c92e146dfc | ||
|
|
d71f81745e | ||
|
|
228c0c7c9b | ||
|
|
d36ef10404 | ||
|
|
c5c00510e5 | ||
|
|
e38c4081ec | ||
|
|
5060f90a79 | ||
|
|
57670ec613 | ||
|
|
3f57c7e0a9 | ||
|
|
efe0d01592 | ||
|
|
f9c665a542 | ||
|
|
b67b6abbdf | ||
|
|
d912796fa5 | ||
|
|
c9ac69f408 | ||
|
|
cc7d96e3d5 | ||
|
|
bf1104443a | ||
|
|
adf8692234 | ||
|
|
94f02e567a | ||
|
|
4eca685dc2 | ||
|
|
90f512e03b | ||
|
|
7d8b0c89c5 | ||
|
|
e45003210f | ||
|
|
4d07d2911f | ||
|
|
0d6e4af62f | ||
|
|
2e6803bd1a | ||
|
|
bcb556b66c | ||
|
|
d8b5293ca1 | ||
|
|
ec2aa703a3 | ||
|
|
c211ab140d | ||
|
|
5cab7dbb2f | ||
|
|
0fc70e8be1 | ||
|
|
609ce08351 | ||
|
|
e366e808ae | ||
|
|
03d5f56114 | ||
|
|
2cf448de72 | ||
|
|
fb0c6a5612 | ||
|
|
a9633510ff | ||
|
|
95d2dce641 | ||
|
|
88b1eb1948 | ||
|
|
67f47ad6fe | ||
|
|
d6c521123b | ||
|
|
024384dc82 | ||
|
|
ec67056d2a | ||
|
|
15cfba46bc | ||
|
|
dbc8b6fadc | ||
|
|
d15fb90950 | ||
|
|
e06a792503 | ||
|
|
b202b21d43 | ||
|
|
443f5c5b22 | ||
|
|
3979b36f63 | ||
|
|
ac460d8023 | ||
|
|
731c8a851b | ||
|
|
a299901fa8 | ||
|
|
660aed8359 | ||
|
|
06aafa78ed | ||
|
|
3c9070b3e7 | ||
|
|
3587c20718 | ||
|
|
de3ca964ab | ||
|
|
19c68416bb | ||
|
|
ee5934de6a | ||
|
|
ca67625ed3 | ||
|
|
fe02b8eff2 | ||
|
|
0c8ff90537 | ||
|
|
5068986a50 | ||
|
|
4ed4681cc4 | ||
|
|
361cd8fc3b | ||
|
|
2916ed0f7b | ||
|
|
cfa98ea42b | ||
|
|
8584b90d3c | ||
|
|
7acce7d18e | ||
|
|
0ebe56d780 | ||
|
|
3d8867136d | ||
|
|
bed5ecd23b | ||
|
|
4e5fcff258 | ||
|
|
aeb52de72f | ||
|
|
ca90938675 | ||
|
|
1aacab2567 | ||
|
|
a28fda392c | ||
|
|
931382deff | ||
|
|
298817ce5c | ||
|
|
8cf3aebf9f | ||
|
|
75fc013f92 | ||
|
|
44c5591646 | ||
|
|
8e0d03b28c |
No files matched your search
@@ -2,6 +2,8 @@
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
*.xcodeproj
|
||||
.build/*
|
||||
Packages/*
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "SocketIOClientSwift"
|
||||
)
|
||||
@@ -5,7 +5,7 @@ Socket.IO-client for iOS/OS X.
|
||||
|
||||
##Example
|
||||
```swift
|
||||
let socket = SocketIOClient(socketURL: "localhost:8080", options: [.Log(true), .ForcePolling(true)])
|
||||
let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8080")!, options: [.Log(true), .ForcePolling(true)])
|
||||
|
||||
socket.on("connect") {data, ack in
|
||||
print("socket connected")
|
||||
@@ -26,7 +26,8 @@ socket.connect()
|
||||
|
||||
##Objective-C Example
|
||||
```objective-c
|
||||
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" options:@{@"log": @YES, @"forcePolling": @YES}];
|
||||
NSURL* url = [[NSURL alloc] initWithString:@"http://localhost:8080"];
|
||||
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url options:@{@"log": @YES, @"forcePolling": @YES}];
|
||||
|
||||
[socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
|
||||
NSLog(@"socket connected");
|
||||
@@ -65,11 +66,27 @@ Manually (iOS 7+)
|
||||
1. Copy the Source folder into your Xcode project. (Make sure you add the files to your target(s))
|
||||
2. If you plan on using this from Objective-C, read [this](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html) on exposing Swift code to Objective-C.
|
||||
|
||||
Swift Package Manager
|
||||
---------------------
|
||||
Add the project as a dependency to your Package.swift:
|
||||
```swift
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "YourSocketIOProject",
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 5)
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
Then import `import SocketIOClientSwift`.
|
||||
|
||||
Carthage
|
||||
-----------------
|
||||
Add this line to your `Cartfile`:
|
||||
```
|
||||
github "socketio/socket.io-client-swift" ~> 4.1.5 # Or latest version
|
||||
github "socketio/socket.io-client-swift" ~> 5.3.0 # Or latest version
|
||||
```
|
||||
|
||||
Run `carthage update --platform ios,macosx`.
|
||||
@@ -83,7 +100,7 @@ source 'https://github.com/CocoaPods/Specs.git'
|
||||
platform :ios, '8.0'
|
||||
use_frameworks!
|
||||
|
||||
pod 'Socket.IO-Client-Swift', '~> 4.1.5' # Or latest version
|
||||
pod 'Socket.IO-Client-Swift', '~> 5.3.0' # Or latest version
|
||||
```
|
||||
|
||||
Install pods:
|
||||
@@ -96,13 +113,13 @@ Import the module:
|
||||
|
||||
Swift:
|
||||
```swift
|
||||
import Socket_IO_Client_Swift
|
||||
import SocketIOClientSwift
|
||||
```
|
||||
|
||||
Objective-C:
|
||||
|
||||
```Objective-C
|
||||
#import <Socket_IO_Client_Swift/Socket_IO_Client_Swift-Swift.h>
|
||||
#import <SocketIOClientSwift/SocketIOClientSwift-Swift.h>
|
||||
```
|
||||
|
||||
CocoaSeeds
|
||||
@@ -111,7 +128,7 @@ CocoaSeeds
|
||||
Add this line to your `Seedfile`:
|
||||
|
||||
```
|
||||
github "socketio/socket.io-client-swift", "v4.1.5", :files => "SocketIOClientSwift/*.swift" # Or latest version
|
||||
github "socketio/socket.io-client-swift", "v5.3.0", :files => "Source/*.swift" # Or latest version
|
||||
```
|
||||
|
||||
Run `seed install`.
|
||||
@@ -120,9 +137,9 @@ Run `seed install`.
|
||||
##API
|
||||
Constructors
|
||||
-----------
|
||||
`init(var socketURL: String, options: Set<SocketIOClientOption> = [])` - Creates a new SocketIOClient. opts is a Set of SocketIOClientOption. If your socket.io server is secure, you need to specify `https` in your socketURL.
|
||||
`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.
|
||||
|
||||
`convenience init(socketURL: String, options: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys.
|
||||
`convenience init(socketURL: NSURL, options: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys.
|
||||
|
||||
Options
|
||||
-------
|
||||
@@ -141,7 +158,7 @@ case Cookies([NSHTTPCookie]) // An array of NSHTTPCookies. Passed during the han
|
||||
case Log(Bool) // If `true` socket will log debug messages. Default is false.
|
||||
case Logger(SocketLogger) // Custom logger that conforms to SocketLogger. Will use the default logging otherwise.
|
||||
case SessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.
|
||||
case Path(String) // If the server uses a custom path. ex: `"/swift"`. Default is `""`
|
||||
case Path(String) // If the server uses a custom path. ex: `"/swift/"`. Default is `""`
|
||||
case ExtraHeaders([String: String]) // Adds custom headers to the initial request. Default is nil.
|
||||
case HandleQueue(dispatch_queue_t) // The dispatch queue that handlers are run on. Default is the main queue.
|
||||
case VoipEnabled(Bool) // Only use this option if you're using the client with VoIP services. Changes the way the WebSocket is created. Default is false
|
||||
@@ -160,9 +177,9 @@ Methods
|
||||
7. `emitWithAck(event: String, withItems items: [AnyObject]) -> (UInt64, (NSArray?) -> Void) -> Void` - `emitWithAck` for Objective-C. Note: The message is not sent until you call the returned function.
|
||||
8. `connect()` - Establishes a connection to the server. A "connect" event is fired upon successful connection.
|
||||
9. `connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
|
||||
10. `close()` - Closes the socket. Once a socket is closed it should not be reopened.
|
||||
10. `disconnect()` - Closes the socket. Reopening a disconnected socket is not fully tested.
|
||||
11. `reconnect()` - Causes the client to reconnect to the server.
|
||||
12. `joinNamespace()` - Causes the client to join nsp. Shouldn't need to be called unless you change nsp manually.
|
||||
12. `joinNamespace(namespace: String)` - Causes the client to join namespace. Shouldn't need to be called unless you change namespaces manually.
|
||||
13. `leaveNamespace()` - Causes the client to leave the nsp and go back to /
|
||||
14. `off(event: String)` - Removes all event handlers for event.
|
||||
15. `off(id id: NSUUID)` - Removes the event that corresponds to id.
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Socket.IO-Client-Swift"
|
||||
s.version = "4.1.5"
|
||||
s.module_name = "SocketIOClientSwift"
|
||||
s.version = "5.3.0"
|
||||
s.summary = "Socket.IO-client for iOS and OS X"
|
||||
s.description = <<-DESC
|
||||
Socket.IO-client for iOS and OS X.
|
||||
Supports ws/wss/polling connections and binary.
|
||||
For socket.io 1.0+ and Swift 1.2.
|
||||
For socket.io 1.0+ and Swift.
|
||||
DESC
|
||||
s.homepage = "https://github.com/socketio/socket.io-client-swift"
|
||||
s.license = { :type => 'MIT' }
|
||||
@@ -13,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 => 'v4.1.5' }
|
||||
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v5.3.0' }
|
||||
s.source_files = "Source/**/*.swift"
|
||||
s.requires_arc = true
|
||||
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
|
||||
|
||||
@@ -8,81 +8,71 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
||||
572EF2251B51F16C00EEBB58 /* SocketIOClientSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */; };
|
||||
572EF23D1B51F18A00EEBB58 /* SocketIO-Mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; };
|
||||
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, ); }; };
|
||||
57634A231BD9B46D00E19CD7 /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
||||
57634A271BD9B46D00E19CD7 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */; };
|
||||
57634A2A1BD9B46D00E19CD7 /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; };
|
||||
57634A2F1BD9B46D00E19CD7 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
||||
57634A311BD9B46D00E19CD7 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */; };
|
||||
57634A321BD9B46D00E19CD7 /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
|
||||
57634A3F1BD9B4BF00E19CD7 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 57634A161BD9B46A00E19CD7 /* SocketIO.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 */; };
|
||||
74171E661C10CD240062D398 /* 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 */; };
|
||||
74171E6C1C10CD240062D398 /* 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 */; };
|
||||
74171E721C10CD240062D398 /* 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 */; };
|
||||
74171E781C10CD240062D398 /* 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 */; };
|
||||
74171E7E1C10CD240062D398 /* 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 */; };
|
||||
74171E841C10CD240062D398 /* 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 */; };
|
||||
74171E8A1C10CD240062D398 /* 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 */; };
|
||||
74171E901C10CD240062D398 /* 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 */; };
|
||||
74171E931C10CD240062D398 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E581C10CD240062D398 /* SocketFixUTF8.swift */; };
|
||||
74171E941C10CD240062D398 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E581C10CD240062D398 /* SocketFixUTF8.swift */; };
|
||||
74171E951C10CD240062D398 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E581C10CD240062D398 /* SocketFixUTF8.swift */; };
|
||||
74171E961C10CD240062D398 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E581C10CD240062D398 /* SocketFixUTF8.swift */; };
|
||||
74171E971C10CD240062D398 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E581C10CD240062D398 /* SocketFixUTF8.swift */; };
|
||||
74171E981C10CD240062D398 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E581C10CD240062D398 /* SocketFixUTF8.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 */; };
|
||||
74171E9C1C10CD240062D398 /* 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 */; };
|
||||
74171EA21C10CD240062D398 /* 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 */; };
|
||||
@@ -94,57 +84,54 @@
|
||||
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 */; };
|
||||
74171EAE1C10CD240062D398 /* 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 */; };
|
||||
74171EB41C10CD240062D398 /* 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 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParser.swift */; };
|
||||
74171EB81C10CD240062D398 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParser.swift */; };
|
||||
74171EB91C10CD240062D398 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParser.swift */; };
|
||||
74171EBA1C10CD240062D398 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParser.swift */; };
|
||||
74171EBB1C10CD240062D398 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParser.swift */; };
|
||||
74171EBC1C10CD240062D398 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E5E1C10CD240062D398 /* SocketParser.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 */; };
|
||||
74171EC01C10CD240062D398 /* 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 */; };
|
||||
74171EC61C10CD240062D398 /* 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 */; };
|
||||
74171EC91C10CD240062D398 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E611C10CD240062D398 /* SwiftRegex.swift */; };
|
||||
74171ECA1C10CD240062D398 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E611C10CD240062D398 /* SwiftRegex.swift */; };
|
||||
74171ECB1C10CD240062D398 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E611C10CD240062D398 /* SwiftRegex.swift */; };
|
||||
74171ECC1C10CD240062D398 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E611C10CD240062D398 /* SwiftRegex.swift */; };
|
||||
74171ECD1C10CD240062D398 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E611C10CD240062D398 /* SwiftRegex.swift */; };
|
||||
74171ECE1C10CD240062D398 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74171E611C10CD240062D398 /* SwiftRegex.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 */; };
|
||||
74171ED21C10CD240062D398 /* 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 */; };
|
||||
745895381BB59A0A0050ACC8 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */; };
|
||||
7458953D1BB59A0A0050ACC8 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */; };
|
||||
7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7420CB781C49629E00956AA4 /* SocketEnginePollable.swift */; };
|
||||
7420CB7A1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7420CB781C49629E00956AA4 /* SocketEnginePollable.swift */; };
|
||||
7420CB7B1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7420CB781C49629E00956AA4 /* SocketEnginePollable.swift */; };
|
||||
74321DCB1C2D939A00CF6F43 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74321DC91C2D939A00CF6F43 /* SocketAckManagerTest.swift */; };
|
||||
74321DCC1C2D939A00CF6F43 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */; };
|
||||
7471CCEA1C39926300364B59 /* SocketClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketClientSpec.swift */; };
|
||||
7471CCEB1C39926C00364B59 /* SocketClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketClientSpec.swift */; };
|
||||
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
|
||||
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 */; };
|
||||
74ABF7771C3991C10078C657 /* SocketClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketClientSpec.swift */; };
|
||||
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
||||
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
||||
949FAE8D1B9B94E600073BE9 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */; };
|
||||
94A20D611B99E22F00BF9E44 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -172,18 +159,19 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
572EF2191B51F16C00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
572EF21D1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = "<group>"; };
|
||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
572EF22A1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
572EF2381B51F18A00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.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; };
|
||||
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>"; };
|
||||
74171E521C10CD240062D398 /* SocketAnyEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAnyEvent.swift; path = Source/SocketAnyEvent.swift; sourceTree = "<group>"; };
|
||||
@@ -198,17 +186,19 @@
|
||||
74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientStatus.swift; path = Source/SocketIOClientStatus.swift; sourceTree = "<group>"; };
|
||||
74171E5C1C10CD240062D398 /* SocketLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketLogger.swift; path = Source/SocketLogger.swift; sourceTree = "<group>"; };
|
||||
74171E5D1C10CD240062D398 /* SocketPacket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketPacket.swift; path = Source/SocketPacket.swift; sourceTree = "<group>"; };
|
||||
74171E5E1C10CD240062D398 /* SocketParser.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketParser.swift; path = Source/SocketParser.swift; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
74171E611C10CD240062D398 /* SwiftRegex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftRegex.swift; path = Source/SwiftRegex.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>"; };
|
||||
74321DC91C2D939A00CF6F43 /* SocketAckManagerTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketAckManagerTest.swift; sourceTree = "<group>"; };
|
||||
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>"; };
|
||||
74ABF7761C3991C10078C657 /* SocketClientSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketClientSpec.swift; path = Source/SocketClientSpec.swift; sourceTree = "<group>"; };
|
||||
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = "<group>"; };
|
||||
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketParserTest.swift; path = "../SocketIO-iOSTests/SocketParserTest.swift"; sourceTree = "<group>"; };
|
||||
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckManagerTest.swift; path = "../SocketIO-iOSTests/SocketAckManagerTest.swift"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -223,7 +213,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */,
|
||||
572EF2251B51F16C00EEBB58 /* SocketIOClientSwift.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -238,7 +228,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */,
|
||||
572EF2431B51F18A00EEBB58 /* SocketIOClientSwift.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -275,9 +265,9 @@
|
||||
572EF21A1B51F16C00EEBB58 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
572EF2191B51F16C00EEBB58 /* SocketIO.framework */,
|
||||
572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */,
|
||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */,
|
||||
572EF2381B51F18A00EEBB58 /* SocketIO.framework */,
|
||||
572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */,
|
||||
572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */,
|
||||
57634A161BD9B46A00E19CD7 /* SocketIO.framework */,
|
||||
57634A3B1BD9B46D00E19CD7 /* SocketIO-tvOSTests.xctest */,
|
||||
@@ -338,11 +328,11 @@
|
||||
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */,
|
||||
74321DC91C2D939A00CF6F43 /* SocketAckManagerTest.swift */,
|
||||
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */,
|
||||
741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */,
|
||||
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */,
|
||||
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */,
|
||||
74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */,
|
||||
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */,
|
||||
572EF2471B51F18A00EEBB58 /* Supporting Files */,
|
||||
);
|
||||
@@ -363,10 +353,13 @@
|
||||
74171E501C10CD240062D398 /* SocketAckEmitter.swift */,
|
||||
74171E511C10CD240062D398 /* SocketAckManager.swift */,
|
||||
74171E521C10CD240062D398 /* SocketAnyEvent.swift */,
|
||||
74ABF7761C3991C10078C657 /* SocketClientSpec.swift */,
|
||||
74171E531C10CD240062D398 /* SocketEngine.swift */,
|
||||
74171E541C10CD240062D398 /* SocketEngineClient.swift */,
|
||||
74171E551C10CD240062D398 /* SocketEnginePacketType.swift */,
|
||||
7420CB781C49629E00956AA4 /* SocketEnginePollable.swift */,
|
||||
74171E561C10CD240062D398 /* SocketEngineSpec.swift */,
|
||||
740CA11F1C496EEB00CB98F4 /* SocketEngineWebsocket.swift */,
|
||||
74171E571C10CD240062D398 /* SocketEventHandler.swift */,
|
||||
74171E581C10CD240062D398 /* SocketFixUTF8.swift */,
|
||||
74171E591C10CD240062D398 /* SocketIOClient.swift */,
|
||||
@@ -374,7 +367,7 @@
|
||||
74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */,
|
||||
74171E5C1C10CD240062D398 /* SocketLogger.swift */,
|
||||
74171E5D1C10CD240062D398 /* SocketPacket.swift */,
|
||||
74171E5E1C10CD240062D398 /* SocketParser.swift */,
|
||||
74171E5E1C10CD240062D398 /* SocketParsable.swift */,
|
||||
74171E5F1C10CD240062D398 /* SocketStringReader.swift */,
|
||||
74171E601C10CD240062D398 /* SocketTypes.swift */,
|
||||
74171E611C10CD240062D398 /* SwiftRegex.swift */,
|
||||
@@ -428,7 +421,7 @@
|
||||
);
|
||||
name = "SocketIO-iOS";
|
||||
productName = "SocketIO-iOS";
|
||||
productReference = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */;
|
||||
productReference = 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
572EF2231B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
||||
@@ -464,7 +457,7 @@
|
||||
);
|
||||
name = "SocketIO-Mac";
|
||||
productName = "SocketIO-Mac";
|
||||
productReference = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */;
|
||||
productReference = 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
572EF2411B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
||||
@@ -528,7 +521,7 @@
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0710;
|
||||
LastUpgradeCheck = 0640;
|
||||
LastUpgradeCheck = 0720;
|
||||
TargetAttributes = {
|
||||
572EF2181B51F16C00EEBB58 = {
|
||||
CreatedOnToolsVersion = 6.4;
|
||||
@@ -616,10 +609,13 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
||||
74171E931C10CD240062D398 /* SocketFixUTF8.swift in Sources */,
|
||||
74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
74171E751C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
||||
74ABF7771C3991C10078C657 /* SocketClientSpec.swift in Sources */,
|
||||
74171E871C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171E631C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
74171EBD1C10CD240062D398 /* SocketStringReader.swift in Sources */,
|
||||
@@ -631,7 +627,7 @@
|
||||
74171E7B1C10CD240062D398 /* SocketEngineClient.swift in Sources */,
|
||||
74171ECF1C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EB11C10CD240062D398 /* SocketPacket.swift in Sources */,
|
||||
74171EB71C10CD240062D398 /* SocketParser.swift in Sources */,
|
||||
74171EB71C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171E811C10CD240062D398 /* SocketEnginePacketType.swift in Sources */,
|
||||
74171E6F1C10CD240062D398 /* SocketAnyEvent.swift in Sources */,
|
||||
74171E9F1C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
@@ -644,7 +640,6 @@
|
||||
files = (
|
||||
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */,
|
||||
74171EA61C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
94A20D611B99E22F00BF9E44 /* SocketAckManagerTest.swift in Sources */,
|
||||
74171E881C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171ED01C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EA01C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
@@ -662,8 +657,7 @@
|
||||
74171E6A1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
74171E761C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
74171E641C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
949FAE8D1B9B94E600073BE9 /* SocketParserTest.swift in Sources */,
|
||||
74171EB81C10CD240062D398 /* SocketParser.swift in Sources */,
|
||||
74171EB81C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171EAC1C10CD240062D398 /* SocketLogger.swift in Sources */,
|
||||
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */,
|
||||
74171E9A1C10CD240062D398 /* SocketIOClient.swift in Sources */,
|
||||
@@ -674,9 +668,12 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
||||
7471CCEA1C39926300364B59 /* SocketClientSpec.swift in Sources */,
|
||||
74171E951C10CD240062D398 /* SocketFixUTF8.swift in Sources */,
|
||||
74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
74171E771C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
7420CB7A1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
||||
74171E6B1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
74171E891C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171E651C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
@@ -689,7 +686,7 @@
|
||||
74171E7D1C10CD240062D398 /* SocketEngineClient.swift in Sources */,
|
||||
74171ED11C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EB31C10CD240062D398 /* SocketPacket.swift in Sources */,
|
||||
74171EB91C10CD240062D398 /* SocketParser.swift in Sources */,
|
||||
74171EB91C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171E831C10CD240062D398 /* SocketEnginePacketType.swift in Sources */,
|
||||
74171E711C10CD240062D398 /* SocketAnyEvent.swift in Sources */,
|
||||
74171EA11C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
@@ -700,31 +697,13 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
74321DCB1C2D939A00CF6F43 /* SocketAckManagerTest.swift in Sources */,
|
||||
74321DCC1C2D939A00CF6F43 /* SocketParserTest.swift in Sources */,
|
||||
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */,
|
||||
74171EA81C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */,
|
||||
74171E8A1C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171ED21C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EA21C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
74171E721C10CD240062D398 /* SocketAnyEvent.swift in Sources */,
|
||||
74171EC61C10CD240062D398 /* SocketTypes.swift in Sources */,
|
||||
74171E901C10CD240062D398 /* SocketEventHandler.swift in Sources */,
|
||||
74171E7E1C10CD240062D398 /* SocketEngineClient.swift in Sources */,
|
||||
74171E961C10CD240062D398 /* SocketFixUTF8.swift in Sources */,
|
||||
74171E841C10CD240062D398 /* SocketEnginePacketType.swift in Sources */,
|
||||
74171ECC1C10CD240062D398 /* SwiftRegex.swift in Sources */,
|
||||
74171EB41C10CD240062D398 /* SocketPacket.swift in Sources */,
|
||||
745895381BB59A0A0050ACC8 /* SocketAckManagerTest.swift in Sources */,
|
||||
74171EC01C10CD240062D398 /* SocketStringReader.swift in Sources */,
|
||||
7458953D1BB59A0A0050ACC8 /* SocketParserTest.swift in Sources */,
|
||||
74171E6C1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
74171E781C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
74171E661C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */,
|
||||
74171EBA1C10CD240062D398 /* SocketParser.swift in Sources */,
|
||||
74171EAE1C10CD240062D398 /* SocketLogger.swift in Sources */,
|
||||
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */,
|
||||
74171E9C1C10CD240062D398 /* SocketIOClient.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -732,9 +711,12 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
||||
7471CCEB1C39926C00364B59 /* SocketClientSpec.swift in Sources */,
|
||||
74171E971C10CD240062D398 /* SocketFixUTF8.swift in Sources */,
|
||||
74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
74171E791C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
7420CB7B1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
||||
74171E6D1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
74171E8B1C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171E671C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
@@ -747,7 +729,7 @@
|
||||
74171E7F1C10CD240062D398 /* SocketEngineClient.swift in Sources */,
|
||||
74171ED31C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EB51C10CD240062D398 /* SocketPacket.swift in Sources */,
|
||||
74171EBB1C10CD240062D398 /* SocketParser.swift in Sources */,
|
||||
74171EBB1C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171E851C10CD240062D398 /* SocketEnginePacketType.swift in Sources */,
|
||||
74171E731C10CD240062D398 /* SocketAnyEvent.swift in Sources */,
|
||||
74171EA31C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
@@ -760,7 +742,6 @@
|
||||
files = (
|
||||
57634A231BD9B46D00E19CD7 /* SocketSideEffectTest.swift in Sources */,
|
||||
74171EAA1C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||
57634A271BD9B46D00E19CD7 /* SocketAckManagerTest.swift in Sources */,
|
||||
74171E8C1C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||
74171ED41C10CD240062D398 /* WebSocket.swift in Sources */,
|
||||
74171EA41C10CD240062D398 /* SocketIOClientOption.swift in Sources */,
|
||||
@@ -778,8 +759,7 @@
|
||||
74171E6E1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||
74171E7A1C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||
74171E681C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||
57634A311BD9B46D00E19CD7 /* SocketParserTest.swift in Sources */,
|
||||
74171EBC1C10CD240062D398 /* SocketParser.swift in Sources */,
|
||||
74171EBC1C10CD240062D398 /* SocketParsable.swift in Sources */,
|
||||
74171EB01C10CD240062D398 /* SocketLogger.swift in Sources */,
|
||||
57634A321BD9B46D00E19CD7 /* SocketNamespacePacketTest.swift in Sources */,
|
||||
74171E9E1C10CD240062D398 /* SocketIOClient.swift in Sources */,
|
||||
@@ -813,10 +793,12 @@
|
||||
BITCODE_GENERATION_MODE = bitcode;
|
||||
CODE_SIGN_IDENTITY = "Developer ID Application";
|
||||
ENABLE_BITCODE = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_NAME = SocketIO;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_NAME = SocketIOClientSwift;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
@@ -831,7 +813,7 @@
|
||||
ENABLE_BITCODE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
PRODUCT_NAME = SocketIO;
|
||||
PRODUCT_NAME = SocketIOClientSwift;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||
@@ -884,6 +866,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.socket.SocketIOClientSwift;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
@@ -933,6 +916,7 @@
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = io.socket.SocketIOClientSwift;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
@@ -987,6 +971,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
};
|
||||
@@ -1030,6 +1015,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = iphoneos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
@@ -1064,6 +1050,7 @@
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_BITCODE = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
FRAMEWORK_VERSION = A;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
@@ -1084,6 +1071,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
@@ -1121,6 +1109,7 @@
|
||||
ENABLE_BITCODE = NO;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
ENABLE_TESTABILITY = YES;
|
||||
FRAMEWORK_VERSION = A;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
@@ -1134,6 +1123,7 @@
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
SDKROOT = macosx;
|
||||
SKIP_INSTALL = YES;
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
@@ -1188,6 +1178,7 @@
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
@@ -1233,6 +1224,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = macosx;
|
||||
};
|
||||
@@ -1284,6 +1276,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = SocketIO;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
@@ -1335,6 +1328,7 @@
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = SocketIO;
|
||||
SDKROOT = appletvos;
|
||||
SKIP_INSTALL = YES;
|
||||
@@ -1391,6 +1385,7 @@
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = appletvos;
|
||||
};
|
||||
@@ -1434,6 +1429,7 @@
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.4;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SDKROOT = appletvos;
|
||||
VALIDATE_PRODUCT = YES;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0640"
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -15,7 +15,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -57,7 +57,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -79,7 +79,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -97,7 +97,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BlueprintName = "SocketIO-Mac"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0640"
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
@@ -15,7 +15,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -58,7 +58,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -80,7 +80,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
@@ -98,7 +98,7 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||
BuildableName = "SocketIO.framework"
|
||||
BuildableName = "SocketIOClientSwift.framework"
|
||||
BlueprintName = "SocketIO-iOS"
|
||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||
</BuildableReference>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0710"
|
||||
LastUpgradeVersion = "0720"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
|
||||
+1
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
|
||||
class SocketAckManagerTest: XCTestCase {
|
||||
var ackManager = SocketAckManager()
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
|
||||
class SocketBasicPacketTest: XCTestCase {
|
||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
|
||||
class SocketEngineTest: XCTestCase {
|
||||
var client: SocketIOClient!
|
||||
@@ -14,8 +15,8 @@ class SocketEngineTest: XCTestCase {
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
client = SocketIOClient(socketURL: "")
|
||||
engine = SocketEngine(client: client, url: "", options: nil)
|
||||
client = SocketIOClient(socketURL: NSURL(string: "http://localhost")!)
|
||||
engine = SocketEngine(client: client, url: NSURL(string: "http://localhost")!, options: nil)
|
||||
|
||||
client.setTestable()
|
||||
}
|
||||
@@ -49,4 +50,28 @@ class SocketEngineTest: XCTestCase {
|
||||
engine.parsePollingMessage("15:42[\"blankTest\"]24:42[\"stringTest\",\"hello\"]")
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testEngineDoesErrorOnUnknownTransport() {
|
||||
let finalExpectation = expectationWithDescription("Unknown Transport")
|
||||
|
||||
client.on("error") {data, ack in
|
||||
if let error = data[0] as? String where error == "Unknown transport" {
|
||||
finalExpectation.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
engine.parseEngineMessage("{\"code\": 0, \"message\": \"Unknown transport\"}", fromPolling: false)
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testEngineDoesErrorOnUnknownMessage() {
|
||||
let finalExpectation = expectationWithDescription("Engine Errors")
|
||||
|
||||
client.on("error") {data, ack in
|
||||
finalExpectation.fulfill()
|
||||
}
|
||||
|
||||
engine.parseEngineMessage("afafafda", fromPolling: false)
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
|
||||
class SocketNamespacePacketTest: XCTestCase {
|
||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
|
||||
@@ -7,8 +7,10 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
|
||||
class SocketParserTest: XCTestCase {
|
||||
let testSocket = SocketIOClient(socketURL: NSURL())
|
||||
|
||||
//Format key: message; namespace-data-binary-id
|
||||
static let packetTypes: Dictionary<String, (String, [AnyObject], [NSData], Int)> = [
|
||||
@@ -92,7 +94,7 @@ class SocketParserTest: XCTestCase {
|
||||
|
||||
func testInvalidInput() {
|
||||
let message = "8"
|
||||
switch SocketParser.parseString(message) {
|
||||
switch testSocket.parseString(message) {
|
||||
case .Left(_):
|
||||
return
|
||||
case .Right(_):
|
||||
@@ -110,7 +112,7 @@ class SocketParserTest: XCTestCase {
|
||||
|
||||
func validateParseResult(message: String) {
|
||||
let validValues = SocketParserTest.packetTypes[message]!
|
||||
let packet = SocketParser.parseString(message)
|
||||
let packet = testSocket.parseString(message)
|
||||
let type = message.substringWithRange(Range<String.Index>(start: message.startIndex, end: message.startIndex.advancedBy(1)))
|
||||
if case let .Right(packet) = packet {
|
||||
XCTAssertEqual(packet.type, SocketPacket.PacketType(rawValue: Int(type) ?? -1)!)
|
||||
@@ -127,7 +129,7 @@ class SocketParserTest: XCTestCase {
|
||||
let keys = Array(SocketParserTest.packetTypes.keys)
|
||||
measureBlock({
|
||||
for item in keys.enumerate() {
|
||||
SocketParser.parseString(item.element)
|
||||
self.testSocket.parseString(item.element)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -7,15 +7,16 @@
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import SocketIOClientSwift
|
||||
|
||||
class SocketSideEffectTest: XCTestCase {
|
||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
let data2 = "test2".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||
private var socket: SocketIOClient!
|
||||
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
socket = SocketIOClient(socketURL: "")
|
||||
socket = SocketIOClient(socketURL: NSURL())
|
||||
socket.setTestable()
|
||||
}
|
||||
|
||||
@@ -31,7 +32,7 @@ class SocketSideEffectTest: XCTestCase {
|
||||
func testSecondAck() {
|
||||
socket.emitWithAck("test")(timeoutAfter: 0) {data in}
|
||||
socket.emitWithAck("test")(timeoutAfter: 0) {data in}
|
||||
|
||||
|
||||
XCTAssertEqual(socket.currentAck, 1)
|
||||
}
|
||||
|
||||
@@ -46,6 +47,18 @@ class SocketSideEffectTest: XCTestCase {
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testHandleAck2() {
|
||||
let expectation = expectationWithDescription("handled ack2")
|
||||
socket.emitWithAck("test")(timeoutAfter: 0) {data in
|
||||
XCTAssertTrue(data.count == 2, "Wrong number of ack items")
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
socket.parseSocketMessage("61-0[{\"_placeholder\":true,\"num\":0},{\"test\":true}]")
|
||||
socket.parseBinaryData(NSData())
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testHandleEvent() {
|
||||
let expectation = expectationWithDescription("handled event")
|
||||
socket.on("test") {data, ack in
|
||||
@@ -87,6 +100,18 @@ class SocketSideEffectTest: XCTestCase {
|
||||
XCTAssertEqual(socket.testHandlers.count, 1)
|
||||
}
|
||||
|
||||
func testHandlesErrorPacket() {
|
||||
let expectation = expectationWithDescription("Handled error")
|
||||
socket.on("error") {data, ack in
|
||||
if let error = data[0] as? String where error == "test error" {
|
||||
expectation.fulfill()
|
||||
}
|
||||
}
|
||||
|
||||
socket.parseSocketMessage("4\"test error\"")
|
||||
waitForExpectationsWithTimeout(3, handler: nil)
|
||||
}
|
||||
|
||||
func testHandleBinaryEvent() {
|
||||
let expectation = expectationWithDescription("handled binary event")
|
||||
socket.on("test") {data, ack in
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
|
||||
@@ -34,13 +34,13 @@ public final class SocketAckEmitter: NSObject {
|
||||
}
|
||||
|
||||
public func with(items: AnyObject...) {
|
||||
guard ackNum != -1 else {return}
|
||||
guard ackNum != -1 else { return }
|
||||
|
||||
socket.emitAck(ackNum, withItems: items)
|
||||
}
|
||||
|
||||
public func with(items: [AnyObject]) {
|
||||
guard ackNum != -1 else {return}
|
||||
guard ackNum != -1 else { return }
|
||||
|
||||
socket.emitAck(ackNum, withItems: items)
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public final class SocketAnyEvent: NSObject {
|
||||
public let event: String!
|
||||
public final class SocketAnyEvent: NSObject {
|
||||
public let event: String
|
||||
public let items: NSArray?
|
||||
override public var description: String {
|
||||
return "SocketAnyEvent: Event: \(event) items: \(items ?? nil)"
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
//
|
||||
// SocketClientSpec.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 1/3/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.
|
||||
|
||||
protocol SocketClientSpec: class {
|
||||
var nsp: String { get set }
|
||||
var waitingData: [SocketPacket] { get set }
|
||||
|
||||
func didConnect()
|
||||
func didDisconnect(reason: String)
|
||||
func didError(reason: String)
|
||||
func handleAck(ack: Int, data: [AnyObject])
|
||||
func handleEvent(event: String, data: [AnyObject], isInternalMessage: Bool, withAck ack: Int)
|
||||
func joinNamespace(namespace: String)
|
||||
}
|
||||
|
||||
extension SocketClientSpec {
|
||||
func didError(reason: String) {
|
||||
DefaultSocketLogger.Logger.error("%@", type: "SocketIOClient", args: reason)
|
||||
|
||||
handleEvent("error", data: [reason], isInternalMessage: true, withAck: -1)
|
||||
}
|
||||
}
|
||||
+176
-415
@@ -24,12 +24,37 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
public private(set) var sid = ""
|
||||
public final class SocketEngine: NSObject, 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)
|
||||
|
||||
public var connectParams: [String: AnyObject]? {
|
||||
didSet {
|
||||
(urlPolling, urlWebSocket) = createURLs()
|
||||
}
|
||||
}
|
||||
public var postWait = [String]()
|
||||
public var waitingForPoll = false
|
||||
public var waitingForPost = false
|
||||
|
||||
public private(set) var closed = false
|
||||
public private(set) var connected = false
|
||||
public private(set) var cookies: [NSHTTPCookie]?
|
||||
public private(set) var socketPath = "/engine.io"
|
||||
public private(set) var urlPolling = ""
|
||||
public private(set) var urlWebSocket = ""
|
||||
public private(set) var extraHeaders: [String: String]?
|
||||
public private(set) var fastUpgrade = false
|
||||
public private(set) var forcePolling = false
|
||||
public private(set) var forceWebsockets = false
|
||||
public private(set) var invalidated = false
|
||||
public private(set) var pingTimer: NSTimer?
|
||||
public private(set) var polling = true
|
||||
public private(set) var probing = false
|
||||
public private(set) var session: NSURLSession?
|
||||
public private(set) var sid = ""
|
||||
public private(set) var socketPath = "/engine.io/"
|
||||
public private(set) var urlPolling = NSURL()
|
||||
public private(set) var urlWebSocket = NSURL()
|
||||
public private(set) var websocket = false
|
||||
public private(set) var ws: WebSocket?
|
||||
|
||||
public weak var client: SocketEngineClient?
|
||||
@@ -39,23 +64,10 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
private typealias Probe = (msg: String, type: SocketEnginePacketType, data: [NSData])
|
||||
private typealias ProbeWaitQueue = [Probe]
|
||||
|
||||
private let allowedCharacterSet = NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
|
||||
private let emitQueue = dispatch_queue_create("com.socketio.engineEmitQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let handleQueue = dispatch_queue_create("com.socketio.engineHandleQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let logType = "SocketEngine"
|
||||
private let parseQueue = dispatch_queue_create("com.socketio.engineParseQueue", DISPATCH_QUEUE_SERIAL)
|
||||
private let url: String
|
||||
private let workQueue = NSOperationQueue()
|
||||
|
||||
private var connectParams: [String: AnyObject]?
|
||||
private var closed = false
|
||||
private var extraHeaders: [String: String]?
|
||||
private var fastUpgrade = false
|
||||
private var forcePolling = false
|
||||
private var forceWebsockets = false
|
||||
private var invalidated = false
|
||||
private let url: NSURL
|
||||
|
||||
private var pingInterval: Double?
|
||||
private var pingTimer: NSTimer?
|
||||
private var pingTimeout = 0.0 {
|
||||
didSet {
|
||||
pongsMissedMax = Int(pingTimeout / (pingInterval ?? 25))
|
||||
@@ -63,57 +75,65 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
}
|
||||
private var pongsMissed = 0
|
||||
private var pongsMissedMax = 0
|
||||
private var postWait = [String]()
|
||||
private var probing = false
|
||||
private var probeWait = ProbeWaitQueue()
|
||||
private var secure = false
|
||||
private var selfSigned = false
|
||||
private var session: NSURLSession?
|
||||
private var voipEnabled = false
|
||||
private var waitingForPoll = false
|
||||
private var waitingForPost = false
|
||||
private var websocketConnected = false
|
||||
private(set) var connected = false
|
||||
private(set) var polling = true
|
||||
private(set) var websocket = false
|
||||
|
||||
public init(client: SocketEngineClient, url: String, options: Set<SocketIOClientOption>) {
|
||||
|
||||
public init(client: SocketEngineClient, url: NSURL, options: Set<SocketIOClientOption>) {
|
||||
self.client = client
|
||||
self.url = url
|
||||
|
||||
|
||||
for option in options {
|
||||
switch option {
|
||||
case .SessionDelegate(let delegate):
|
||||
case let .ConnectParams(params):
|
||||
connectParams = params
|
||||
case let .SessionDelegate(delegate):
|
||||
sessionDelegate = delegate
|
||||
case .ForcePolling(let force):
|
||||
case let .ForcePolling(force):
|
||||
forcePolling = force
|
||||
case .ForceWebsockets(let force):
|
||||
case let .ForceWebsockets(force):
|
||||
forceWebsockets = force
|
||||
case .Cookies(let cookies):
|
||||
case let .Cookies(cookies):
|
||||
self.cookies = cookies
|
||||
case .Path(let path):
|
||||
case let .Path(path):
|
||||
socketPath = path
|
||||
case .ExtraHeaders(let headers):
|
||||
case let .ExtraHeaders(headers):
|
||||
extraHeaders = headers
|
||||
case .VoipEnabled(let enable):
|
||||
case let .VoipEnabled(enable):
|
||||
voipEnabled = enable
|
||||
case .Secure(let secure):
|
||||
case let .Secure(secure):
|
||||
self.secure = secure
|
||||
case .SelfSigned(let selfSigned):
|
||||
case let .SelfSigned(selfSigned):
|
||||
self.selfSigned = selfSigned
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
super.init()
|
||||
|
||||
(urlPolling, urlWebSocket) = createURLs()
|
||||
}
|
||||
|
||||
public convenience init(client: SocketEngineClient, url: String, options: NSDictionary?) {
|
||||
self.init(client: client, url: url,
|
||||
options: Set<SocketIOClientOption>.NSDictionaryToSocketOptionsSet(options ?? [:]))
|
||||
public convenience init(client: SocketEngineClient, url: NSURL, options: NSDictionary?) {
|
||||
self.init(client: client, url: url, options: options?.toSocketOptionsSet() ?? [])
|
||||
}
|
||||
|
||||
@available(*, deprecated=5.3)
|
||||
public convenience init(client: SocketEngineClient, urlString: String, options: Set<SocketIOClientOption>) {
|
||||
guard let url = NSURL(string: urlString) else { fatalError("Incorrect url") }
|
||||
self.init(client: client, url: url, options: options)
|
||||
}
|
||||
|
||||
@available(*, deprecated=5.3)
|
||||
public convenience init(client: SocketEngineClient, urlString: String, options: NSDictionary?) {
|
||||
guard let url = NSURL(string: urlString) else { fatalError("Incorrect url") }
|
||||
self.init(client: client, url: url, options: options?.toSocketOptionsSet() ?? [])
|
||||
}
|
||||
|
||||
deinit {
|
||||
DefaultSocketLogger.Logger.log("Engine is being deinit", type: logType)
|
||||
DefaultSocketLogger.Logger.log("Engine is being released", type: logType)
|
||||
closed = true
|
||||
stopPolling()
|
||||
}
|
||||
@@ -130,20 +150,19 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
|
||||
switch code {
|
||||
case 0: // Unknown transport
|
||||
logAndError(error)
|
||||
case 1: // Unknown sid. clear and retry connect
|
||||
sid = ""
|
||||
open(connectParams)
|
||||
didError(error)
|
||||
case 1: // Unknown sid.
|
||||
didError(error)
|
||||
case 2: // Bad handshake request
|
||||
logAndError(error)
|
||||
didError(error)
|
||||
case 3: // Bad request
|
||||
logAndError(error)
|
||||
didError(error)
|
||||
default:
|
||||
logAndError(error)
|
||||
didError(error)
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
logAndError("Got unknown error from server")
|
||||
didError("Got unknown error from server \(msg)")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,7 +173,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
|
||||
if let data = NSData(base64EncodedString: noPrefix,
|
||||
options: .IgnoreUnknownCharacters) {
|
||||
client?.parseBinaryData(data)
|
||||
client?.parseEngineBinaryData(data)
|
||||
}
|
||||
|
||||
return true
|
||||
@@ -163,83 +182,68 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
public func close() {
|
||||
DefaultSocketLogger.Logger.log("Engine is being closed.", type: logType)
|
||||
|
||||
pingTimer?.invalidate()
|
||||
closed = true
|
||||
connected = false
|
||||
|
||||
if websocket {
|
||||
sendWebSocketMessage("", withType: .Close)
|
||||
} else {
|
||||
sendPollMessage("", withType: .Close)
|
||||
public func close(reason: String) {
|
||||
func postSendClose(data: NSData?, _ res: NSURLResponse?, _ err: NSError?) {
|
||||
sid = ""
|
||||
closed = true
|
||||
invalidated = true
|
||||
connected = false
|
||||
|
||||
pingTimer?.invalidate()
|
||||
ws?.disconnect()
|
||||
stopPolling()
|
||||
client?.engineDidClose(reason)
|
||||
}
|
||||
|
||||
ws?.disconnect()
|
||||
stopPolling()
|
||||
client?.engineDidClose("Disconnect")
|
||||
}
|
||||
|
||||
private func createBinaryDataForSend(data: NSData) -> Either<NSData, String> {
|
||||
DefaultSocketLogger.Logger.log("Engine is being closed.", type: logType)
|
||||
|
||||
if websocket {
|
||||
var byteArray = [UInt8](count: 1, repeatedValue: 0x0)
|
||||
byteArray[0] = 4
|
||||
let mutData = NSMutableData(bytes: &byteArray, length: 1)
|
||||
|
||||
mutData.appendData(data)
|
||||
|
||||
return .Left(mutData)
|
||||
sendWebSocketMessage("", withType: .Close, withData: [])
|
||||
postSendClose(nil, nil, nil)
|
||||
} else {
|
||||
let str = "b4" + data.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
|
||||
|
||||
return .Right(str)
|
||||
// We need to take special care when we're polling that we send it ASAP
|
||||
postWait.append(String(SocketEnginePacketType.Close.rawValue))
|
||||
let req = createRequestForPostWithPostWait()
|
||||
doRequest(req, withCallback: postSendClose)
|
||||
}
|
||||
}
|
||||
|
||||
private func createURLs(params: [String: AnyObject]?) -> (String, String) {
|
||||
private func createURLs() -> (NSURL, NSURL) {
|
||||
if client == nil {
|
||||
return ("", "")
|
||||
return (NSURL(), NSURL())
|
||||
}
|
||||
|
||||
let socketURL = "\(url)\(socketPath)/?transport="
|
||||
var urlPolling: String
|
||||
var urlWebSocket: String
|
||||
let urlPolling = NSURLComponents(string: url.absoluteString)!
|
||||
let urlWebSocket = NSURLComponents(string: url.absoluteString)!
|
||||
var queryString = ""
|
||||
|
||||
urlWebSocket.path = socketPath
|
||||
urlPolling.path = socketPath
|
||||
urlWebSocket.query = "transport=websocket"
|
||||
urlPolling.query = "transport=polling&b64=1"
|
||||
|
||||
if secure {
|
||||
urlPolling = "https://" + socketURL + "polling"
|
||||
urlWebSocket = "wss://" + socketURL + "websocket"
|
||||
urlPolling.scheme = "https"
|
||||
urlWebSocket.scheme = "wss"
|
||||
} else {
|
||||
urlPolling = "http://" + socketURL + "polling"
|
||||
urlWebSocket = "ws://" + socketURL + "websocket"
|
||||
urlPolling.scheme = "http"
|
||||
urlWebSocket.scheme = "ws"
|
||||
}
|
||||
|
||||
if params != nil {
|
||||
for (key, value) in params! {
|
||||
let keyEsc = key.stringByAddingPercentEncodingWithAllowedCharacters(
|
||||
allowedCharacterSet)!
|
||||
urlPolling += "&\(keyEsc)="
|
||||
urlWebSocket += "&\(keyEsc)="
|
||||
|
||||
if value is String {
|
||||
let valueEsc = (value as! String).stringByAddingPercentEncodingWithAllowedCharacters(
|
||||
allowedCharacterSet)!
|
||||
urlPolling += "\(valueEsc)"
|
||||
urlWebSocket += "\(valueEsc)"
|
||||
} else {
|
||||
urlPolling += "\(value)"
|
||||
urlWebSocket += "\(value)"
|
||||
}
|
||||
if connectParams != nil {
|
||||
for (key, value) in connectParams! {
|
||||
queryString += "&\(key)=\(value)"
|
||||
}
|
||||
}
|
||||
|
||||
return (urlPolling, urlWebSocket)
|
||||
urlWebSocket.query = urlWebSocket.query! + queryString
|
||||
urlPolling.query = urlPolling.query! + queryString
|
||||
|
||||
return (urlPolling.URL!, urlWebSocket.URL!)
|
||||
}
|
||||
|
||||
private func createWebsocketAndConnect(connect: Bool) {
|
||||
let wsUrl = urlWebSocket + (sid == "" ? "" : "&sid=\(sid)")
|
||||
|
||||
ws = WebSocket(url: NSURL(string: wsUrl)!)
|
||||
private func createWebsocketAndConnect() {
|
||||
ws = WebSocket(url: urlWebSocketWithSid)
|
||||
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
@@ -259,18 +263,22 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
ws?.delegate = self
|
||||
ws?.selfSignedSSL = selfSigned
|
||||
|
||||
if connect {
|
||||
ws?.connect()
|
||||
}
|
||||
ws?.connect()
|
||||
}
|
||||
|
||||
public func didError(error: String) {
|
||||
DefaultSocketLogger.Logger.error(error, type: logType)
|
||||
client?.engineDidError(error)
|
||||
close(error)
|
||||
}
|
||||
|
||||
private func doFastUpgrade() {
|
||||
public func doFastUpgrade() {
|
||||
if waitingForPoll {
|
||||
DefaultSocketLogger.Logger.error("Outstanding poll when switched to WebSockets," +
|
||||
"we'll probably disconnect soon. You should report this.", type: logType)
|
||||
}
|
||||
|
||||
sendWebSocketMessage("", withType: .Upgrade, datas: nil)
|
||||
sendWebSocketMessage("", withType: .Upgrade, withData: [])
|
||||
websocket = true
|
||||
polling = false
|
||||
fastUpgrade = false
|
||||
@@ -293,13 +301,25 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We had packets waiting for send when we upgraded
|
||||
// Send them raw
|
||||
public func flushWaitingForPostToWebSocket() {
|
||||
guard let ws = self.ws else { return }
|
||||
|
||||
for msg in postWait {
|
||||
ws.writeString(fixDoubleUTF8(msg))
|
||||
}
|
||||
|
||||
postWait.removeAll(keepCapacity: true)
|
||||
}
|
||||
|
||||
private func handleClose(reason: String) {
|
||||
client?.engineDidClose(reason)
|
||||
}
|
||||
|
||||
private func handleMessage(message: String) {
|
||||
client?.parseSocketMessage(message)
|
||||
client?.parseEngineMessage(message)
|
||||
}
|
||||
|
||||
private func handleNOOP() {
|
||||
@@ -318,7 +338,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
connected = true
|
||||
|
||||
if let upgrades = json?["upgrades"] as? [String] {
|
||||
upgradeWs = upgrades.filter {$0 == "websocket"}.count != 0
|
||||
upgradeWs = upgrades.contains("websocket")
|
||||
} else {
|
||||
upgradeWs = false
|
||||
}
|
||||
@@ -329,19 +349,22 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
}
|
||||
|
||||
if !forcePolling && !forceWebsockets && upgradeWs {
|
||||
createWebsocketAndConnect(true)
|
||||
createWebsocketAndConnect()
|
||||
}
|
||||
|
||||
|
||||
startPingTimer()
|
||||
|
||||
if !forceWebsockets {
|
||||
doPoll()
|
||||
}
|
||||
|
||||
client?.engineDidOpen?("Connect")
|
||||
}
|
||||
} catch {
|
||||
DefaultSocketLogger.Logger.error("Error parsing open packet", type: logType)
|
||||
didError("Error parsing open packet")
|
||||
return
|
||||
}
|
||||
|
||||
startPingTimer()
|
||||
|
||||
if !forceWebsockets {
|
||||
doPoll()
|
||||
}
|
||||
}
|
||||
|
||||
private func handlePong(pongMessage: String) {
|
||||
@@ -353,50 +376,26 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
// A poll failed, tell the client about it
|
||||
private func handlePollingFailed(reason: String) {
|
||||
connected = false
|
||||
ws?.disconnect()
|
||||
pingTimer?.invalidate()
|
||||
waitingForPoll = false
|
||||
waitingForPost = false
|
||||
|
||||
if !closed {
|
||||
client?.didError(reason)
|
||||
client?.engineDidClose(reason)
|
||||
}
|
||||
}
|
||||
|
||||
private func logAndError(error: String) {
|
||||
DefaultSocketLogger.Logger.error(error, type: logType)
|
||||
client?.didError(error)
|
||||
}
|
||||
|
||||
public func open(opts: [String: AnyObject]? = nil) {
|
||||
connectParams = opts
|
||||
|
||||
public func open() {
|
||||
if connected {
|
||||
DefaultSocketLogger.Logger.error("Tried to open while connected", type: logType)
|
||||
client?.didError("Tried to open engine while connected")
|
||||
|
||||
DefaultSocketLogger.Logger.error("Engine tried opening while connected. This is probably a programming error. "
|
||||
+ "Abandoning open attempt", type: logType)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
DefaultSocketLogger.Logger.log("Starting engine", type: logType)
|
||||
DefaultSocketLogger.Logger.log("Handshaking", type: logType)
|
||||
|
||||
resetEngine()
|
||||
|
||||
(urlPolling, urlWebSocket) = createURLs(opts)
|
||||
|
||||
if forceWebsockets {
|
||||
polling = false
|
||||
websocket = true
|
||||
createWebsocketAndConnect(true)
|
||||
createWebsocketAndConnect()
|
||||
return
|
||||
}
|
||||
|
||||
let reqPolling = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&b64=1")!)
|
||||
let reqPolling = NSMutableURLRequest(URL: urlPolling)
|
||||
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
@@ -412,12 +411,12 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
doLongPoll(reqPolling)
|
||||
}
|
||||
|
||||
private func parseEngineData(data: NSData) {
|
||||
public func parseEngineData(data: NSData) {
|
||||
DefaultSocketLogger.Logger.log("Got binary data: %@", type: "SocketEngine", args: data)
|
||||
client?.parseBinaryData(data.subdataWithRange(NSMakeRange(1, data.length - 1)))
|
||||
client?.parseEngineBinaryData(data.subdataWithRange(NSMakeRange(1, data.length - 1)))
|
||||
}
|
||||
|
||||
private func parseEngineMessage(message: String, fromPolling: Bool) {
|
||||
public func parseEngineMessage(message: String, fromPolling: Bool) {
|
||||
DefaultSocketLogger.Logger.log("Got message: %@", type: logType, args: message)
|
||||
|
||||
let reader = SocketStringReader(message: message)
|
||||
@@ -452,13 +451,6 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
DefaultSocketLogger.Logger.log("Got unknown packet type", type: logType)
|
||||
}
|
||||
}
|
||||
|
||||
private func probeWebSocket() {
|
||||
if websocketConnected {
|
||||
sendWebSocketMessage("probe", withType: .Ping)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func resetEngine() {
|
||||
closed = false
|
||||
@@ -469,21 +461,11 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
invalidated = false
|
||||
session = NSURLSession(configuration: .defaultSessionConfiguration(),
|
||||
delegate: sessionDelegate,
|
||||
delegateQueue: workQueue)
|
||||
delegateQueue: NSOperationQueue())
|
||||
sid = ""
|
||||
waitingForPoll = false
|
||||
waitingForPost = false
|
||||
websocket = false
|
||||
websocketConnected = false
|
||||
}
|
||||
|
||||
/// Send an engine message (4)
|
||||
public func send(msg: String, withData datas: [NSData]) {
|
||||
if probing {
|
||||
probeWait.append((msg, .Message, datas))
|
||||
} else {
|
||||
write(msg, withType: .Message, withData: datas)
|
||||
}
|
||||
}
|
||||
|
||||
@objc private func sendPing() {
|
||||
@@ -494,7 +476,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
++pongsMissed
|
||||
pongsMissed += 1
|
||||
write("", withType: .Ping, withData: [])
|
||||
}
|
||||
|
||||
@@ -512,250 +494,38 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||
}
|
||||
|
||||
private func upgradeTransport() {
|
||||
if websocketConnected {
|
||||
if ws?.isConnected ?? false {
|
||||
DefaultSocketLogger.Logger.log("Upgrading transport to WebSockets", type: logType)
|
||||
|
||||
fastUpgrade = true
|
||||
sendPollMessage("", withType: .Noop)
|
||||
sendPollMessage("", withType: .Noop, withData: [])
|
||||
// After this point, we should not send anymore polling messages
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Write a message, independent of transport.
|
||||
*/
|
||||
*/
|
||||
public func write(msg: String, withType type: SocketEnginePacketType, withData data: [NSData]) {
|
||||
dispatch_async(emitQueue) {
|
||||
if self.connected {
|
||||
if self.websocket {
|
||||
DefaultSocketLogger.Logger.log("Writing ws: %@ has data: %@",
|
||||
type: self.logType, args: msg, data.count != 0)
|
||||
self.sendWebSocketMessage(msg, withType: type, datas: data)
|
||||
} else {
|
||||
DefaultSocketLogger.Logger.log("Writing poll: %@ has data: %@",
|
||||
type: self.logType, args: msg, data.count != 0)
|
||||
self.sendPollMessage(msg, withType: type, datas: data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Polling methods
|
||||
extension SocketEngine {
|
||||
private func addHeaders(req: NSMutableURLRequest) {
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
req.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
if extraHeaders != nil {
|
||||
for (headerName, value) in extraHeaders! {
|
||||
req.setValue(value, forHTTPHeaderField: headerName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func doPoll() {
|
||||
if websocket || waitingForPoll || !connected || closed {
|
||||
return
|
||||
}
|
||||
|
||||
waitingForPoll = true
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&sid=\(sid)&b64=1")!)
|
||||
|
||||
addHeaders(req)
|
||||
doLongPoll(req)
|
||||
}
|
||||
|
||||
private func doRequest(req: NSMutableURLRequest,
|
||||
withCallback callback: (NSData?, NSURLResponse?, NSError?) -> Void) {
|
||||
if !polling || closed || invalidated {
|
||||
DefaultSocketLogger.Logger.error("Tried to do polling request when not supposed to", type: logType)
|
||||
return
|
||||
}
|
||||
guard self.connected else { return }
|
||||
|
||||
DefaultSocketLogger.Logger.log("Doing polling request", type: logType)
|
||||
|
||||
req.cachePolicy = .ReloadIgnoringLocalAndRemoteCacheData
|
||||
session?.dataTaskWithRequest(req, completionHandler: callback).resume()
|
||||
}
|
||||
|
||||
private func doLongPoll(req: NSMutableURLRequest) {
|
||||
doRequest(req) {[weak self] data, res, err in
|
||||
guard let this = self else {return}
|
||||
|
||||
if err != nil || data == nil {
|
||||
DefaultSocketLogger.Logger.error(err?.localizedDescription ?? "Error", type: this.logType)
|
||||
|
||||
if this.polling {
|
||||
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Got polling response", type: this.logType)
|
||||
|
||||
if let str = String(data: data!, encoding: NSUTF8StringEncoding) {
|
||||
dispatch_async(this.parseQueue) {
|
||||
this.parsePollingMessage(str)
|
||||
}
|
||||
}
|
||||
|
||||
this.waitingForPoll = false
|
||||
|
||||
if this.fastUpgrade {
|
||||
this.doFastUpgrade()
|
||||
} else if !this.closed && this.polling {
|
||||
this.doPoll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func flushWaitingForPost() {
|
||||
if postWait.count == 0 || !connected {
|
||||
return
|
||||
} else if websocket {
|
||||
flushWaitingForPostToWebSocket()
|
||||
return
|
||||
}
|
||||
|
||||
var postStr = ""
|
||||
|
||||
for packet in postWait {
|
||||
let len = packet.characters.count
|
||||
|
||||
postStr += "\(len):\(packet)"
|
||||
}
|
||||
|
||||
postWait.removeAll(keepCapacity: false)
|
||||
|
||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&sid=\(sid)")!)
|
||||
|
||||
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")
|
||||
|
||||
waitingForPost = true
|
||||
|
||||
DefaultSocketLogger.Logger.log("POSTing: %@", type: logType, args: postStr)
|
||||
|
||||
doRequest(req) {[weak self] data, res, err in
|
||||
guard let this = self else {return}
|
||||
|
||||
if err != nil {
|
||||
DefaultSocketLogger.Logger.error(err?.localizedDescription ?? "Error", type: this.logType)
|
||||
|
||||
if this.polling {
|
||||
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.waitingForPost = false
|
||||
|
||||
dispatch_async(this.emitQueue) {
|
||||
if !this.fastUpgrade {
|
||||
this.flushWaitingForPost()
|
||||
this.doPoll()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// We had packets waiting for send when we upgraded
|
||||
// Send them raw
|
||||
private func flushWaitingForPostToWebSocket() {
|
||||
guard let ws = self.ws else { return }
|
||||
|
||||
for msg in postWait {
|
||||
ws.writeString(fixDoubleUTF8(msg))
|
||||
}
|
||||
|
||||
postWait.removeAll(keepCapacity: true)
|
||||
}
|
||||
|
||||
func parsePollingMessage(str: String) {
|
||||
guard str.characters.count != 1 else {
|
||||
return
|
||||
}
|
||||
|
||||
var reader = SocketStringReader(message: str)
|
||||
|
||||
while reader.hasNext {
|
||||
if let n = Int(reader.readUntilStringOccurence(":")) {
|
||||
let str = reader.read(n)
|
||||
|
||||
dispatch_async(handleQueue) {
|
||||
self.parseEngineMessage(str, fromPolling: true)
|
||||
}
|
||||
if self.websocket {
|
||||
DefaultSocketLogger.Logger.log("Writing ws: %@ has data: %@",
|
||||
type: self.logType, args: msg, data.count != 0)
|
||||
self.sendWebSocketMessage(msg, withType: type, withData: data)
|
||||
} else if !self.probing {
|
||||
DefaultSocketLogger.Logger.log("Writing poll: %@ has data: %@",
|
||||
type: self.logType, args: msg, data.count != 0)
|
||||
self.sendPollMessage(msg, withType: type, withData: data)
|
||||
} else {
|
||||
dispatch_async(handleQueue) {
|
||||
self.parseEngineMessage(str, fromPolling: true)
|
||||
}
|
||||
break
|
||||
self.probeWait.append((msg, type, data))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Send polling message.
|
||||
/// Only call on emitQueue
|
||||
private func sendPollMessage(message: String, withType type: SocketEnginePacketType,
|
||||
datas:[NSData]? = nil) {
|
||||
DefaultSocketLogger.Logger.log("Sending poll: %@ as type: %@", type: logType, args: message, type.rawValue)
|
||||
let fixedMessage = doubleEncodeUTF8(message)
|
||||
let strMsg = "\(type.rawValue)\(fixedMessage)"
|
||||
|
||||
postWait.append(strMsg)
|
||||
|
||||
for data in datas ?? [] {
|
||||
if case let .Right(bin) = createBinaryDataForSend(data) {
|
||||
postWait.append(bin)
|
||||
}
|
||||
}
|
||||
|
||||
if !waitingForPost {
|
||||
flushWaitingForPost()
|
||||
}
|
||||
}
|
||||
|
||||
private func stopPolling() {
|
||||
invalidated = true
|
||||
session?.finishTasksAndInvalidate()
|
||||
}
|
||||
}
|
||||
|
||||
// WebSocket methods
|
||||
extension SocketEngine {
|
||||
/// Send message on WebSockets
|
||||
/// Only call on emitQueue
|
||||
private func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType,
|
||||
datas:[NSData]? = nil) {
|
||||
DefaultSocketLogger.Logger.log("Sending ws: %@ as type: %@", type: logType, args: str, type.rawValue)
|
||||
|
||||
ws?.writeString("\(type.rawValue)\(str)")
|
||||
|
||||
for data in datas ?? [] {
|
||||
if case let .Left(bin) = createBinaryDataForSend(data) {
|
||||
ws?.writeData(bin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delagate methods
|
||||
|
||||
public func websocketDidConnect(socket:WebSocket) {
|
||||
websocketConnected = true
|
||||
|
||||
// Delegate methods
|
||||
public func websocketDidConnect(socket: WebSocket) {
|
||||
if !forceWebsockets {
|
||||
probing = true
|
||||
probeWebSocket()
|
||||
@@ -767,7 +537,6 @@ extension SocketEngine {
|
||||
}
|
||||
|
||||
public func websocketDidDisconnect(socket: WebSocket, error: NSError?) {
|
||||
websocketConnected = false
|
||||
probing = false
|
||||
|
||||
if closed {
|
||||
@@ -783,7 +552,7 @@ extension SocketEngine {
|
||||
let reason = error?.localizedDescription ?? "Socket Disconnected"
|
||||
|
||||
if error != nil {
|
||||
client?.didError(reason)
|
||||
didError(reason)
|
||||
}
|
||||
|
||||
client?.engineDidClose(reason)
|
||||
@@ -791,12 +560,4 @@ extension SocketEngine {
|
||||
flushProbeWait()
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
|
||||
parseEngineMessage(text, fromPolling: false)
|
||||
}
|
||||
|
||||
public func websocketDidReceiveData(socket: WebSocket, data: NSData) {
|
||||
parseEngineData(data)
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,10 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
@objc public protocol SocketEngineClient {
|
||||
func didError(reason: AnyObject)
|
||||
@objc public protocol SocketEngineClient {
|
||||
func engineDidError(reason: String)
|
||||
func engineDidClose(reason: String)
|
||||
func parseSocketMessage(msg: String)
|
||||
func parseBinaryData(data: NSData)
|
||||
optional func engineDidOpen(reason: String)
|
||||
func parseEngineMessage(msg: String)
|
||||
func parseEngineBinaryData(data: NSData)
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
//
|
||||
// SocketEnginePollable.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 1/15/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
|
||||
|
||||
/// Protocol that is used to implement socket.io polling support
|
||||
public protocol SocketEnginePollable: SocketEngineSpec {
|
||||
var invalidated: Bool { get }
|
||||
/// Holds strings waiting to be sent over polling.
|
||||
/// You shouldn't need to mess with this.
|
||||
var postWait: [String] { get set }
|
||||
var session: NSURLSession? { get }
|
||||
/// Because socket.io doesn't let you send two polling request at the same time
|
||||
/// we have to keep track if there's an outstanding poll
|
||||
var waitingForPoll: Bool { get set }
|
||||
/// Because socket.io doesn't let you send two post request at the same time
|
||||
/// we have to keep track if there's an outstanding post
|
||||
var waitingForPost: Bool { get set }
|
||||
|
||||
func doPoll()
|
||||
func sendPollMessage(message: String, withType type: SocketEnginePacketType, withData datas: [NSData])
|
||||
func stopPolling()
|
||||
}
|
||||
|
||||
// Default polling methods
|
||||
extension SocketEnginePollable {
|
||||
private func addHeaders(req: NSMutableURLRequest) {
|
||||
if cookies != nil {
|
||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||
req.allHTTPHeaderFields = headers
|
||||
}
|
||||
|
||||
if extraHeaders != nil {
|
||||
for (headerName, value) in extraHeaders! {
|
||||
req.setValue(value, forHTTPHeaderField: headerName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func createRequestForPostWithPostWait() -> NSURLRequest {
|
||||
var postStr = ""
|
||||
|
||||
for packet in postWait {
|
||||
let len = packet.characters.count
|
||||
|
||||
postStr += "\(len):\(packet)"
|
||||
}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Created POST string: %@", type: "SocketEnginePolling", args: postStr)
|
||||
|
||||
postWait.removeAll(keepCapacity: false)
|
||||
|
||||
let req = NSMutableURLRequest(URL: urlPollingWithSid)
|
||||
|
||||
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")
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
public func doPoll() {
|
||||
if websocket || waitingForPoll || !connected || closed {
|
||||
return
|
||||
}
|
||||
|
||||
waitingForPoll = true
|
||||
let req = NSMutableURLRequest(URL: urlPollingWithSid)
|
||||
|
||||
addHeaders(req)
|
||||
doLongPoll(req)
|
||||
}
|
||||
|
||||
func doRequest(req: NSURLRequest, withCallback callback: (NSData?, NSURLResponse?, NSError?) -> Void) {
|
||||
if !polling || closed || invalidated {
|
||||
DefaultSocketLogger.Logger.error("Tried to do polling request when not supposed to", type: "SocketEnginePolling")
|
||||
return
|
||||
}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Doing polling request", type: "SocketEnginePolling")
|
||||
|
||||
session?.dataTaskWithRequest(req, completionHandler: callback).resume()
|
||||
}
|
||||
|
||||
func doLongPoll(req: NSURLRequest) {
|
||||
doRequest(req) {[weak self] data, res, err in
|
||||
guard let this = self else { return }
|
||||
|
||||
if err != nil || data == nil {
|
||||
DefaultSocketLogger.Logger.error(err?.localizedDescription ?? "Error", type: "SocketEnginePolling")
|
||||
|
||||
if this.polling {
|
||||
this.didError(err?.localizedDescription ?? "Error")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Got polling response", type: "SocketEnginePolling")
|
||||
|
||||
if let str = String(data: data!, encoding: NSUTF8StringEncoding) {
|
||||
dispatch_async(this.parseQueue) {
|
||||
this.parsePollingMessage(str)
|
||||
}
|
||||
}
|
||||
|
||||
this.waitingForPoll = false
|
||||
|
||||
if this.fastUpgrade {
|
||||
this.doFastUpgrade()
|
||||
} else if !this.closed && this.polling {
|
||||
this.doPoll()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func flushWaitingForPost() {
|
||||
if postWait.count == 0 || !connected {
|
||||
return
|
||||
} else if websocket {
|
||||
flushWaitingForPostToWebSocket()
|
||||
return
|
||||
}
|
||||
|
||||
let req = createRequestForPostWithPostWait()
|
||||
|
||||
waitingForPost = true
|
||||
|
||||
DefaultSocketLogger.Logger.log("POSTing", type: "SocketEnginePolling")
|
||||
|
||||
doRequest(req) {[weak self] data, res, err in
|
||||
guard let this = self else { return }
|
||||
|
||||
if err != nil {
|
||||
DefaultSocketLogger.Logger.error(err?.localizedDescription ?? "Error", type: "SocketEnginePolling")
|
||||
|
||||
if this.polling {
|
||||
this.didError(err?.localizedDescription ?? "Error")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
this.waitingForPost = false
|
||||
|
||||
dispatch_async(this.emitQueue) {
|
||||
if !this.fastUpgrade {
|
||||
this.flushWaitingForPost()
|
||||
this.doPoll()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func parsePollingMessage(str: String) {
|
||||
guard str.characters.count != 1 else {
|
||||
return
|
||||
}
|
||||
|
||||
var reader = SocketStringReader(message: str)
|
||||
|
||||
while reader.hasNext {
|
||||
if let n = Int(reader.readUntilStringOccurence(":")) {
|
||||
let str = reader.read(n)
|
||||
|
||||
dispatch_async(handleQueue) {
|
||||
self.parseEngineMessage(str, fromPolling: true)
|
||||
}
|
||||
} else {
|
||||
dispatch_async(handleQueue) {
|
||||
self.parseEngineMessage(str, fromPolling: true)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Send polling message.
|
||||
/// Only call on emitQueue
|
||||
public func sendPollMessage(message: String, withType type: SocketEnginePacketType, withData datas: [NSData]) {
|
||||
DefaultSocketLogger.Logger.log("Sending poll: %@ as type: %@", type: "SocketEnginePolling", args: message, type.rawValue)
|
||||
let fixedMessage = doubleEncodeUTF8(message)
|
||||
let strMsg = "\(type.rawValue)\(fixedMessage)"
|
||||
|
||||
postWait.append(strMsg)
|
||||
|
||||
for data in datas {
|
||||
if case let .Right(bin) = createBinaryDataForSend(data) {
|
||||
postWait.append(bin)
|
||||
}
|
||||
}
|
||||
|
||||
if !waitingForPost {
|
||||
flushWaitingForPost()
|
||||
}
|
||||
}
|
||||
|
||||
public func stopPolling() {
|
||||
waitingForPoll = false
|
||||
waitingForPost = false
|
||||
session?.finishTasksAndInvalidate()
|
||||
}
|
||||
}
|
||||
@@ -26,17 +26,71 @@
|
||||
import Foundation
|
||||
|
||||
@objc public protocol SocketEngineSpec {
|
||||
weak var client: SocketEngineClient? {get set}
|
||||
var cookies: [NSHTTPCookie]? {get}
|
||||
var sid: String {get}
|
||||
var socketPath: String {get}
|
||||
var urlPolling: String {get}
|
||||
var urlWebSocket: String {get}
|
||||
weak var client: SocketEngineClient? { get set }
|
||||
var closed: Bool { get }
|
||||
var connected: Bool { get }
|
||||
var connectParams: [String: AnyObject]? { get set }
|
||||
var cookies: [NSHTTPCookie]? { get }
|
||||
var extraHeaders: [String: String]? { get }
|
||||
var fastUpgrade: Bool { get }
|
||||
var forcePolling: Bool { get }
|
||||
var forceWebsockets: Bool { get }
|
||||
var parseQueue: dispatch_queue_t! { get }
|
||||
var pingTimer: NSTimer? { get }
|
||||
var polling: Bool { get }
|
||||
var probing: Bool { get }
|
||||
var emitQueue: dispatch_queue_t! { get }
|
||||
var handleQueue: dispatch_queue_t! { get }
|
||||
var sid: String { get }
|
||||
var socketPath: String { get }
|
||||
var urlPolling: NSURL { get }
|
||||
var urlWebSocket: NSURL { get }
|
||||
var websocket: Bool { get }
|
||||
|
||||
init(client: SocketEngineClient, url: String, options: NSDictionary?)
|
||||
init(client: SocketEngineClient, url: NSURL, options: NSDictionary?)
|
||||
|
||||
func close()
|
||||
func open(opts: [String: AnyObject]?)
|
||||
func send(msg: String, withData datas: [NSData])
|
||||
func close(reason: String)
|
||||
func didError(error: String)
|
||||
func doFastUpgrade()
|
||||
func flushWaitingForPostToWebSocket()
|
||||
func open()
|
||||
func parseEngineData(data: NSData)
|
||||
func parseEngineMessage(message: String, fromPolling: Bool)
|
||||
func write(msg: String, withType type: SocketEnginePacketType, withData data: [NSData])
|
||||
}
|
||||
|
||||
extension SocketEngineSpec {
|
||||
var urlPollingWithSid: NSURL {
|
||||
let com = NSURLComponents(URL: urlPolling, resolvingAgainstBaseURL: false)!
|
||||
com.query = com.query! + "&sid=\(sid)"
|
||||
|
||||
return com.URL!
|
||||
}
|
||||
|
||||
var urlWebSocketWithSid: NSURL {
|
||||
let com = NSURLComponents(URL: urlWebSocket, resolvingAgainstBaseURL: false)!
|
||||
com.query = com.query! + (sid == "" ? "" : "&sid=\(sid)")
|
||||
|
||||
return com.URL!
|
||||
}
|
||||
|
||||
func createBinaryDataForSend(data: NSData) -> Either<NSData, String> {
|
||||
if websocket {
|
||||
var byteArray = [UInt8](count: 1, repeatedValue: 0x4)
|
||||
let mutData = NSMutableData(bytes: &byteArray, length: 1)
|
||||
|
||||
mutData.appendData(data)
|
||||
|
||||
return .Left(mutData)
|
||||
} else {
|
||||
let str = "b4" + data.base64EncodedStringWithOptions(.Encoding64CharacterLineLength)
|
||||
|
||||
return .Right(str)
|
||||
}
|
||||
}
|
||||
|
||||
/// Send an engine message (4)
|
||||
func send(msg: String, withData datas: [NSData]) {
|
||||
write(msg, withType: .Message, withData: datas)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// SocketEngineWebsocket.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Created by Erik Little on 1/15/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
|
||||
|
||||
/// Protocol that is used to implement socket.io WebSocket support
|
||||
public protocol SocketEngineWebsocket: SocketEngineSpec, WebSocketDelegate {
|
||||
var ws: WebSocket? { get }
|
||||
|
||||
func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType, withData datas: [NSData])
|
||||
}
|
||||
|
||||
// WebSocket methods
|
||||
extension SocketEngineWebsocket {
|
||||
func probeWebSocket() {
|
||||
if ws?.isConnected ?? false {
|
||||
sendWebSocketMessage("probe", withType: .Ping, withData: [])
|
||||
}
|
||||
}
|
||||
|
||||
/// Send message on WebSockets
|
||||
/// Only call on emitQueue
|
||||
public func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType, withData datas: [NSData]) {
|
||||
DefaultSocketLogger.Logger.log("Sending ws: %@ as type: %@", type: "SocketEngine", args: str, type.rawValue)
|
||||
|
||||
ws?.writeString("\(type.rawValue)\(str)")
|
||||
|
||||
for data in datas {
|
||||
if case let .Left(bin) = createBinaryDataForSend(data) {
|
||||
ws?.writeData(bin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
|
||||
parseEngineMessage(text, fromPolling: false)
|
||||
}
|
||||
|
||||
public func websocketDidReceiveData(socket: WebSocket, data: NSData) {
|
||||
parseEngineData(data)
|
||||
}
|
||||
}
|
||||
+191
-193
@@ -24,12 +24,12 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
public let socketURL: String
|
||||
|
||||
public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable {
|
||||
public let socketURL: NSURL
|
||||
|
||||
public private(set) var engine: SocketEngineSpec?
|
||||
public private(set) var status = SocketIOClientStatus.NotConnected
|
||||
|
||||
|
||||
public var forceNew = false
|
||||
public var nsp = "/"
|
||||
public var options: Set<SocketIOClientOption>
|
||||
@@ -38,216 +38,214 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
public var sid: String? {
|
||||
return engine?.sid
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
private var anyHandler: ((SocketAnyEvent) -> Void)?
|
||||
private var currentReconnectAttempt = 0
|
||||
private var handlers = [SocketEventHandler]()
|
||||
private var connectParams: [String: AnyObject]?
|
||||
private var reconnectTimer: NSTimer?
|
||||
private var ackHandlers = SocketAckManager()
|
||||
|
||||
|
||||
private(set) var currentAck = -1
|
||||
private(set) var handleQueue = dispatch_get_main_queue()
|
||||
private(set) var reconnectAttempts = -1
|
||||
|
||||
|
||||
var waitingData = [SocketPacket]()
|
||||
|
||||
/**
|
||||
Type safe way to create a new SocketIOClient. opts can be omitted
|
||||
*/
|
||||
public init(socketURL: String, options: Set<SocketIOClientOption> = []) {
|
||||
public init(socketURL: NSURL, options: Set<SocketIOClientOption> = []) {
|
||||
self.options = options
|
||||
self.socketURL = socketURL
|
||||
|
||||
if socketURL["https://"].matches().count != 0 {
|
||||
if socketURL.absoluteString.hasPrefix("https://") {
|
||||
self.options.insertIgnore(.Secure(true))
|
||||
}
|
||||
|
||||
self.socketURL = socketURL["https?://"] ~= ""
|
||||
|
||||
for option in options ?? [] {
|
||||
for option in options {
|
||||
switch option {
|
||||
case .ConnectParams(let params):
|
||||
connectParams = params
|
||||
case .Reconnects(let reconnects):
|
||||
case let .Reconnects(reconnects):
|
||||
self.reconnects = reconnects
|
||||
case .ReconnectAttempts(let attempts):
|
||||
case let .ReconnectAttempts(attempts):
|
||||
reconnectAttempts = attempts
|
||||
case .ReconnectWait(let wait):
|
||||
case let .ReconnectWait(wait):
|
||||
reconnectWait = abs(wait)
|
||||
case .Nsp(let nsp):
|
||||
case let .Nsp(nsp):
|
||||
self.nsp = nsp
|
||||
case .Log(let log):
|
||||
case let .Log(log):
|
||||
DefaultSocketLogger.Logger.log = log
|
||||
case .Logger(let logger):
|
||||
case let .Logger(logger):
|
||||
DefaultSocketLogger.Logger = logger
|
||||
case .HandleQueue(let queue):
|
||||
case let .HandleQueue(queue):
|
||||
handleQueue = queue
|
||||
case .ForceNew(let force):
|
||||
case let .ForceNew(force):
|
||||
forceNew = force
|
||||
default:
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
self.options.insertIgnore(.Path("/socket.io"))
|
||||
self.options.insertIgnore(.Path("/socket.io/"))
|
||||
|
||||
super.init()
|
||||
}
|
||||
|
||||
/**
|
||||
Not so type safe way to create a SocketIOClient, meant for Objective-C compatiblity.
|
||||
If using Swift it's recommended to use `init(var socketURL: String, opts: SocketOptionsDictionary? = nil)`
|
||||
If using Swift it's recommended to use `init(socketURL: NSURL, options: Set<SocketIOClientOption>)`
|
||||
*/
|
||||
public convenience init(socketURL: String, options: NSDictionary?) {
|
||||
self.init(socketURL: socketURL,
|
||||
options: Set<SocketIOClientOption>.NSDictionaryToSocketOptionsSet(options ?? [:]))
|
||||
public convenience init(socketURL: NSURL, options: NSDictionary?) {
|
||||
self.init(socketURL: socketURL, options: options?.toSocketOptionsSet() ?? [])
|
||||
}
|
||||
|
||||
/// Please use the NSURL based init
|
||||
@available(*, deprecated=5.3)
|
||||
public convenience init(socketURLString: String, options: Set<SocketIOClientOption> = []) {
|
||||
guard let url = NSURL(string: socketURLString) else { fatalError("Incorrect url") }
|
||||
self.init(socketURL: url, options: options)
|
||||
}
|
||||
|
||||
/// Please use the NSURL based init
|
||||
@available(*, deprecated=5.3)
|
||||
public convenience init(socketURLString: String, options: NSDictionary?) {
|
||||
guard let url = NSURL(string: socketURLString) else { fatalError("Incorrect url") }
|
||||
self.init(socketURL: url, options: options?.toSocketOptionsSet() ?? [])
|
||||
}
|
||||
|
||||
deinit {
|
||||
DefaultSocketLogger.Logger.log("Client is being deinit", type: logType)
|
||||
engine?.close()
|
||||
DefaultSocketLogger.Logger.log("Client is being released", type: logType)
|
||||
engine?.close("Client Deinit")
|
||||
}
|
||||
|
||||
private func addEngine() -> SocketEngine {
|
||||
|
||||
private func addEngine() -> SocketEngineSpec {
|
||||
DefaultSocketLogger.Logger.log("Adding engine", type: logType)
|
||||
|
||||
let newEngine = SocketEngine(client: self, url: socketURL, options: options ?? [])
|
||||
|
||||
engine = newEngine
|
||||
return newEngine
|
||||
|
||||
engine = SocketEngine(client: self, url: socketURL, options: options)
|
||||
|
||||
return engine!
|
||||
}
|
||||
|
||||
|
||||
private func clearReconnectTimer() {
|
||||
reconnectTimer?.invalidate()
|
||||
reconnectTimer = nil
|
||||
}
|
||||
|
||||
/**
|
||||
Closes the socket. Only reopen the same socket if you know what you're doing.
|
||||
Will turn off automatic reconnects.
|
||||
Pass true to fast if you're closing from a background task
|
||||
*/
|
||||
|
||||
@available(*, deprecated=5.3)
|
||||
public func close() {
|
||||
DefaultSocketLogger.Logger.log("Closing socket", type: logType)
|
||||
|
||||
reconnects = false
|
||||
didDisconnect("Closed")
|
||||
disconnect()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Connect to the server.
|
||||
*/
|
||||
public func connect() {
|
||||
connect(timeoutAfter: 0, withTimeoutHandler: nil)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Connect to the server. If we aren't connected after timeoutAfter, call handler
|
||||
*/
|
||||
public func connect(timeoutAfter timeoutAfter: Int,
|
||||
withTimeoutHandler handler: (() -> Void)?) {
|
||||
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
|
||||
|
||||
guard status != .Connected else {
|
||||
DefaultSocketLogger.Logger.log("Tried connecting on an already connected socket",
|
||||
type: logType)
|
||||
return
|
||||
}
|
||||
|
||||
status = .Connecting
|
||||
|
||||
if engine == nil || forceNew {
|
||||
addEngine().open(connectParams)
|
||||
} else {
|
||||
engine?.open(connectParams)
|
||||
}
|
||||
|
||||
guard timeoutAfter != 0 else { return }
|
||||
|
||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
|
||||
|
||||
dispatch_after(time, handleQueue) {[weak self] in
|
||||
if let this = self where this.status != .Connected {
|
||||
this.status = .Closed
|
||||
this.engine?.close()
|
||||
|
||||
handler?()
|
||||
}
|
||||
public func connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?) {
|
||||
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
|
||||
|
||||
guard status != .Connected else {
|
||||
DefaultSocketLogger.Logger.log("Tried connecting on an already connected socket",
|
||||
type: logType)
|
||||
return
|
||||
}
|
||||
|
||||
status = .Connecting
|
||||
|
||||
if engine == nil || forceNew {
|
||||
addEngine().open()
|
||||
} else {
|
||||
engine?.open()
|
||||
}
|
||||
|
||||
guard timeoutAfter != 0 else { return }
|
||||
|
||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
|
||||
|
||||
dispatch_after(time, handleQueue) {[weak self] in
|
||||
if let this = self where this.status != .Connected {
|
||||
this.status = .Closed
|
||||
this.engine?.close("Connect timeout")
|
||||
|
||||
handler?()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private func createOnAck(items: [AnyObject]) -> OnAckCallback {
|
||||
return {[weak self, ack = ++currentAck] timeout, callback in
|
||||
currentAck += 1
|
||||
|
||||
return {[weak self, ack = currentAck] timeout, callback in
|
||||
if let this = self {
|
||||
this.ackHandlers.addAck(ack, callback: callback)
|
||||
|
||||
|
||||
dispatch_async(this.emitQueue) {
|
||||
this._emit(items, ack: ack)
|
||||
}
|
||||
|
||||
|
||||
if timeout != 0 {
|
||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
||||
|
||||
dispatch_after(time, dispatch_get_main_queue()) {
|
||||
|
||||
dispatch_after(time, this.handleQueue) {
|
||||
this.ackHandlers.timeoutAck(ack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func didConnect() {
|
||||
DefaultSocketLogger.Logger.log("Socket connected", type: logType)
|
||||
status = .Connected
|
||||
currentReconnectAttempt = 0
|
||||
clearReconnectTimer()
|
||||
|
||||
|
||||
// Don't handle as internal because something crazy could happen where
|
||||
// we disconnect before it's handled
|
||||
handleEvent("connect", data: [], isInternalMessage: false)
|
||||
}
|
||||
|
||||
|
||||
func didDisconnect(reason: String) {
|
||||
guard status != .Closed else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
DefaultSocketLogger.Logger.log("Disconnected: %@", type: logType, args: reason)
|
||||
|
||||
|
||||
status = .Closed
|
||||
reconnects = false
|
||||
|
||||
|
||||
// Make sure the engine is actually dead.
|
||||
engine?.close()
|
||||
engine?.close(reason)
|
||||
handleEvent("disconnect", data: [reason], isInternalMessage: true)
|
||||
}
|
||||
|
||||
/// error
|
||||
public func didError(reason: AnyObject) {
|
||||
DefaultSocketLogger.Logger.error("%@", type: logType, args: reason)
|
||||
|
||||
handleEvent("error", data: reason as? [AnyObject] ?? [reason],
|
||||
isInternalMessage: true)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Same as close
|
||||
Disconnects the socket. Only reconnect the same socket if you know what you're doing.
|
||||
Will turn off automatic reconnects.
|
||||
*/
|
||||
public func disconnect() {
|
||||
close()
|
||||
DefaultSocketLogger.Logger.log("Closing socket", type: logType)
|
||||
|
||||
reconnects = false
|
||||
didDisconnect("Disconnect")
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Send a message to the server
|
||||
*/
|
||||
public func emit(event: String, _ items: AnyObject...) {
|
||||
emit(event, withItems: items)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Same as emit, but meant for Objective-C
|
||||
*/
|
||||
@@ -256,12 +254,12 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
handleEvent("error", data: ["Tried emitting \(event) when not connected"], isInternalMessage: true)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
dispatch_async(emitQueue) {
|
||||
self._emit([event] + items)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Sends a message to the server, requesting an ack. Use the onAck method of SocketAckHandler to add
|
||||
an ack.
|
||||
@@ -269,45 +267,45 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
public func emitWithAck(event: String, _ items: AnyObject...) -> OnAckCallback {
|
||||
return emitWithAck(event, withItems: items)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Same as emitWithAck, but for Objective-C
|
||||
*/
|
||||
public func emitWithAck(event: String, withItems items: [AnyObject]) -> OnAckCallback {
|
||||
return createOnAck([event] + items)
|
||||
}
|
||||
|
||||
|
||||
private func _emit(data: [AnyObject], ack: Int? = nil) {
|
||||
guard status == .Connected else {
|
||||
handleEvent("error", data: ["Tried emitting when not connected"], isInternalMessage: true)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let packet = SocketPacket.packetFromEmit(data, id: ack ?? -1, nsp: nsp, ack: false)
|
||||
let str = packet.packetString
|
||||
|
||||
|
||||
DefaultSocketLogger.Logger.log("Emitting: %@", type: logType, args: str)
|
||||
|
||||
|
||||
engine?.send(str, withData: packet.binary)
|
||||
}
|
||||
|
||||
|
||||
// If the server wants to know that the client received data
|
||||
func emitAck(ack: Int, withItems items: [AnyObject]) {
|
||||
dispatch_async(emitQueue) {
|
||||
if self.status == .Connected {
|
||||
let packet = SocketPacket.packetFromEmit(items, id: ack ?? -1, nsp: self.nsp, ack: true)
|
||||
let str = packet.packetString
|
||||
|
||||
|
||||
DefaultSocketLogger.Logger.log("Emitting Ack: %@", type: self.logType, args: str)
|
||||
|
||||
|
||||
self.engine?.send(str, withData: packet.binary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public func engineDidClose(reason: String) {
|
||||
waitingData.removeAll()
|
||||
|
||||
|
||||
if status == .Closed || !reconnects {
|
||||
didDisconnect(reason)
|
||||
} else if status != .Reconnecting {
|
||||
@@ -316,38 +314,42 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
tryReconnect()
|
||||
}
|
||||
}
|
||||
|
||||
// Called when the socket gets an ack for something it sent
|
||||
func handleAck(ack: Int, data: AnyObject?) {
|
||||
guard status == .Connected else {return}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "")
|
||||
|
||||
ackHandlers.executeAck(ack,
|
||||
items: (data as? [AnyObject]) ?? (data != nil ? [data!] : []))
|
||||
|
||||
/// error
|
||||
public func engineDidError(reason: String) {
|
||||
DefaultSocketLogger.Logger.error("%@", type: logType, args: reason)
|
||||
|
||||
handleEvent("error", data: [reason], isInternalMessage: true)
|
||||
}
|
||||
|
||||
|
||||
// Called when the socket gets an ack for something it sent
|
||||
func handleAck(ack: Int, data: [AnyObject]) {
|
||||
guard status == .Connected else {return}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "")
|
||||
|
||||
ackHandlers.executeAck(ack, items: data)
|
||||
}
|
||||
|
||||
/**
|
||||
Causes an event to be handled. Only use if you know what you're doing.
|
||||
*/
|
||||
public func handleEvent(event: String, data: [AnyObject], isInternalMessage: Bool,
|
||||
withAck ack: Int = -1) {
|
||||
guard status == .Connected || isInternalMessage else {
|
||||
return
|
||||
public func handleEvent(event: String, data: [AnyObject], isInternalMessage: Bool, withAck ack: Int = -1) {
|
||||
guard status == .Connected || isInternalMessage else {
|
||||
return
|
||||
}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Handling event: %@ with data: %@", type: logType, args: event, data ?? "")
|
||||
|
||||
dispatch_async(handleQueue) {
|
||||
self.anyHandler?(SocketAnyEvent(event: event, items: data))
|
||||
|
||||
for handler in self.handlers where handler.event == event {
|
||||
handler.executeCallback(data, withAck: ack, withSocket: self)
|
||||
}
|
||||
|
||||
DefaultSocketLogger.Logger.log("Handling event: %@ with data: %@", type: logType, args: event, data ?? "")
|
||||
|
||||
dispatch_async(handleQueue) {
|
||||
self.anyHandler?(SocketAnyEvent(event: event, items: data))
|
||||
|
||||
for handler in self.handlers where handler.event == event {
|
||||
handler.executeCallback(data, withAck: ack, withSocket: self)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Leaves nsp and goes back to /
|
||||
*/
|
||||
@@ -357,110 +359,106 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
nsp = "/"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Joins nsp if it is not /
|
||||
Joins namespace
|
||||
*/
|
||||
public func joinNamespace() {
|
||||
DefaultSocketLogger.Logger.log("Joining namespace", type: logType)
|
||||
|
||||
public func joinNamespace(namespace: String) {
|
||||
nsp = namespace
|
||||
|
||||
if nsp != "/" {
|
||||
DefaultSocketLogger.Logger.log("Joining namespace", type: logType)
|
||||
engine?.send("0\(nsp)", withData: [])
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Joins namespace /
|
||||
*/
|
||||
public func joinNamespace(namespace: String) {
|
||||
self.nsp = namespace
|
||||
joinNamespace()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Removes handler(s)
|
||||
*/
|
||||
public func off(event: String) {
|
||||
DefaultSocketLogger.Logger.log("Removing handler for event: %@", type: logType, args: event)
|
||||
|
||||
|
||||
handlers = handlers.filter { $0.event != event }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Removes a handler with the specified UUID gotten from an `on` or `once`
|
||||
*/
|
||||
public func off(id id: NSUUID) {
|
||||
DefaultSocketLogger.Logger.log("Removing handler with id: %@", type: logType, args: id)
|
||||
|
||||
|
||||
handlers = handlers.filter { $0.id != id }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Adds a handler for an event.
|
||||
Returns: A unique id for the handler
|
||||
*/
|
||||
public func on(event: String, callback: NormalCallback) -> NSUUID {
|
||||
DefaultSocketLogger.Logger.log("Adding handler for event: %@", type: logType, args: event)
|
||||
|
||||
|
||||
let handler = SocketEventHandler(event: event, id: NSUUID(), callback: callback)
|
||||
handlers.append(handler)
|
||||
|
||||
|
||||
return handler.id
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Adds a single-use handler for an event.
|
||||
Returns: A unique id for the handler
|
||||
*/
|
||||
public func once(event: String, callback: NormalCallback) -> NSUUID {
|
||||
DefaultSocketLogger.Logger.log("Adding once handler for event: %@", type: logType, args: event)
|
||||
|
||||
|
||||
let id = NSUUID()
|
||||
|
||||
|
||||
let handler = SocketEventHandler(event: event, id: id) {[weak self] data, ack in
|
||||
guard let this = self else {return}
|
||||
guard let this = self else { return }
|
||||
this.off(id: id)
|
||||
callback(data, ack)
|
||||
}
|
||||
|
||||
|
||||
handlers.append(handler)
|
||||
|
||||
|
||||
return handler.id
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Adds a handler that will be called on every event.
|
||||
*/
|
||||
public func onAny(handler: (SocketAnyEvent) -> Void) {
|
||||
anyHandler = handler
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Same as connect
|
||||
*/
|
||||
@available(*, deprecated=5.3)
|
||||
public func open() {
|
||||
connect()
|
||||
}
|
||||
|
||||
public func parseSocketMessage(msg: String) {
|
||||
|
||||
public func parseEngineMessage(msg: String) {
|
||||
DefaultSocketLogger.Logger.log("Should parse message: %@", type: "SocketIOClient", args: msg)
|
||||
|
||||
dispatch_async(parseQueue) {
|
||||
SocketParser.parseSocketMessage(msg, socket: self)
|
||||
self.parseSocketMessage(msg)
|
||||
}
|
||||
}
|
||||
|
||||
public func parseBinaryData(data: NSData) {
|
||||
|
||||
public func parseEngineBinaryData(data: NSData) {
|
||||
dispatch_async(parseQueue) {
|
||||
SocketParser.parseBinaryData(data, socket: self)
|
||||
self.parseBinaryData(data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Tries to reconnect to the server.
|
||||
*/
|
||||
public func reconnect() {
|
||||
tryReconnect()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Removes all handlers.
|
||||
Can be used after disconnecting to break any potential remaining retain cycles.
|
||||
@@ -468,39 +466,39 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||
public func removeAllHandlers() {
|
||||
handlers.removeAll(keepCapacity: false)
|
||||
}
|
||||
|
||||
|
||||
private func tryReconnect() {
|
||||
if reconnectTimer == nil {
|
||||
DefaultSocketLogger.Logger.log("Starting reconnect", type: logType)
|
||||
|
||||
|
||||
status = .Reconnecting
|
||||
|
||||
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
self.reconnectTimer = NSTimer.scheduledTimerWithTimeInterval(Double(self.reconnectWait),
|
||||
target: self, selector: "_tryReconnect", userInfo: nil, repeats: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@objc private func _tryReconnect() {
|
||||
if status == .Connected {
|
||||
clearReconnectTimer()
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if reconnectAttempts != -1 && currentReconnectAttempt + 1 > reconnectAttempts || !reconnects {
|
||||
clearReconnectTimer()
|
||||
didDisconnect("Reconnect Failed")
|
||||
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
DefaultSocketLogger.Logger.log("Trying to reconnect", type: logType)
|
||||
handleEvent("reconnectAttempt", data: [reconnectAttempts - currentReconnectAttempt],
|
||||
isInternalMessage: true)
|
||||
|
||||
currentReconnectAttempt++
|
||||
|
||||
currentReconnectAttempt += 1
|
||||
connect()
|
||||
}
|
||||
}
|
||||
@@ -510,15 +508,15 @@ extension SocketIOClient {
|
||||
var testHandlers: [SocketEventHandler] {
|
||||
return handlers
|
||||
}
|
||||
|
||||
|
||||
func setTestable() {
|
||||
status = .Connected
|
||||
}
|
||||
|
||||
|
||||
func setTestEngine(engine: SocketEngineSpec?) {
|
||||
self.engine = engine
|
||||
}
|
||||
|
||||
|
||||
func emitTest(event: String, _ data: AnyObject...) {
|
||||
self._emit([event] + data)
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
import Foundation
|
||||
|
||||
protocol ClientOption: CustomStringConvertible, Hashable {
|
||||
func getSocketIOOptionValue() -> AnyObject?
|
||||
func getSocketIOOptionValue() -> AnyObject
|
||||
}
|
||||
|
||||
public enum SocketIOClientOption: ClientOption {
|
||||
@@ -49,62 +49,97 @@ public enum SocketIOClientOption: ClientOption {
|
||||
case VoipEnabled(Bool)
|
||||
|
||||
public var description: String {
|
||||
if let label = Mirror(reflecting: self).children.first?.label {
|
||||
return String(label[label.startIndex]).lowercaseString + String(label.characters.dropFirst())
|
||||
} else {
|
||||
return ""
|
||||
let description: String
|
||||
|
||||
switch self {
|
||||
case .ConnectParams:
|
||||
description = "connectParams"
|
||||
case .Cookies:
|
||||
description = "cookies"
|
||||
case .ExtraHeaders:
|
||||
description = "extraHeaders"
|
||||
case .ForceNew:
|
||||
description = "forceNew"
|
||||
case .ForcePolling:
|
||||
description = "forcePolling"
|
||||
case .ForceWebsockets:
|
||||
description = "forceWebsockets"
|
||||
case .HandleQueue:
|
||||
description = "handleQueue"
|
||||
case .Log:
|
||||
description = "log"
|
||||
case .Logger:
|
||||
description = "logger"
|
||||
case .Nsp:
|
||||
description = "nsp"
|
||||
case .Path:
|
||||
description = "path"
|
||||
case .Reconnects:
|
||||
description = "reconnects"
|
||||
case .ReconnectAttempts:
|
||||
description = "reconnectAttempts"
|
||||
case .ReconnectWait:
|
||||
description = "reconnectWait"
|
||||
case .Secure:
|
||||
description = "secure"
|
||||
case .SelfSigned:
|
||||
description = "selfSigned"
|
||||
case .SessionDelegate:
|
||||
description = "sessionDelegate"
|
||||
case .VoipEnabled:
|
||||
description = "voipEnabled"
|
||||
}
|
||||
|
||||
return description
|
||||
}
|
||||
|
||||
public var hashValue: Int {
|
||||
return description.hashValue
|
||||
}
|
||||
|
||||
static func keyValueToSocketIOClientOption(key: String, value: AnyObject) -> SocketIOClientOption? {
|
||||
switch (key, value) {
|
||||
case ("connectParams", let params as [String: AnyObject]):
|
||||
return .ConnectParams(params)
|
||||
case ("reconnects", let reconnects as Bool):
|
||||
return .Reconnects(reconnects)
|
||||
case ("reconnectAttempts", let attempts as Int):
|
||||
return .ReconnectAttempts(attempts)
|
||||
case ("reconnectWait", let wait as Int):
|
||||
return .ReconnectWait(wait)
|
||||
case ("forceNew", let force as Bool):
|
||||
return .ForceNew(force)
|
||||
case ("forcePolling", let force as Bool):
|
||||
return .ForcePolling(force)
|
||||
case ("forceWebsockets", let force as Bool):
|
||||
return .ForceWebsockets(force)
|
||||
case ("nsp", let nsp as String):
|
||||
return .Nsp(nsp)
|
||||
case ("cookies", let cookies as [NSHTTPCookie]):
|
||||
return .Cookies(cookies)
|
||||
case ("log", let log as Bool):
|
||||
return .Log(log)
|
||||
case ("logger", let logger as SocketLogger):
|
||||
return .Logger(logger)
|
||||
case ("sessionDelegate", let delegate as NSURLSessionDelegate):
|
||||
return .SessionDelegate(delegate)
|
||||
case ("path", let path as String):
|
||||
return .Path(path)
|
||||
case ("extraHeaders", let headers as [String: String]):
|
||||
return .ExtraHeaders(headers)
|
||||
case ("handleQueue", let queue as dispatch_queue_t):
|
||||
return .HandleQueue(queue)
|
||||
case ("voipEnabled", let enable as Bool):
|
||||
return .VoipEnabled(enable)
|
||||
case ("secure", let secure as Bool):
|
||||
return .Secure(secure)
|
||||
case ("selfSigned", let selfSigned as Bool):
|
||||
return .SelfSigned(selfSigned)
|
||||
default:
|
||||
return nil
|
||||
func getSocketIOOptionValue() -> AnyObject {
|
||||
let value: AnyObject
|
||||
|
||||
switch self {
|
||||
case let .ConnectParams(params):
|
||||
value = params
|
||||
case let .Cookies(cookies):
|
||||
value = cookies
|
||||
case let .ExtraHeaders(headers):
|
||||
value = headers
|
||||
case let .ForceNew(force):
|
||||
value = force
|
||||
case let .ForcePolling(force):
|
||||
value = force
|
||||
case let .ForceWebsockets(force):
|
||||
value = force
|
||||
case let .HandleQueue(queue):
|
||||
value = queue
|
||||
case let .Log(log):
|
||||
value = log
|
||||
case let .Logger(logger):
|
||||
value = logger
|
||||
case let .Nsp(nsp):
|
||||
value = nsp
|
||||
case let .Path(path):
|
||||
value = path
|
||||
case let .Reconnects(reconnects):
|
||||
value = reconnects
|
||||
case let .ReconnectAttempts(attempts):
|
||||
value = attempts
|
||||
case let .ReconnectWait(wait):
|
||||
value = wait
|
||||
case let .Secure(secure):
|
||||
value = secure
|
||||
case let .SelfSigned(signed):
|
||||
value = signed
|
||||
case let .SessionDelegate(delegate):
|
||||
value = delegate
|
||||
case let .VoipEnabled(enabled):
|
||||
value = enabled
|
||||
}
|
||||
}
|
||||
|
||||
func getSocketIOOptionValue() -> AnyObject? {
|
||||
return Mirror(reflecting: self).children.first?.value as? AnyObject
|
||||
|
||||
return value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,26 +153,61 @@ extension Set where Element: ClientOption {
|
||||
insert(element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension NSDictionary {
|
||||
static func keyValueToSocketIOClientOption(key: String, value: AnyObject) -> SocketIOClientOption? {
|
||||
switch (key, value) {
|
||||
case let ("connectParams", params as [String: AnyObject]):
|
||||
return .ConnectParams(params)
|
||||
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 ("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 ("nsp", nsp as String):
|
||||
return .Nsp(nsp)
|
||||
case let ("cookies", cookies as [NSHTTPCookie]):
|
||||
return .Cookies(cookies)
|
||||
case let ("log", log as Bool):
|
||||
return .Log(log)
|
||||
case let ("logger", logger as SocketLogger):
|
||||
return .Logger(logger)
|
||||
case let ("sessionDelegate", delegate as NSURLSessionDelegate):
|
||||
return .SessionDelegate(delegate)
|
||||
case let ("path", path as String):
|
||||
return .Path(path)
|
||||
case let ("extraHeaders", headers as [String: String]):
|
||||
return .ExtraHeaders(headers)
|
||||
case let ("handleQueue", queue as dispatch_queue_t):
|
||||
return .HandleQueue(queue)
|
||||
case let ("voipEnabled", enable as Bool):
|
||||
return .VoipEnabled(enable)
|
||||
case let ("secure", secure as Bool):
|
||||
return .Secure(secure)
|
||||
case let ("selfSigned", selfSigned as Bool):
|
||||
return .SelfSigned(selfSigned)
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
static func NSDictionaryToSocketOptionsSet(dict: NSDictionary) -> Set<SocketIOClientOption> {
|
||||
func toSocketOptionsSet() -> Set<SocketIOClientOption> {
|
||||
var options = Set<SocketIOClientOption>()
|
||||
|
||||
for (rawKey, value) in dict {
|
||||
if let key = rawKey as? String, opt = SocketIOClientOption.keyValueToSocketIOClientOption(key, value: value) {
|
||||
for (rawKey, value) in self {
|
||||
if let key = rawKey as? String, opt = NSDictionary.keyValueToSocketIOClientOption(key, value: value) {
|
||||
options.insertIgnore(opt)
|
||||
}
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
func SocketOptionsSetToNSDictionary() -> NSDictionary {
|
||||
let options = NSMutableDictionary()
|
||||
|
||||
for option in self {
|
||||
options[option.description] = option.getSocketIOOptionValue()
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public protocol SocketLogger: class {
|
||||
|
||||
public extension SocketLogger {
|
||||
func log(message: String, type: String, args: AnyObject...) {
|
||||
abstractLog("Log", message: message, type: type, args: args)
|
||||
abstractLog("LOG", message: message, type: type, args: args)
|
||||
}
|
||||
|
||||
func error(message: String, type: String, args: AnyObject...) {
|
||||
@@ -47,7 +47,7 @@ public extension SocketLogger {
|
||||
private func abstractLog(logType: String, message: String, type: String, args: [AnyObject]) {
|
||||
guard log else { return }
|
||||
|
||||
let newArgs = args.map {arg -> CVarArgType in String(arg)}
|
||||
let newArgs = args.map({arg -> CVarArgType in String(arg)})
|
||||
let replaced = String(format: message, arguments: newArgs)
|
||||
|
||||
NSLog("%@ %@: %@", logType, type, replaced)
|
||||
|
||||
+60
-75
@@ -27,7 +27,6 @@ import Foundation
|
||||
|
||||
struct SocketPacket {
|
||||
private let placeholders: Int
|
||||
private var currentPlace = 0
|
||||
|
||||
private static let logType = "SocketPacket"
|
||||
|
||||
@@ -39,18 +38,11 @@ struct SocketPacket {
|
||||
case Connect, Disconnect, Event, Ack, Error, BinaryEvent, BinaryAck
|
||||
}
|
||||
|
||||
var args: [AnyObject]? {
|
||||
var arr = data
|
||||
|
||||
if data.count == 0 {
|
||||
return nil
|
||||
var args: [AnyObject] {
|
||||
if type == .Event || type == .BinaryEvent && data.count != 0 {
|
||||
return Array(data.dropFirst())
|
||||
} else {
|
||||
if type == .Event || type == .BinaryEvent {
|
||||
arr.removeAtIndex(0)
|
||||
return arr
|
||||
} else {
|
||||
return arr
|
||||
}
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +54,7 @@ struct SocketPacket {
|
||||
}
|
||||
|
||||
var event: String {
|
||||
return data[0] as? String ?? String(data[0])
|
||||
return String(data[0])
|
||||
}
|
||||
|
||||
var packetString: String {
|
||||
@@ -80,15 +72,14 @@ struct SocketPacket {
|
||||
}
|
||||
|
||||
mutating func addData(data: NSData) -> Bool {
|
||||
if placeholders == currentPlace {
|
||||
if placeholders == binary.count {
|
||||
return true
|
||||
}
|
||||
|
||||
binary.append(data)
|
||||
currentPlace++
|
||||
|
||||
if placeholders == currentPlace {
|
||||
currentPlace = 0
|
||||
if placeholders == binary.count {
|
||||
fillInPlaceholders()
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@@ -107,15 +98,15 @@ struct SocketPacket {
|
||||
do {
|
||||
let jsonSend = try NSJSONSerialization.dataWithJSONObject(arg,
|
||||
options: NSJSONWritingOptions(rawValue: 0))
|
||||
let jsonString = NSString(data: jsonSend, encoding: NSUTF8StringEncoding)
|
||||
let jsonString = String(data: jsonSend, encoding: NSUTF8StringEncoding)
|
||||
|
||||
restOfMessage += jsonString! as String + ","
|
||||
restOfMessage += jsonString! + ","
|
||||
} catch {
|
||||
DefaultSocketLogger.Logger.error("Error creating JSON object in SocketPacket.completeMessage",
|
||||
type: SocketPacket.logType)
|
||||
}
|
||||
} else if let str = arg as? String {
|
||||
restOfMessage += "\"" + ((str["\n"] ~= "\\\\n")["\r"] ~= "\\\\r") + "\","
|
||||
restOfMessage += "\"" + ((str["\n"] <~ "\\\\n")["\r"] <~ "\\\\r") + "\","
|
||||
} else if arg is NSNull {
|
||||
restOfMessage += "null,"
|
||||
} else {
|
||||
@@ -131,30 +122,30 @@ struct SocketPacket {
|
||||
}
|
||||
|
||||
private func createAck() -> String {
|
||||
let msg: String
|
||||
let message: String
|
||||
|
||||
if type == PacketType.Ack {
|
||||
if type == .Ack {
|
||||
if nsp == "/" {
|
||||
msg = "3\(id)["
|
||||
message = "3\(id)["
|
||||
} else {
|
||||
msg = "3\(nsp),\(id)["
|
||||
message = "3\(nsp),\(id)["
|
||||
}
|
||||
} else {
|
||||
if nsp == "/" {
|
||||
msg = "6\(binary.count)-\(id)["
|
||||
message = "6\(binary.count)-\(id)["
|
||||
} else {
|
||||
msg = "6\(binary.count)-\(nsp),\(id)["
|
||||
message = "6\(binary.count)-\(nsp),\(id)["
|
||||
}
|
||||
}
|
||||
|
||||
return completeMessage(msg, ack: true)
|
||||
return completeMessage(message, ack: true)
|
||||
}
|
||||
|
||||
|
||||
private func createMessageForEvent() -> String {
|
||||
let message: String
|
||||
|
||||
if type == PacketType.Event {
|
||||
if type == .Event {
|
||||
if nsp == "/" {
|
||||
if id == -1 {
|
||||
message = "2["
|
||||
@@ -199,36 +190,30 @@ struct SocketPacket {
|
||||
return str
|
||||
}
|
||||
|
||||
mutating func fillInPlaceholders() {
|
||||
for i in 0..<data.count {
|
||||
if let str = data[i] as? String, num = str["~~(\\d)"].groups() {
|
||||
// Fill in binary placeholder with data
|
||||
data[i] = binary[Int(num[1])!]
|
||||
} else if data[i] is NSDictionary || data[i] is NSArray {
|
||||
data[i] = _fillInPlaceholders(data[i])
|
||||
}
|
||||
}
|
||||
// Called when we have all the binary data for a packet
|
||||
// calls _fillInPlaceholders, which replaces placeholders with the
|
||||
// corresponding binary
|
||||
private mutating func fillInPlaceholders() {
|
||||
data = data.map(_fillInPlaceholders)
|
||||
}
|
||||
|
||||
private mutating func _fillInPlaceholders(data: AnyObject) -> AnyObject {
|
||||
if let str = data as? String {
|
||||
if let num = str["~~(\\d)"].groups() {
|
||||
return binary[Int(num[1])!]
|
||||
} else {
|
||||
return str
|
||||
}
|
||||
} else if let dict = data as? NSDictionary {
|
||||
let newDict = NSMutableDictionary(dictionary: dict)
|
||||
|
||||
for (key, value) in dict {
|
||||
newDict[key as! NSCopying] = _fillInPlaceholders(value)
|
||||
}
|
||||
|
||||
return newDict
|
||||
} else if let arr = data as? [AnyObject] {
|
||||
return arr.map({_fillInPlaceholders($0)})
|
||||
} else {
|
||||
return data
|
||||
// Helper method that looks for placeholder strings
|
||||
// If object is a collection it will recurse
|
||||
// Returns the object if it is not a placeholder string or the corresponding
|
||||
// binary data
|
||||
private func _fillInPlaceholders(object: AnyObject) -> AnyObject {
|
||||
switch object {
|
||||
case let string as String where string["~~(\\d)"].groups() != nil:
|
||||
return binary[Int(string["~~(\\d)"].groups()![1])!]
|
||||
case let dict as NSDictionary:
|
||||
return dict.reduce(NSMutableDictionary(), combine: {cur, keyValue in
|
||||
cur[keyValue.0 as! NSCopying] = _fillInPlaceholders(keyValue.1)
|
||||
return cur
|
||||
})
|
||||
case let arr as [AnyObject]:
|
||||
return arr.map(_fillInPlaceholders)
|
||||
default:
|
||||
return object
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,15 +222,15 @@ extension SocketPacket {
|
||||
private static func findType(binCount: Int, ack: Bool) -> PacketType {
|
||||
switch binCount {
|
||||
case 0 where !ack:
|
||||
return PacketType.Event
|
||||
return .Event
|
||||
case 0 where ack:
|
||||
return PacketType.Ack
|
||||
return .Ack
|
||||
case _ where !ack:
|
||||
return PacketType.BinaryEvent
|
||||
return .BinaryEvent
|
||||
case _ where ack:
|
||||
return PacketType.BinaryAck
|
||||
return .BinaryAck
|
||||
default:
|
||||
return PacketType.Error
|
||||
return .Error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,28 +244,28 @@ extension SocketPacket {
|
||||
}
|
||||
|
||||
private extension SocketPacket {
|
||||
// Recursive function that looks for NSData in collections
|
||||
static func shred(data: AnyObject, inout binary: [NSData]) -> AnyObject {
|
||||
if let bin = data as? NSData {
|
||||
let placeholder = ["_placeholder": true, "num": binary.count]
|
||||
|
||||
let placeholder = ["_placeholder": true, "num": binary.count]
|
||||
|
||||
switch data {
|
||||
case let bin as NSData:
|
||||
binary.append(bin)
|
||||
|
||||
return placeholder
|
||||
} else if let arr = data as? [AnyObject] {
|
||||
case let arr as [AnyObject]:
|
||||
return arr.map({shred($0, binary: &binary)})
|
||||
} else if let dict = data as? NSDictionary {
|
||||
let mutDict = NSMutableDictionary(dictionary: dict)
|
||||
|
||||
for (key, value) in dict {
|
||||
mutDict[key as! NSCopying] = shred(value, binary: &binary)
|
||||
}
|
||||
|
||||
return mutDict
|
||||
} else {
|
||||
case let dict as NSDictionary:
|
||||
return dict.reduce(NSMutableDictionary(), combine: {cur, keyValue in
|
||||
cur[keyValue.0 as! NSCopying] = shred(keyValue.1, binary: &binary)
|
||||
return cur
|
||||
})
|
||||
default:
|
||||
return data
|
||||
}
|
||||
}
|
||||
|
||||
// Removes binary data from emit data
|
||||
// Returns a type containing the de-binaryed data and the binary
|
||||
static func deconstructData(data: [AnyObject]) -> ([AnyObject], [NSData]) {
|
||||
var binary = [NSData]()
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// SocketParser.swift
|
||||
// SocketParsable.swift
|
||||
// Socket.IO-Client-Swift
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -22,46 +22,50 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
class SocketParser {
|
||||
|
||||
private static func isCorrectNamespace(nsp: String, _ socket: SocketIOClient) -> Bool {
|
||||
return nsp == socket.nsp
|
||||
}
|
||||
protocol SocketParsable: SocketClientSpec {
|
||||
func parseBinaryData(data: NSData)
|
||||
func parseSocketMessage(message: String)
|
||||
}
|
||||
|
||||
private static func handleConnect(p: SocketPacket, socket: SocketIOClient) {
|
||||
if p.nsp == "/" && socket.nsp != "/" {
|
||||
socket.joinNamespace()
|
||||
} else if p.nsp != "/" && socket.nsp == "/" {
|
||||
socket.didConnect()
|
||||
extension SocketParsable {
|
||||
private func isCorrectNamespace(nsp: String) -> Bool {
|
||||
return nsp == self.nsp
|
||||
}
|
||||
|
||||
private func handleConnect(p: SocketPacket) {
|
||||
if p.nsp == "/" && nsp != "/" {
|
||||
joinNamespace(nsp)
|
||||
} else if p.nsp != "/" && nsp == "/" {
|
||||
didConnect()
|
||||
} else {
|
||||
socket.didConnect()
|
||||
didConnect()
|
||||
}
|
||||
}
|
||||
|
||||
private static func handlePacket(pack: SocketPacket, withSocket socket: SocketIOClient) {
|
||||
private func handlePacket(pack: SocketPacket) {
|
||||
switch pack.type {
|
||||
case .Event where isCorrectNamespace(pack.nsp, socket):
|
||||
socket.handleEvent(pack.event, data: pack.args ?? [],
|
||||
case .Event where isCorrectNamespace(pack.nsp):
|
||||
handleEvent(pack.event, data: pack.args,
|
||||
isInternalMessage: false, withAck: pack.id)
|
||||
case .Ack where isCorrectNamespace(pack.nsp, socket):
|
||||
socket.handleAck(pack.id, data: pack.data)
|
||||
case .BinaryEvent where isCorrectNamespace(pack.nsp, socket):
|
||||
socket.waitingData.append(pack)
|
||||
case .BinaryAck where isCorrectNamespace(pack.nsp, socket):
|
||||
socket.waitingData.append(pack)
|
||||
case .Ack where isCorrectNamespace(pack.nsp):
|
||||
handleAck(pack.id, data: pack.data)
|
||||
case .BinaryEvent where isCorrectNamespace(pack.nsp):
|
||||
waitingData.append(pack)
|
||||
case .BinaryAck where isCorrectNamespace(pack.nsp):
|
||||
waitingData.append(pack)
|
||||
case .Connect:
|
||||
handleConnect(pack, socket: socket)
|
||||
handleConnect(pack)
|
||||
case .Disconnect:
|
||||
socket.didDisconnect("Got Disconnect")
|
||||
didDisconnect("Got Disconnect")
|
||||
case .Error:
|
||||
socket.didError(pack.data)
|
||||
handleEvent("error", data: pack.data, isInternalMessage: true, withAck: pack.id)
|
||||
default:
|
||||
DefaultSocketLogger.Logger.log("Got invalid packet: %@", type: "SocketParser", args: pack.description)
|
||||
}
|
||||
}
|
||||
|
||||
/// Parses a messsage from the engine. Returning either a string error or a complete SocketPacket
|
||||
static func parseString(message: String) -> Either<String, SocketPacket> {
|
||||
func parseString(message: String) -> Either<String, SocketPacket> {
|
||||
var parser = SocketStringReader(message: message)
|
||||
|
||||
guard let type = SocketPacket.PacketType(rawValue: Int(parser.read(1)) ?? -1) else {
|
||||
@@ -79,7 +83,7 @@ class SocketParser {
|
||||
if let holders = Int(parser.readUntilStringOccurence("-")) {
|
||||
placeholders = holders
|
||||
} else {
|
||||
return .Left("Invalid packet")
|
||||
return .Left("Invalid packet")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,10 +112,10 @@ class SocketParser {
|
||||
}
|
||||
|
||||
let d = message[parser.currentIndex.advancedBy(1)..<message.endIndex]
|
||||
let noPlaceholders = d["(\\{\"_placeholder\":true,\"num\":(\\d*)\\})"] ~= "\"~~$2\""
|
||||
let noPlaceholders = d["(\\{\"_placeholder\":true,\"num\":(\\d*)\\})"] <~ "\"~~$2\""
|
||||
|
||||
switch parseData(noPlaceholders) {
|
||||
case .Left(let err):
|
||||
case let .Left(err):
|
||||
// If first you don't succeed, try again
|
||||
if case let .Right(data) = parseData("\([noPlaceholders as AnyObject])") {
|
||||
return .Right(SocketPacket(type: type, data: data, id: Int(idString) ?? -1,
|
||||
@@ -119,14 +123,14 @@ class SocketParser {
|
||||
} else {
|
||||
return .Left(err)
|
||||
}
|
||||
case .Right(let data):
|
||||
case let .Right(data):
|
||||
return .Right(SocketPacket(type: type, data: data, id: Int(idString) ?? -1,
|
||||
nsp: namespace ?? "/", placeholders: placeholders))
|
||||
}
|
||||
}
|
||||
|
||||
// Parses data for events
|
||||
private static func parseData(data: String) -> Either<String, [AnyObject]> {
|
||||
private func parseData(data: String) -> Either<String, [AnyObject]> {
|
||||
let stringData = data.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
|
||||
do {
|
||||
if let arr = try NSJSONSerialization.JSONObjectWithData(stringData!,
|
||||
@@ -141,39 +145,38 @@ class SocketParser {
|
||||
}
|
||||
|
||||
// Parses messages recieved
|
||||
static func parseSocketMessage(message: String, socket: SocketIOClient) {
|
||||
func parseSocketMessage(message: String) {
|
||||
guard !message.isEmpty else { return }
|
||||
|
||||
DefaultSocketLogger.Logger.log("Parsing %@", type: "SocketParser", args: message)
|
||||
|
||||
switch parseString(message) {
|
||||
case .Left(let err):
|
||||
case let .Left(err):
|
||||
DefaultSocketLogger.Logger.error("\(err): %@", type: "SocketParser", args: message)
|
||||
case .Right(let pack):
|
||||
case let .Right(pack):
|
||||
DefaultSocketLogger.Logger.log("Decoded packet as: %@", type: "SocketParser", args: pack.description)
|
||||
handlePacket(pack, withSocket: socket)
|
||||
handlePacket(pack)
|
||||
}
|
||||
}
|
||||
|
||||
static func parseBinaryData(data: NSData, socket: SocketIOClient) {
|
||||
guard !socket.waitingData.isEmpty else {
|
||||
func parseBinaryData(data: NSData) {
|
||||
guard !waitingData.isEmpty else {
|
||||
DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser")
|
||||
return
|
||||
}
|
||||
|
||||
// Should execute event?
|
||||
guard socket.waitingData[socket.waitingData.count - 1].addData(data) else {
|
||||
guard waitingData[waitingData.count - 1].addData(data) else {
|
||||
return
|
||||
}
|
||||
|
||||
var packet = socket.waitingData.removeLast()
|
||||
packet.fillInPlaceholders()
|
||||
let packet = waitingData.removeLast()
|
||||
|
||||
if packet.type != .BinaryAck {
|
||||
socket.handleEvent(packet.event, data: packet.args ?? [],
|
||||
handleEvent(packet.event, data: packet.args ?? [],
|
||||
isInternalMessage: false, withAck: packet.id)
|
||||
} else {
|
||||
socket.handleAck(packet.id, data: packet.args)
|
||||
handleAck(packet.id, data: packet.args)
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-31
@@ -13,13 +13,20 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
infix operator <~ { associativity none precedence 130 }
|
||||
|
||||
private let lock = dispatch_semaphore_create(1)
|
||||
private var swiftRegexCache = [String: NSRegularExpression]()
|
||||
|
||||
internal class SwiftRegex: NSObject, BooleanType {
|
||||
internal final class SwiftRegex: NSObject, BooleanType {
|
||||
var target:String
|
||||
var regex: NSRegularExpression
|
||||
|
||||
init(target:String, pattern:String, options:NSRegularExpressionOptions?) {
|
||||
if dispatch_semaphore_wait(lock, dispatch_time(DISPATCH_TIME_NOW, Int64(10 * NSEC_PER_MSEC))) != 0 {
|
||||
fatalError("This should never happen")
|
||||
}
|
||||
|
||||
self.target = target
|
||||
if let regex = swiftRegexCache[pattern] {
|
||||
self.regex = regex
|
||||
@@ -34,6 +41,7 @@ internal class SwiftRegex: NSObject, BooleanType {
|
||||
self.regex = NSRegularExpression()
|
||||
}
|
||||
}
|
||||
dispatch_semaphore_signal(lock)
|
||||
super.init()
|
||||
}
|
||||
|
||||
@@ -41,11 +49,11 @@ internal class SwiftRegex: NSObject, BooleanType {
|
||||
fatalError("SwiftRegex: \(message)")
|
||||
}
|
||||
|
||||
private final var targetRange: NSRange {
|
||||
private var targetRange: NSRange {
|
||||
return NSRange(location: 0,length: target.utf16.count)
|
||||
}
|
||||
|
||||
private final func substring(range: NSRange) -> String? {
|
||||
private func substring(range: NSRange) -> String? {
|
||||
if range.location != NSNotFound {
|
||||
return (target as NSString).substringWithRange(range)
|
||||
} else {
|
||||
@@ -168,36 +176,9 @@ extension String {
|
||||
}
|
||||
}
|
||||
|
||||
func ~= (left: SwiftRegex, right: String) -> String {
|
||||
func <~ (left: SwiftRegex, right: String) -> String {
|
||||
return left.substituteMatches({match, stop in
|
||||
return left.regex.replacementStringForResult( match,
|
||||
inString: left.target as String, offset: 0, template: right )
|
||||
}, options: [])
|
||||
}
|
||||
|
||||
func ~= (left: SwiftRegex, right: [String]) -> String {
|
||||
var matchNumber = 0
|
||||
return left.substituteMatches({match, stop -> String in
|
||||
|
||||
if ++matchNumber == right.count {
|
||||
stop.memory = true
|
||||
}
|
||||
|
||||
return left.regex.replacementStringForResult( match,
|
||||
inString: left.target as String, offset: 0, template: right[matchNumber-1] )
|
||||
}, options: [])
|
||||
}
|
||||
|
||||
func ~= (left: SwiftRegex, right: (String) -> String) -> String {
|
||||
// return right(left.substring(match.range))
|
||||
return left.substituteMatches(
|
||||
{match, stop -> String in
|
||||
right(left.substring(match.range)!)
|
||||
}, options: [])
|
||||
}
|
||||
|
||||
func ~= (left: SwiftRegex, right: ([String]?) -> String) -> String {
|
||||
return left.substituteMatches({match, stop -> String in
|
||||
return right(left.groupsForMatch(match))
|
||||
}, options: [])
|
||||
}
|
||||
@@ -382,6 +382,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
|
||||
inputQueue = inputQueue.filter{$0 != data}
|
||||
dequeueInput()
|
||||
}
|
||||
|
||||
///Finds the HTTP Packet in the TCP stream, by looking for the CRLF.
|
||||
private func processHTTP(buffer: UnsafePointer<UInt8>, bufferLen: Int) -> Bool {
|
||||
let CRLFBytes = [UInt8(ascii: "\r"), UInt8(ascii: "\n"), UInt8(ascii: "\r"), UInt8(ascii: "\n")]
|
||||
|
||||
Reference in new issue
Block a user