Compare commits

...
32 Commits
Author SHA1 Message Date
Erik ee5934de6a bump version 2016-01-13 12:23:30 -05:00
Erik ca67625ed3 remove redundancies 2016-01-03 14:14:42 -05:00
Erik fe02b8eff2 change socketparser into a protocol 2016-01-03 13:11:18 -05:00
Erik 0c8ff90537 change pattern matching syntax 2016-01-03 12:00:37 -05:00
Erik 5068986a50 fix socketio/socket.io-client-swift#233 2016-01-03 11:56:16 -05:00
Erik 4ed4681cc4 change visibility of connectParams 2016-01-03 11:11:58 -05:00
Erik 361cd8fc3b change some methods to use nsurlrequest 2016-01-03 10:12:02 -05:00
Erik 2916ed0f7b cache method isn't implemented 2016-01-03 10:10:41 -05:00
Erik cfa98ea42b remove ++ 2016-01-03 09:55:10 -05:00
Erik 8584b90d3c simplify namespace api 2016-01-02 17:38:19 -05:00
Erik 7acce7d18e small tweaks 2015-12-30 20:14:31 -05:00
Erik 0ebe56d780 remove anonymous function and use named function 2015-12-26 17:22:03 -05:00
Erik 3d8867136d comment some socketpacket methods 2015-12-26 13:38:59 -05:00
Erik bed5ecd23b more pattern matching 2015-12-26 13:18:07 -05:00
Erik 4e5fcff258 use pattern matching 2015-12-26 13:09:24 -05:00
Erik aeb52de72f don't need to keep count manually 2015-12-25 11:28:08 -05:00
Erik ca90938675 refactor socketpacket 2015-12-25 11:24:03 -05:00
Erik 1aacab2567 use testable 2015-12-25 10:22:59 -05:00
Erik a28fda392c move test files 2015-12-25 10:11:00 -05:00
Erik 931382deff refactors 2015-12-25 10:02:09 -05:00
Erik 298817ce5c refactor 2015-12-23 14:00:06 -05:00
Erik Little 8cf3aebf9f Update README.md 2015-12-22 14:38:04 -05:00
Erik 75fc013f92 document spm 2015-12-22 14:35:31 -05:00
Erik 44c5591646 bump version 2015-12-22 14:12:56 -05:00
Erik 8e0d03b28c add basic package.swift file 2015-12-22 13:43:07 -05:00
Erik 7b1f72852f bump version 2015-12-20 15:42:40 -05:00
Erik 97d4f3f527 fix encoding of postWait messages sent over websocket 2015-12-20 15:36:42 -05:00
Erik d94a1901ca refactor. Remove var from methods and pattern matching 2015-12-20 15:01:28 -05:00
Erik fff2f29c55 remove extra stuff 2015-12-12 13:36:43 -05:00
Erik 57d1f3c4b4 bump websockets 2015-12-12 13:35:28 -05:00
Erik Little 499c0d6824 Merge pull request #255 from NachoSoto/deployment-target
Explicitly setting deployment target for to watchOS 2.0 and tvOS 9.0
2015-12-09 19:32:26 -05:00
NachoSoto 85cf6c48b1 Explicitly setting deployment target for to watchOS 2.0 and tvOS 9.0
Before this change, they would default to `watchOS 2.1` and `tvOS 9.1` in `Xcode 7.2`.
2015-12-10 00:20:05 +00:00
29 changed files with 566 additions and 435 deletions

No files matched your search

+2
View File
@@ -2,6 +2,8 @@
.AppleDouble
.LSOverride
*.xcodeproj
.build/*
Packages/*
# Icon must end with two \r
Icon
+5
View File
@@ -0,0 +1,5 @@
import PackageDescription
let package = Package(
name: "SocketIOClientSwift"
)
+20 -4
View File
@@ -65,11 +65,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.4 # Or latest version
github "socketio/socket.io-client-swift" ~> 5.0.0 # Or latest version
```
Run `carthage update --platform ios,macosx`.
@@ -83,7 +99,7 @@ source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!
pod 'Socket.IO-Client-Swift', '~> 4.1.4' # Or latest version
pod 'Socket.IO-Client-Swift', '~> 5.0.0' # Or latest version
```
Install pods:
@@ -111,7 +127,7 @@ CocoaSeeds
Add this line to your `Seedfile`:
```
github "socketio/socket.io-client-swift", "v4.1.4", :files => "SocketIOClientSwift/*.swift" # Or latest version
github "socketio/socket.io-client-swift", "v5.0.0", :files => "SocketIOClientSwift/*.swift" # Or latest version
```
Run `seed install`.
@@ -162,7 +178,7 @@ Methods
9. `connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
10. `close()` - Closes the socket. Once a socket is closed it should not be reopened.
11. `reconnect()` - Causes the client to reconnect to the server.
12. `joinNamespace()` - Causes the client to join nsp. Shouldn't need to be called unless you change nsp manually.
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.
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Socket.IO-Client-Swift"
s.version = "4.1.4"
s.version = "5.0.0"
s.summary = "Socket.IO-client for iOS and OS X"
s.description = <<-DESC
Socket.IO-client for iOS and OS X.
@@ -13,7 +13,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.4' }
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v5.0.0' }
s.source_files = "Source/**/*.swift"
s.requires_arc = true
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
@@ -13,76 +13,63 @@
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.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 */; };
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 +81,51 @@
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 */; };
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 */
@@ -198,17 +179,18 @@
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>"; };
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 */
@@ -338,11 +320,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,6 +345,7 @@
74171E501C10CD240062D398 /* SocketAckEmitter.swift */,
74171E511C10CD240062D398 /* SocketAckManager.swift */,
74171E521C10CD240062D398 /* SocketAnyEvent.swift */,
74ABF7761C3991C10078C657 /* SocketClientSpec.swift */,
74171E531C10CD240062D398 /* SocketEngine.swift */,
74171E541C10CD240062D398 /* SocketEngineClient.swift */,
74171E551C10CD240062D398 /* SocketEnginePacketType.swift */,
@@ -374,7 +357,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 */,
@@ -528,7 +511,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0640;
LastUpgradeCheck = 0720;
TargetAttributes = {
572EF2181B51F16C00EEBB58 = {
CreatedOnToolsVersion = 6.4;
@@ -620,6 +603,7 @@
74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
74171E751C10CD240062D398 /* SocketEngine.swift in Sources */,
74171E691C10CD240062D398 /* SocketAckManager.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 +615,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 +628,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 +645,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,6 +656,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7471CCEA1C39926300364B59 /* SocketClientSpec.swift in Sources */,
74171E951C10CD240062D398 /* SocketFixUTF8.swift in Sources */,
74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
74171E771C10CD240062D398 /* SocketEngine.swift in Sources */,
@@ -689,7 +672,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 +683,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,6 +697,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7471CCEB1C39926C00364B59 /* SocketClientSpec.swift in Sources */,
74171E971C10CD240062D398 /* SocketFixUTF8.swift in Sources */,
74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
74171E791C10CD240062D398 /* SocketEngine.swift in Sources */,
@@ -747,7 +713,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 +726,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 +743,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,9 +777,15 @@
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;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = SocketIO;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Debug;
};
@@ -825,8 +795,12 @@
BITCODE_GENERATION_MODE = bitcode;
CODE_SIGN_IDENTITY = "Developer ID Application";
ENABLE_BITCODE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_NAME = SocketIO;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
name = Release;
};
@@ -873,10 +847,10 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -924,9 +898,9 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
TARGETED_DEVICE_FAMILY = "1,2";
@@ -981,6 +955,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;
};
@@ -1024,6 +999,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;
@@ -1058,6 +1034,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;
@@ -1076,9 +1053,9 @@
INFOPLIST_FILE = "SocketIO-Mac/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
@@ -1116,6 +1093,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;
@@ -1128,8 +1106,8 @@
INFOPLIST_FILE = "SocketIO-Mac/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
SDKROOT = macosx;
SKIP_INSTALL = YES;
VERSIONING_SYSTEM = "apple-generic";
@@ -1184,6 +1162,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;
};
@@ -1229,6 +1208,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;
};
@@ -1277,10 +1257,10 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = SocketIO;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
@@ -1330,9 +1310,9 @@
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = "SocketIO-iOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = SocketIO;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
@@ -1389,6 +1369,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;
};
@@ -1432,6 +1413,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"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0640"
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0710"
LastUpgradeVersion = "0720"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
+1 -1
View File
@@ -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 -1
View File
@@ -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,6 +7,7 @@
//
import XCTest
@testable import SocketIO
class SocketAckManagerTest: XCTestCase {
var ackManager = SocketAckManager()
@@ -7,6 +7,7 @@
//
import XCTest
@testable import SocketIO
class SocketBasicPacketTest: XCTestCase {
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
+1
View File
@@ -7,6 +7,7 @@
//
import XCTest
@testable import SocketIO
class SocketEngineTest: XCTestCase {
var client: SocketIOClient!
@@ -7,6 +7,7 @@
//
import XCTest
@testable import SocketIO
class SocketNamespacePacketTest: XCTestCase {
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
@@ -7,8 +7,10 @@
//
import XCTest
@testable import SocketIO
class SocketParserTest: XCTestCase {
let testSocket = SocketIOClient(socketURL: "")
//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)
}
})
}
+15 -2
View File
@@ -7,12 +7,13 @@
//
import XCTest
@testable import SocketIO
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: "")
@@ -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
+1 -1
View File
@@ -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 -1
View File
@@ -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>
+2 -2
View File
@@ -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)
}
+35
View File
@@ -0,0 +1,35 @@
//
// 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: AnyObject)
func handleAck(ack: Int, data: [AnyObject])
func handleEvent(event: String, data: [AnyObject], isInternalMessage: Bool, withAck ack: Int)
func joinNamespace(namespace: String)
}
+71 -76
View File
@@ -83,23 +83,23 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
for option in options {
switch option {
case .SessionDelegate(let delegate):
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
@@ -109,7 +109,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
public convenience init(client: SocketEngineClient, url: String, options: NSDictionary?) {
self.init(client: client, url: url,
options: Set<SocketIOClientOption>.NSDictionaryToSocketOptionsSet(options ?? [:]))
options: options?.toSocketOptionsSet() ?? [])
}
deinit {
@@ -147,15 +147,14 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
}
}
private func checkIfMessageIsBase64Binary(var message: String) -> Bool {
private func checkIfMessageIsBase64Binary(message: String) -> Bool {
if message.hasPrefix("b4") {
// binary in base64 string
message.removeRange(Range(start: message.startIndex,
end: message.startIndex.advancedBy(2)))
let noPrefix = message[message.startIndex.advancedBy(2)..<message.endIndex]
if let data = NSData(base64EncodedString: message,
if let data = NSData(base64EncodedString: noPrefix,
options: .IgnoreUnknownCharacters) {
client?.parseBinaryData(data)
client?.parseEngineBinaryData(data)
}
return true
@@ -172,9 +171,9 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
connected = false
if websocket {
sendWebSocketMessage("", withType: .Close)
sendWebSocketMessage("", withType: .Close, withData: [])
} else {
sendPollMessage("", withType: .Close)
sendPollMessage("", withType: .Close, withData: [])
}
ws?.disconnect()
@@ -271,7 +270,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
"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
@@ -282,17 +281,15 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
private func flushProbeWait() {
DefaultSocketLogger.Logger.log("Flushing probe wait", type: logType)
dispatch_async(emitQueue) {[weak self] in
if let this = self {
for waiter in this.probeWait {
this.write(waiter.msg, withType: waiter.type, withData: waiter.data)
}
this.probeWait.removeAll(keepCapacity: false)
if this.postWait.count != 0 {
this.flushWaitingForPostToWebSocket()
}
dispatch_async(emitQueue) {
for waiter in self.probeWait {
self.write(waiter.msg, withType: waiter.type, withData: waiter.data)
}
self.probeWait.removeAll(keepCapacity: false)
if self.postWait.count != 0 {
self.flushWaitingForPostToWebSocket()
}
}
}
@@ -302,7 +299,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
}
private func handleMessage(message: String) {
client?.parseSocketMessage(message)
client?.parseEngineMessage(message)
}
private func handleNOOP() {
@@ -417,13 +414,14 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
private 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(var message: String, fromPolling: Bool) {
private func parseEngineMessage(message: String, fromPolling: Bool) {
DefaultSocketLogger.Logger.log("Got message: %@", type: logType, args: message)
let reader = SocketStringReader(message: message)
let fixedString: String
guard let type = SocketEnginePacketType(rawValue: Int(reader.currentCharacter) ?? -1) else {
if !checkIfMessageIsBase64Binary(message) {
@@ -434,22 +432,22 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
}
if fromPolling && type != .Noop {
fixDoubleUTF8(&message)
fixedString = fixDoubleUTF8(message)
} else {
fixedString = message
}
switch type {
case .Message:
message.removeAtIndex(message.startIndex)
handleMessage(message)
handleMessage(fixedString[fixedString.startIndex.successor()..<fixedString.endIndex])
case .Noop:
handleNOOP()
case .Pong:
handlePong(message)
handlePong(fixedString)
case .Open:
message.removeAtIndex(message.startIndex)
handleOpen(message)
handleOpen(fixedString[fixedString.startIndex.successor()..<fixedString.endIndex])
case .Close:
handleClose(message)
handleClose(fixedString)
default:
DefaultSocketLogger.Logger.log("Got unknown packet type", type: logType)
}
@@ -457,7 +455,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
private func probeWebSocket() {
if websocketConnected {
sendWebSocketMessage("probe", withType: .Ping)
sendWebSocketMessage("probe", withType: .Ping, withData: [])
}
}
@@ -496,7 +494,7 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
return
}
++pongsMissed
pongsMissed += 1
write("", withType: .Ping, withData: [])
}
@@ -518,26 +516,26 @@ public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
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)
}
guard self.connected else { return }
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 {
DefaultSocketLogger.Logger.log("Writing poll: %@ has data: %@",
type: self.logType, args: msg, data.count != 0)
self.sendPollMessage(msg, withType: type, withData: data)
}
}
}
@@ -567,11 +565,10 @@ extension SocketEngine {
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&sid=\(sid)&b64=1")!)
addHeaders(req)
doLongPoll(req)
}
private func doRequest(req: NSMutableURLRequest,
private 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: logType)
@@ -580,11 +577,10 @@ extension SocketEngine {
DefaultSocketLogger.Logger.log("Doing polling request", type: logType)
req.cachePolicy = .ReloadIgnoringLocalAndRemoteCacheData
session?.dataTaskWithRequest(req, completionHandler: callback).resume()
}
private func doLongPoll(req: NSMutableURLRequest) {
private func doLongPoll(req: NSURLRequest) {
doRequest(req) {[weak self] data, res, err in
guard let this = self else {return}
@@ -600,9 +596,9 @@ extension SocketEngine {
DefaultSocketLogger.Logger.log("Got polling response", type: this.logType)
if let str = NSString(data: data!, encoding: NSUTF8StringEncoding) as? String {
dispatch_async(this.parseQueue) {[weak this] in
this?.parsePollingMessage(str)
if let str = String(data: data!, encoding: NSUTF8StringEncoding) {
dispatch_async(this.parseQueue) {
this.parsePollingMessage(str)
}
}
@@ -666,10 +662,10 @@ extension SocketEngine {
this.waitingForPost = false
dispatch_async(this.emitQueue) {[weak this] in
if !(this?.fastUpgrade ?? true) {
this?.flushWaitingForPost()
this?.doPoll()
dispatch_async(this.emitQueue) {
if !this.fastUpgrade {
this.flushWaitingForPost()
this.doPoll()
}
}
}
@@ -678,10 +674,10 @@ extension SocketEngine {
// We had packets waiting for send when we upgraded
// Send them raw
private func flushWaitingForPostToWebSocket() {
guard let ws = self.ws else {return}
guard let ws = self.ws else { return }
for msg in postWait {
ws.writeString(msg)
ws.writeString(fixDoubleUTF8(msg))
}
postWait.removeAll(keepCapacity: true)
@@ -712,16 +708,15 @@ extension SocketEngine {
/// Send polling message.
/// Only call on emitQueue
private func sendPollMessage(var msg: String, withType type: SocketEnginePacketType,
datas:[NSData]? = nil) {
DefaultSocketLogger.Logger.log("Sending poll: %@ as type: %@", type: logType, args: msg, type.rawValue)
doubleEncodeUTF8(&msg)
let strMsg = "\(type.rawValue)\(msg)"
private func sendPollMessage(message: String, withType type: SocketEnginePacketType,
withData datas: [NSData]) {
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 ?? [] {
for data in datas {
if case let .Right(bin) = createBinaryDataForSend(data) {
postWait.append(bin)
}
@@ -743,13 +738,13 @@ extension SocketEngine {
/// Send message on WebSockets
/// Only call on emitQueue
private func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType,
datas:[NSData]? = nil) {
withData datas: [NSData]) {
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 Either.Left(bin) = createBinaryDataForSend(data) {
for data in datas {
if case let .Left(bin) = createBinaryDataForSend(data) {
ws?.writeData(bin)
}
}
+2 -2
View File
@@ -28,6 +28,6 @@ import Foundation
@objc public protocol SocketEngineClient {
func didError(reason: AnyObject)
func engineDidClose(reason: String)
func parseSocketMessage(msg: String)
func parseBinaryData(data: NSData)
func parseEngineMessage(msg: String)
func parseEngineBinaryData(data: NSData)
}
+10 -6
View File
@@ -25,16 +25,20 @@
import Foundation
func fixDoubleUTF8(inout name: String) {
if let utf8 = name.dataUsingEncoding(NSISOLatin1StringEncoding),
func fixDoubleUTF8(string: String) -> String {
if let utf8 = string.dataUsingEncoding(NSISOLatin1StringEncoding),
latin1 = NSString(data: utf8, encoding: NSUTF8StringEncoding) {
name = latin1 as String
return latin1 as String
} else {
return string
}
}
func doubleEncodeUTF8(inout str: String) {
if let latin1 = str.dataUsingEncoding(NSUTF8StringEncoding),
func doubleEncodeUTF8(string: String) -> String {
if let latin1 = string.dataUsingEncoding(NSUTF8StringEncoding),
utf8 = NSString(data: latin1, encoding: NSISOLatin1StringEncoding) {
str = utf8 as String
return utf8 as String
} else {
return string
}
}
+35 -41
View File
@@ -24,12 +24,13 @@
import Foundation
public final class SocketIOClient: NSObject, SocketEngineClient {
public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable {
public let socketURL: String
public private(set) var engine: SocketEngineSpec?
public private(set) var status = SocketIOClientStatus.NotConnected
public var connectParams: [String: AnyObject]?
public var forceNew = false
public var nsp = "/"
public var options: Set<SocketIOClientOption>
@@ -46,7 +47,6 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
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()
@@ -68,25 +68,25 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
self.socketURL = socketURL["https?://"] ~= ""
for option in options ?? [] {
for option in options {
switch option {
case .ConnectParams(let params):
case let .ConnectParams(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
@@ -104,7 +104,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
*/
public convenience init(socketURL: String, options: NSDictionary?) {
self.init(socketURL: socketURL,
options: Set<SocketIOClientOption>.NSDictionaryToSocketOptionsSet(options ?? [:]))
options: options?.toSocketOptionsSet() ?? [])
}
deinit {
@@ -112,13 +112,12 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
engine?.close()
}
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 = SocketEngine(client: self, url: socketURL, options: options)
engine = newEngine
return newEngine
return engine!
}
private func clearReconnectTimer() {
@@ -181,7 +180,9 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
}
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)
@@ -192,7 +193,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
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)
}
}
@@ -318,13 +319,12 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
}
// Called when the socket gets an ack for something it sent
func handleAck(ack: Int, data: AnyObject?) {
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!] : []))
ackHandlers.executeAck(ack, items: data)
}
/**
@@ -359,22 +359,15 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
}
/**
Joins nsp if it is not /
*/
public func joinNamespace() {
DefaultSocketLogger.Logger.log("Joining namespace", type: logType)
if nsp != "/" {
engine?.send("0\(nsp)", withData: [])
}
}
/**
Joins namespace /
Joins namespace
*/
public func joinNamespace(namespace: String) {
self.nsp = namespace
joinNamespace()
nsp = namespace
if nsp != "/" {
DefaultSocketLogger.Logger.log("Joining namespace", type: logType)
engine?.send("0\(nsp)", withData: [])
}
}
/**
@@ -442,15 +435,16 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
connect()
}
public func parseSocketMessage(msg: String) {
public func parseEngineMessage(msg: String) {
DefaultSocketLogger.Logger.log("Should parse message", type: "SocketIOClient")
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)
}
}
@@ -500,7 +494,7 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
handleEvent("reconnectAttempt", data: [reconnectAttempts - currentReconnectAttempt],
isInternalMessage: true)
currentReconnectAttempt++
currentReconnectAttempt += 1
connect()
}
}
+132 -62
View File
@@ -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
}
}
+2 -2
View File
@@ -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)
+73 -103
View File
@@ -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,22 +72,23 @@ 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
}
}
private func completeMessage(var message: String, ack: Bool) -> String {
private func completeMessage(message: String, ack: Bool) -> String {
var restOfMessage = ""
if data.count == 0 {
return message + "]"
}
@@ -105,57 +98,54 @@ 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)
message += jsonString! as String + ","
restOfMessage += jsonString! + ","
} catch {
DefaultSocketLogger.Logger.error("Error creating JSON object in SocketPacket.completeMessage",
type: SocketPacket.logType)
}
} else if var str = arg as? String {
str = str["\n"] ~= "\\\\n"
str = str["\r"] ~= "\\\\r"
message += "\"\(str)\","
} else if let str = arg as? String {
restOfMessage += "\"" + ((str["\n"] ~= "\\\\n")["\r"] ~= "\\\\r") + "\","
} else if arg is NSNull {
message += "null,"
restOfMessage += "null,"
} else {
message += "\(arg),"
restOfMessage += "\(arg),"
}
}
if message != "" {
message.removeAtIndex(message.endIndex.predecessor())
if restOfMessage != "" {
restOfMessage.removeAtIndex(restOfMessage.endIndex.predecessor())
}
return message + "]"
return message + restOfMessage + "]"
}
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["
@@ -191,7 +181,7 @@ struct SocketPacket {
private func createPacketString() -> String {
let str: String
if type == PacketType.Event || type == PacketType.BinaryEvent {
if type == .Event || type == .BinaryEvent {
str = createMessageForEvent()
} else {
str = createAck()
@@ -200,42 +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? NSArray {
let newArr = NSMutableArray(array: arr)
for i in 0..<arr.count {
newArr[i] = _fillInPlaceholders(arr[i])
}
return newArr
} 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
}
}
}
@@ -244,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
}
}
@@ -266,39 +244,31 @@ 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 var arr = data as? [AnyObject] {
for i in 0..<arr.count {
arr[i] = shred(arr[i], binary: &binary)
}
return arr
} 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 arr as [AnyObject]:
return arr.map({shred($0, binary: &binary)})
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
}
}
static func deconstructData(var data: [AnyObject]) -> ([AnyObject], [NSData]) {
// 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]()
for i in 0..<data.count {
data[i] = shred(data[i], binary: &binary)
}
return (data, binary)
return (data.map({shred($0, binary: &binary)}), binary)
}
}
@@ -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)
didError(pack.data)
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")
}
}
@@ -111,7 +115,7 @@ class SocketParser {
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)
}
}
}
+48 -12
View File
@@ -3,6 +3,19 @@
// Websocket.swift
//
// Created by Dalton Cherry on 7/16/14.
// Copyright (c) 2014-2015 Dalton Cherry.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//////////////////////////////////////////////////////////////////////////////////////////////////
@@ -421,6 +434,33 @@ public class WebSocket : NSObject, NSStreamDelegate {
return false
}
///read a 16 bit big endian value from a buffer
private static func readUint16(buffer: UnsafePointer<UInt8>, offset: Int) -> UInt16 {
return (UInt16(buffer[offset + 0]) << 8) | UInt16(buffer[offset + 1])
}
///read a 64 bit big endian value from a buffer
private static func readUint64(buffer: UnsafePointer<UInt8>, offset: Int) -> UInt64 {
var value = UInt64(0)
for i in 0...7 {
value = (value << 8) | UInt64(buffer[offset + i])
}
return value
}
///write a 16 bit big endian value to a buffer
private static func writeUint16(buffer: UnsafeMutablePointer<UInt8>, offset: Int, value: UInt16) {
buffer[offset + 0] = UInt8(value >> 8)
buffer[offset + 1] = UInt8(value & 0xff)
}
///write a 64 bit big endian value to a buffer
private static func writeUint64(buffer: UnsafeMutablePointer<UInt8>, offset: Int, value: UInt64) {
for i in 0...7 {
buffer[offset + i] = UInt8((value >> (8*UInt64(7 - i))) & 0xff)
}
}
///process the websocket data
private func processRawMessage(buffer: UnsafePointer<UInt8>, bufferLen: Int) {
let response = readStack.last
@@ -474,8 +514,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
if payloadLen == 1 {
code = CloseCode.ProtocolError.rawValue
} else if payloadLen > 1 {
let codeBuffer = UnsafePointer<UInt16>((buffer+offset))
code = codeBuffer[0].bigEndian
code = WebSocket.readUint16(buffer, offset: offset)
if code < 1000 || (code > 1003 && code < 1007) || (code > 1011 && code < 3000) {
code = CloseCode.ProtocolError.rawValue
}
@@ -501,12 +540,10 @@ public class WebSocket : NSObject, NSStreamDelegate {
}
var dataLength = UInt64(payloadLen)
if dataLength == 127 {
let bytes = UnsafePointer<UInt64>((buffer+offset))
dataLength = bytes[0].bigEndian
dataLength = WebSocket.readUint64(buffer, offset: offset)
offset += sizeof(UInt64)
} else if dataLength == 126 {
let bytes = UnsafePointer<UInt16>((buffer+offset))
dataLength = UInt64(bytes[0].bigEndian)
dataLength = UInt64(WebSocket.readUint16(buffer, offset: offset))
offset += sizeof(UInt16)
}
if bufferLen < offset || UInt64(bufferLen - offset) < dataLength {
@@ -644,8 +681,8 @@ public class WebSocket : NSObject, NSStreamDelegate {
///write a an error to the socket
private func writeError(code: UInt16) {
let buf = NSMutableData(capacity: sizeof(UInt16))
let buffer = UnsafeMutablePointer<UInt16>(buf!.bytes)
buffer[0] = code.bigEndian
let buffer = UnsafeMutablePointer<UInt8>(buf!.bytes)
WebSocket.writeUint16(buffer, offset: 0, value: code)
dequeueWrite(NSData(bytes: buffer, length: sizeof(UInt16)), code: .ConnectionClose)
}
///used to write things to the stream
@@ -665,13 +702,11 @@ public class WebSocket : NSObject, NSStreamDelegate {
buffer[1] = CUnsignedChar(dataLength)
} else if dataLength <= Int(UInt16.max) {
buffer[1] = 126
let sizeBuffer = UnsafeMutablePointer<UInt16>((buffer+offset))
sizeBuffer[0] = UInt16(dataLength).bigEndian
WebSocket.writeUint16(buffer, offset: offset, value: UInt16(dataLength))
offset += sizeof(UInt16)
} else {
buffer[1] = 127
let sizeBuffer = UnsafeMutablePointer<UInt64>((buffer+offset))
sizeBuffer[0] = UInt64(dataLength).bigEndian
WebSocket.writeUint64(buffer, offset: offset, value: UInt64(dataLength))
offset += sizeof(UInt64)
}
buffer[1] |= s.MaskMask
@@ -725,6 +760,7 @@ public class WebSocket : NSObject, NSStreamDelegate {
}
}
private class SSLCert {
var certData: NSData?
var key: SecKeyRef?