From 76a96adef53fb16cbee35dee9767f8c07a89fcaf Mon Sep 17 00:00:00 2001 From: allenlinli Date: Mon, 30 Dec 2019 15:25:19 +0800 Subject: [PATCH] test: did carthage update and move the framework --- Cartfile.resolved | 2 +- Carthage/Checkouts/Starscream/.gitignore | 118 ++ Carthage/Checkouts/Starscream/.travis.yml | 7 + Carthage/Checkouts/Starscream/CHANGELOG.md | 231 +++ Carthage/Checkouts/Starscream/Gemfile | 4 + Carthage/Checkouts/Starscream/Gemfile.lock | 212 +++ Carthage/Checkouts/Starscream/LICENSE | 176 +++ .../Checkouts/Starscream/Package.resolved | 16 + Carthage/Checkouts/Starscream/Package.swift | 36 + Carthage/Checkouts/Starscream/README.md | 438 ++++++ .../Checkouts/Starscream/Sources/Info.plist | 26 + .../Checkouts/Starscream/Sources/Starscream.h | 19 + .../Sources/Starscream/Compression.swift | 177 +++ .../Starscream/SSLClientCertificate.swift | 92 ++ .../Sources/Starscream/SSLSecurity.swift | 266 ++++ .../Sources/Starscream/WebSocket.swift | 1356 +++++++++++++++++ .../Checkouts/Starscream/Starscream.podspec | 16 + .../Starscream/Tests/CompressionTests.swift | 67 + .../Checkouts/Starscream/Tests/Info.plist | 24 + .../StarscreamTests/StarscreamTests.swift | 35 + Carthage/Checkouts/Starscream/build.sh | 6 + .../examples/AutobahnTest/.gitignore | 27 + .../AutobahnTest/Autobahn/AppDelegate.swift | 46 + .../Autobahn/Base.lproj/LaunchScreen.xib | 41 + .../Autobahn/Base.lproj/Main.storyboard | 26 + .../AppIcon.appiconset/Contents.json | 68 + .../examples/AutobahnTest/Autobahn/Info.plist | 47 + .../Autobahn/ViewController.swift | 166 ++ .../AutobahnTests/AutobahnTests.swift | 36 + .../AutobahnTest/AutobahnTests/Info.plist | 24 + .../Starscream/examples/SimpleTest/.gitignore | 27 + .../Starscream/examples/SimpleTest/README.md | 20 + .../SimpleTest/SimpleTest/AppDelegate.swift | 46 + .../SimpleTest/Base.lproj/Main.storyboard | 54 + .../AppIcon.appiconset/Contents.json | 58 + .../LaunchImage.launchimage/Contents.json | 51 + .../examples/SimpleTest/SimpleTest/Info.plist | 45 + .../SimpleTest/ViewController.swift | 67 + .../examples/SimpleTest/ws-server.rb | 25 + .../examples/WebSocketsOrgEcho/Podfile | 11 + .../examples/WebSocketsOrgEcho/Podfile.lock | 16 + .../Local Podspecs/Starscream.podspec.json | 24 + .../WebSocketsOrgEcho/Pods/Manifest.lock | 16 + .../Pods-WebSocketsOrgEcho-Info.plist | 26 + ...ebSocketsOrgEcho-acknowledgements.markdown | 182 +++ ...s-WebSocketsOrgEcho-acknowledgements.plist | 5 + .../Pods-WebSocketsOrgEcho-dummy.m | 5 + .../Pods-WebSocketsOrgEcho-frameworks.sh | 158 ++ .../Pods-WebSocketsOrgEcho-umbrella.h | 16 + .../Pods-WebSocketsOrgEcho.debug.xcconfig | 11 + .../Pods-WebSocketsOrgEcho.modulemap | 6 + .../Pods-WebSocketsOrgEcho.release.xcconfig | 11 + .../Starscream/Starscream-Info.plist | 26 + .../Starscream/Starscream-dummy.m | 5 + .../Starscream/Starscream-prefix.pch | 12 + .../Starscream/Starscream-umbrella.h | 16 + .../Starscream/Starscream.modulemap | 6 + .../Starscream/Starscream.xcconfig | 9 + .../contents.xcworkspacedata | 10 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../WebSocketsOrgEcho/AppDelegate.swift | 21 + .../AppIcon.appiconset/Contents.json | 98 ++ .../Assets.xcassets/Contents.json | 6 + .../Base.lproj/LaunchScreen.storyboard | 25 + .../Base.lproj/Main.storyboard | 40 + .../WebSocketsOrgEcho/Info.plist | 45 + .../WebSocketsOrgEcho/URL+Extensions.swift | 19 + .../WebSocketsOrgEcho/ViewController.swift | 42 + .../Checkouts/Starscream/fastlane/Fastfile | 28 + .../Checkouts/Starscream/fastlane/README.md | 29 + Carthage/Checkouts/Starscream/release.sh | 4 + .../project.pbxproj | 14 +- 72 files changed, 5145 insertions(+), 3 deletions(-) create mode 100644 Carthage/Checkouts/Starscream/.gitignore create mode 100644 Carthage/Checkouts/Starscream/.travis.yml create mode 100644 Carthage/Checkouts/Starscream/CHANGELOG.md create mode 100644 Carthage/Checkouts/Starscream/Gemfile create mode 100644 Carthage/Checkouts/Starscream/Gemfile.lock create mode 100644 Carthage/Checkouts/Starscream/LICENSE create mode 100644 Carthage/Checkouts/Starscream/Package.resolved create mode 100644 Carthage/Checkouts/Starscream/Package.swift create mode 100644 Carthage/Checkouts/Starscream/README.md create mode 100644 Carthage/Checkouts/Starscream/Sources/Info.plist create mode 100644 Carthage/Checkouts/Starscream/Sources/Starscream.h create mode 100644 Carthage/Checkouts/Starscream/Sources/Starscream/Compression.swift create mode 100644 Carthage/Checkouts/Starscream/Sources/Starscream/SSLClientCertificate.swift create mode 100644 Carthage/Checkouts/Starscream/Sources/Starscream/SSLSecurity.swift create mode 100644 Carthage/Checkouts/Starscream/Sources/Starscream/WebSocket.swift create mode 100644 Carthage/Checkouts/Starscream/Starscream.podspec create mode 100644 Carthage/Checkouts/Starscream/Tests/CompressionTests.swift create mode 100644 Carthage/Checkouts/Starscream/Tests/Info.plist create mode 100644 Carthage/Checkouts/Starscream/Tests/StarscreamTests/StarscreamTests.swift create mode 100755 Carthage/Checkouts/Starscream/build.sh create mode 100644 Carthage/Checkouts/Starscream/examples/AutobahnTest/.gitignore create mode 100644 Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/AppDelegate.swift create mode 100644 Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Base.lproj/LaunchScreen.xib create mode 100644 Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Base.lproj/Main.storyboard create mode 100644 Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Info.plist create mode 100644 Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/ViewController.swift create mode 100644 Carthage/Checkouts/Starscream/examples/AutobahnTest/AutobahnTests/AutobahnTests.swift create mode 100644 Carthage/Checkouts/Starscream/examples/AutobahnTest/AutobahnTests/Info.plist create mode 100644 Carthage/Checkouts/Starscream/examples/SimpleTest/.gitignore create mode 100644 Carthage/Checkouts/Starscream/examples/SimpleTest/README.md create mode 100644 Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/AppDelegate.swift create mode 100644 Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Base.lproj/Main.storyboard create mode 100644 Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Images.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Images.xcassets/LaunchImage.launchimage/Contents.json create mode 100644 Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Info.plist create mode 100644 Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/ViewController.swift create mode 100644 Carthage/Checkouts/Starscream/examples/SimpleTest/ws-server.rb create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Podfile create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Podfile.lock create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Local Podspecs/Starscream.podspec.json create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Manifest.lock create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-Info.plist create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-acknowledgements.markdown create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-acknowledgements.plist create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-dummy.m create mode 100755 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-frameworks.sh create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-umbrella.h create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.debug.xcconfig create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.modulemap create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.release.xcconfig create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-Info.plist create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-dummy.m create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-prefix.pch create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-umbrella.h create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream.modulemap create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream.xcconfig create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho.xcworkspace/contents.xcworkspacedata create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/AppDelegate.swift create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Assets.xcassets/Contents.json create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Base.lproj/LaunchScreen.storyboard create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Base.lproj/Main.storyboard create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Info.plist create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/URL+Extensions.swift create mode 100644 Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/ViewController.swift create mode 100644 Carthage/Checkouts/Starscream/fastlane/Fastfile create mode 100644 Carthage/Checkouts/Starscream/fastlane/README.md create mode 100755 Carthage/Checkouts/Starscream/release.sh diff --git a/Cartfile.resolved b/Cartfile.resolved index c76f7271..afb07edd 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "daltoniam/Starscream" "3.1.0" +github "daltoniam/Starscream" "3.1.1" diff --git a/Carthage/Checkouts/Starscream/.gitignore b/Carthage/Checkouts/Starscream/.gitignore new file mode 100644 index 00000000..69ce2544 --- /dev/null +++ b/Carthage/Checkouts/Starscream/.gitignore @@ -0,0 +1,118 @@ +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control? +# + Pods/ + +# Xcode +.DS_Store +build +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ +*.hmap +*.xccheckout +*.xcodeproj/*.xcworkspace + + +# Created by https://www.gitignore.io/api/swift,swiftpm + +### Swift ### +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## Build generated +build/ +DerivedData/ + +## Various settings +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata/ + +## Other +*.moved-aside +*.xccheckout +*.xcscmblueprint + +## Obj-C/Swift specific +*.hmap +*.ipa +*.dSYM.zip +*.dSYM + +## Playgrounds +timeline.xctimeline +playground.xcworkspace + +# Swift Package Manager +# +# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. +# Packages/ +# Package.pins +# Package.resolved +.build/ + +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control +# +# Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace + +# Carthage +# +# Add this line if you want to avoid checking in source code from Carthage dependencies. +# Carthage/Checkouts + +Carthage/Build + +# fastlane +# +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# screenshots whenever they are needed. +# For more information about the recommended setup visit: +# https://docs.fastlane.tools/best-practices/source-control/#source-control + +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output + +# Code Injection +# +# After new code Injection tools there's a generated folder /iOSInjectionProject +# https://github.com/johnno1962/injectionforxcode + +iOSInjectionProject/ + +### SwiftPM ### +Packages +xcuserdata +*.xcodeproj + + +# End of https://www.gitignore.io/api/swift,swiftpm diff --git a/Carthage/Checkouts/Starscream/.travis.yml b/Carthage/Checkouts/Starscream/.travis.yml new file mode 100644 index 00000000..8eb19e52 --- /dev/null +++ b/Carthage/Checkouts/Starscream/.travis.yml @@ -0,0 +1,7 @@ +osx_image: xcode10.2 +language: objective-c +before_install: + - gem install cocoapods --pre + - gem cleanup +script: +- ./build.sh diff --git a/Carthage/Checkouts/Starscream/CHANGELOG.md b/Carthage/Checkouts/Starscream/CHANGELOG.md new file mode 100644 index 00000000..0998d7a1 --- /dev/null +++ b/Carthage/Checkouts/Starscream/CHANGELOG.md @@ -0,0 +1,231 @@ +# Change Log +All notable changes to this project will be documented in this file. +`Starscream` adheres to [Semantic Versioning](http://semver.org/). + +### [3.1.1](https://github.com/daltoniam/Starscream/tree/3.1.1) + +Small version number fix for 3.1.0: [#703](https://github.com/daltoniam/Starscream/issues/703) + +### [3.1.0](https://github.com/daltoniam/Starscream/tree/3.1.0) + +* Swift 5.0 and Xcode 10.2 support + +#### [3.0.6](https://github.com/daltoniam/Starscream/tree/3.0.6) + +* Swift 4.2 and Xcode 10 support +* added pongDelegate +* moved CommonCrypto and zlib dependencies +* HTTP proxy support + +#### [3.0.5](https://github.com/daltoniam/Starscream/tree/3.0.5) + +Swift 4.1 support and bug fixes. + +Pull Requests: +[#492](https://github.com/daltoniam/Starscream/pull/492) +[#461](https://github.com/daltoniam/Starscream/pull/461) +[#476](https://github.com/daltoniam/Starscream/pull/476) + +Issues: +[#494](https://github.com/daltoniam/Starscream/issues/494) +[#491](https://github.com/daltoniam/Starscream/issues/491) +[#474](https://github.com/daltoniam/Starscream/issues/474) +[#471](https://github.com/daltoniam/Starscream/issues/471) +[#437](https://github.com/daltoniam/Starscream/issues/437) +[#445](https://github.com/daltoniam/Starscream/issues/445) +[#466](https://github.com/daltoniam/Starscream/issues/466) + + +#### [3.0.4](https://github.com/daltoniam/Starscream/tree/3.0.4) + +Improved error handling. Timeout fix. Small assorted fixes. + +Pull Requests: +[#452](https://github.com/daltoniam/Starscream/pull/452) +[#448](https://github.com/daltoniam/Starscream/pull/448) +[#444](https://github.com/daltoniam/Starscream/pull/444) +[#443](https://github.com/daltoniam/Starscream/pull/443) + +Issues: +[#415](https://github.com/daltoniam/Starscream/issues/415) +[#422](https://github.com/daltoniam/Starscream/issues/422) +[#429](https://github.com/daltoniam/Starscream/issues/429) +[#433](https://github.com/daltoniam/Starscream/issues/433) +[#439](https://github.com/daltoniam/Starscream/issues/439) + +#### [3.0.3](https://github.com/daltoniam/Starscream/tree/3.0.3) + +Assorted fixes. + +Pull Requests: +[#438](https://github.com/daltoniam/Starscream/pull/438) +[#423](https://github.com/daltoniam/Starscream/pull/423) +[#420](https://github.com/daltoniam/Starscream/pull/420) +[#418](https://github.com/daltoniam/Starscream/pull/418) +[#410](https://github.com/daltoniam/Starscream/pull/410) +[#405](https://github.com/daltoniam/Starscream/pull/405) +[#404](https://github.com/daltoniam/Starscream/pull/404) +[#400](https://github.com/daltoniam/Starscream/pull/400) + +Issues: +[#435](https://github.com/daltoniam/Starscream/issues/435) +[#431](https://github.com/daltoniam/Starscream/issues/431) +[#426](https://github.com/daltoniam/Starscream/issues/426) +[#409](https://github.com/daltoniam/Starscream/issues/409) +[#408](https://github.com/daltoniam/Starscream/issues/408) +[#401](https://github.com/daltoniam/Starscream/issues/401) +[#399](https://github.com/daltoniam/Starscream/issues/399) +[#378](https://github.com/daltoniam/Starscream/issues/378) + +#### [3.0.2](https://github.com/daltoniam/Starscream/tree/3.0.2) + +Small fixes for 3.0.1. + +[#394](https://github.com/daltoniam/Starscream/issues/394) +[#392](https://github.com/daltoniam/Starscream/issues/392) +[#391](https://github.com/daltoniam/Starscream/issues/391) + +#### [3.0.1](https://github.com/daltoniam/Starscream/tree/3.0.1) + +Small fixes for 3.0.0. + +[#389](https://github.com/daltoniam/Starscream/issues/389) +[#354](https://github.com/daltoniam/Starscream/issues/354) +[#386](https://github.com/daltoniam/Starscream/pull/386) +[#388](https://github.com/daltoniam/Starscream/pull/388) +[#390](https://github.com/daltoniam/Starscream/pull/390) + +#### [3.0.0](https://github.com/daltoniam/Starscream/tree/3.0.0) + +Major refactor and Swift 4 support. Additions include: + +- Watchos support. +- Linux support. +- New Stream class to allow custom socket implementations if desired. +- Protocol added for mocking (dependency injection). +- Single framework (no more platform suffixes! e.g. StarscreamOSX, StarscreamTVOS, etc). + +[#384](https://github.com/daltoniam/Starscream/issues/384) +[#377](https://github.com/daltoniam/Starscream/pull/377) +[#374](https://github.com/daltoniam/Starscream/issues/374) +[#346](https://github.com/daltoniam/Starscream/issues/346) +[#335](https://github.com/daltoniam/Starscream/issues/335) +[#311](https://github.com/daltoniam/Starscream/pull/311) +[#269](https://github.com/daltoniam/Starscream/issues/269) + +#### [2.1.1](https://github.com/daltoniam/Starscream/tree/2.1.1) + +Fixes race condition. Updated to avoid SPM dependencies. + +[#370](https://github.com/daltoniam/Starscream/issues/370) +[#367](https://github.com/daltoniam/Starscream/issues/367) +[#364](https://github.com/daltoniam/Starscream/pull/364) +[#357](https://github.com/daltoniam/Starscream/pull/357) +[#355](https://github.com/daltoniam/Starscream/pull/355) + +#### [2.1.0](https://github.com/daltoniam/Starscream/tree/2.1.0) + +Adds WebSocket compression. Also adds advance WebSocket delegate for extra control. Bug Fixes. + +[#349](https://github.com/daltoniam/Starscream/pull/349) +[#344](https://github.com/daltoniam/Starscream/pull/344) +[#339](https://github.com/daltoniam/Starscream/pull/339) +[#337](https://github.com/daltoniam/Starscream/pull/337) +[#334](https://github.com/daltoniam/Starscream/issues/334) +[#333](https://github.com/daltoniam/Starscream/pull/333) +[#319](https://github.com/daltoniam/Starscream/issues/319) +[#309](https://github.com/daltoniam/Starscream/issues/309) +[#329](https://github.com/daltoniam/Starscream/issues/329) + +#### [2.0.4](https://github.com/daltoniam/Starscream/tree/2.0.4) + +SSL Pinning fix by Giuliano Galea as reported by Lukas Futera of [Centralway](https://www.centralway.com/de/). +Warning fixes for Swift 3.1 + +#### [2.0.3](https://github.com/daltoniam/Starscream/tree/2.0.3) + +[#302](https://github.com/daltoniam/Starscream/issues/302) +[#301](https://github.com/daltoniam/Starscream/issues/301) +[#300](https://github.com/daltoniam/Starscream/issues/300) +[#296](https://github.com/daltoniam/Starscream/issues/296) +[#294](https://github.com/daltoniam/Starscream/issues/294) +[#292](https://github.com/daltoniam/Starscream/issues/292) +[#289](https://github.com/daltoniam/Starscream/issues/289) +[#288](https://github.com/daltoniam/Starscream/issues/288) + +#### [2.0.2](https://github.com/daltoniam/Starscream/tree/2.0.2) + +Fix for the Swift Package Manager. + +Fixed: +[#277](https://github.com/daltoniam/Starscream/issues/277) + +#### [2.0.1](https://github.com/daltoniam/Starscream/tree/2.0.1) + +Bug fixes. + +Fixed: +[#261](https://github.com/daltoniam/Starscream/issues/261) +[#276](https://github.com/daltoniam/Starscream/issues/276) +[#267](https://github.com/daltoniam/Starscream/issues/267) +[#266](https://github.com/daltoniam/Starscream/issues/266) +[#259](https://github.com/daltoniam/Starscream/issues/259) + +#### [2.0.0](https://github.com/daltoniam/Starscream/tree/2.0.0) + +Added Swift 3 support. + +Fixed: +[#229](https://github.com/daltoniam/Starscream/issues/229) +[#232](https://github.com/daltoniam/Starscream/issues/232) + +#### [1.1.4](https://github.com/daltoniam/Starscream/tree/1.1.4) + +Swift 2.3 support. + +#### [1.1.3](https://github.com/daltoniam/Starscream/tree/1.1.3) + +Changed: +[#170](https://github.com/daltoniam/Starscream/issues/170) +[#171](https://github.com/daltoniam/Starscream/issues/171) +[#174](https://github.com/daltoniam/Starscream/issues/174) +[#177](https://github.com/daltoniam/Starscream/issues/177) +[#178](https://github.com/daltoniam/Starscream/issues/178) + +#### [1.1.2](https://github.com/daltoniam/Starscream/tree/1.1.2) + +Fixed: +[#158](https://github.com/daltoniam/Starscream/issues/158) +[#161](https://github.com/daltoniam/Starscream/issues/161) +[#164](https://github.com/daltoniam/Starscream/issues/164) + +#### [1.1.1](https://github.com/daltoniam/Starscream/tree/1.1.1) + +Fixed: +[#157](https://github.com/daltoniam/Starscream/issues/157) + +#### [1.1.0](https://github.com/daltoniam/Starscream/tree/1.1.0) + +Changed: +Moved over to Runloop/default GCD queues to shared queue. + +Fixed: +[#153](https://github.com/daltoniam/Starscream/issues/153) +[#151](https://github.com/daltoniam/Starscream/issues/151) +[#150](https://github.com/daltoniam/Starscream/issues/150) +[#149](https://github.com/daltoniam/Starscream/issues/149) +[#147](https://github.com/daltoniam/Starscream/issues/147) +[#139](https://github.com/daltoniam/Starscream/issues/139) +[#77](https://github.com/daltoniam/Starscream/issues/77) + +#### [1.0.2](https://github.com/daltoniam/Starscream/tree/1.0.2) + +Added TVOS support. + +#### [1.0.1](https://github.com/daltoniam/Starscream/tree/1.0.1) + +Fixes for #121, #123 + +#### [1.0.0](https://github.com/daltoniam/Starscream/tree/1.0.0) + +first release of Swift 2 support. diff --git a/Carthage/Checkouts/Starscream/Gemfile b/Carthage/Checkouts/Starscream/Gemfile new file mode 100644 index 00000000..82d1e304 --- /dev/null +++ b/Carthage/Checkouts/Starscream/Gemfile @@ -0,0 +1,4 @@ +source "https://rubygems.org" + +gem "fastlane" +gem "cocoapods" diff --git a/Carthage/Checkouts/Starscream/Gemfile.lock b/Carthage/Checkouts/Starscream/Gemfile.lock new file mode 100644 index 00000000..06409b7f --- /dev/null +++ b/Carthage/Checkouts/Starscream/Gemfile.lock @@ -0,0 +1,212 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.0) + activesupport (4.2.11.1) + i18n (~> 0.7) + minitest (~> 5.1) + thread_safe (~> 0.3, >= 0.3.4) + tzinfo (~> 1.1) + addressable (2.6.0) + public_suffix (>= 2.0.2, < 4.0) + atomos (0.1.3) + babosa (1.0.2) + claide (1.0.2) + cocoapods (1.6.1) + activesupport (>= 4.0.2, < 5) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.6.1) + cocoapods-deintegrate (>= 1.0.2, < 2.0) + cocoapods-downloader (>= 1.2.2, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-stats (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.3.1, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.2.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.6.6) + nap (~> 1.0) + ruby-macho (~> 1.4) + xcodeproj (>= 1.8.1, < 2.0) + cocoapods-core (1.6.1) + activesupport (>= 4.0.2, < 6) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + cocoapods-deintegrate (1.0.4) + cocoapods-downloader (1.2.2) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.0) + cocoapods-stats (1.1.0) + cocoapods-trunk (1.3.1) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.1.0) + colored (1.2) + colored2 (3.1.2) + commander-fastlane (4.4.6) + highline (~> 1.7.2) + concurrent-ruby (1.1.5) + declarative (0.0.10) + declarative-option (0.1.0) + digest-crc (0.4.1) + domain_name (0.5.20180417) + unf (>= 0.0.5, < 1.0.0) + dotenv (2.7.2) + emoji_regex (1.0.1) + escape (0.0.4) + excon (0.64.0) + faraday (0.15.4) + multipart-post (>= 1.2, < 3) + faraday-cookie_jar (0.0.6) + faraday (>= 0.7.4) + http-cookie (~> 1.0.0) + faraday_middleware (0.13.1) + faraday (>= 0.7.4, < 1.0) + fastimage (2.1.5) + fastlane (2.122.0) + CFPropertyList (>= 2.3, < 4.0.0) + addressable (>= 2.3, < 3.0.0) + babosa (>= 1.0.2, < 2.0.0) + bundler (>= 1.12.0, < 3.0.0) + colored + commander-fastlane (>= 4.4.6, < 5.0.0) + dotenv (>= 2.1.1, < 3.0.0) + emoji_regex (>= 0.1, < 2.0) + excon (>= 0.45.0, < 1.0.0) + faraday (~> 0.9) + faraday-cookie_jar (~> 0.0.6) + faraday_middleware (~> 0.9) + fastimage (>= 2.1.0, < 3.0.0) + gh_inspector (>= 1.1.2, < 2.0.0) + google-api-client (>= 0.21.2, < 0.24.0) + google-cloud-storage (>= 1.15.0, < 2.0.0) + highline (>= 1.7.2, < 2.0.0) + json (< 3.0.0) + mini_magick (~> 4.5.1) + multi_json + multi_xml (~> 0.5) + multipart-post (~> 2.0.0) + plist (>= 3.1.0, < 4.0.0) + public_suffix (~> 2.0.0) + rubyzip (>= 1.2.2, < 2.0.0) + security (= 0.1.3) + simctl (~> 1.6.3) + slack-notifier (>= 2.0.0, < 3.0.0) + terminal-notifier (>= 2.0.0, < 3.0.0) + terminal-table (>= 1.4.5, < 2.0.0) + tty-screen (>= 0.6.3, < 1.0.0) + tty-spinner (>= 0.8.0, < 1.0.0) + word_wrap (~> 1.0.0) + xcodeproj (>= 1.8.1, < 2.0.0) + xcpretty (~> 0.3.0) + xcpretty-travis-formatter (>= 0.0.3) + fourflusher (2.2.0) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + google-api-client (0.23.9) + addressable (~> 2.5, >= 2.5.1) + googleauth (>= 0.5, < 0.7.0) + httpclient (>= 2.8.1, < 3.0) + mime-types (~> 3.0) + representable (~> 3.0) + retriable (>= 2.0, < 4.0) + signet (~> 0.9) + google-cloud-core (1.3.0) + google-cloud-env (~> 1.0) + google-cloud-env (1.0.5) + faraday (~> 0.11) + google-cloud-storage (1.16.0) + digest-crc (~> 0.4) + google-api-client (~> 0.23) + google-cloud-core (~> 1.2) + googleauth (>= 0.6.2, < 0.10.0) + googleauth (0.6.7) + faraday (~> 0.12) + jwt (>= 1.4, < 3.0) + memoist (~> 0.16) + multi_json (~> 1.11) + os (>= 0.9, < 2.0) + signet (~> 0.7) + highline (1.7.10) + http-cookie (1.0.3) + domain_name (~> 0.5) + httpclient (2.8.3) + i18n (0.9.5) + concurrent-ruby (~> 1.0) + json (2.2.0) + jwt (2.1.0) + memoist (0.16.0) + mime-types (3.2.2) + mime-types-data (~> 3.2015) + mime-types-data (3.2019.0331) + mini_magick (4.5.1) + minitest (5.11.3) + molinillo (0.6.6) + multi_json (1.13.1) + multi_xml (0.6.0) + multipart-post (2.0.0) + nanaimo (0.2.6) + nap (1.1.0) + naturally (2.2.0) + netrc (0.11.0) + os (1.0.1) + plist (3.5.0) + public_suffix (2.0.5) + representable (3.0.4) + declarative (< 0.1.0) + declarative-option (< 0.2.0) + uber (< 0.2.0) + retriable (3.1.2) + rouge (2.0.7) + ruby-macho (1.4.0) + rubyzip (1.2.2) + security (0.1.3) + signet (0.11.0) + addressable (~> 2.3) + faraday (~> 0.9) + jwt (>= 1.5, < 3.0) + multi_json (~> 1.10) + simctl (1.6.5) + CFPropertyList + naturally + slack-notifier (2.3.2) + terminal-notifier (2.0.0) + terminal-table (1.8.0) + unicode-display_width (~> 1.1, >= 1.1.1) + thread_safe (0.3.6) + tty-cursor (0.6.1) + tty-screen (0.6.5) + tty-spinner (0.9.0) + tty-cursor (~> 0.6.0) + tzinfo (1.2.5) + thread_safe (~> 0.1) + uber (0.1.0) + unf (0.1.4) + unf_ext + unf_ext (0.0.7.6) + unicode-display_width (1.5.0) + word_wrap (1.0.0) + xcodeproj (1.9.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.2.6) + xcpretty (0.3.0) + rouge (~> 2.0.7) + xcpretty-travis-formatter (1.0.0) + xcpretty (~> 0.2, >= 0.0.7) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods + fastlane + +BUNDLED WITH + 1.17.2 diff --git a/Carthage/Checkouts/Starscream/LICENSE b/Carthage/Checkouts/Starscream/LICENSE new file mode 100644 index 00000000..d6ab2f1f --- /dev/null +++ b/Carthage/Checkouts/Starscream/LICENSE @@ -0,0 +1,176 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + Copyright (c) 2014-2016 Dalton Cherry. + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. \ No newline at end of file diff --git a/Carthage/Checkouts/Starscream/Package.resolved b/Carthage/Checkouts/Starscream/Package.resolved new file mode 100644 index 00000000..e49c8be4 --- /dev/null +++ b/Carthage/Checkouts/Starscream/Package.resolved @@ -0,0 +1,16 @@ +{ + "object": { + "pins": [ + { + "package": "swift-nio-zlib-support", + "repositoryURL": "https://github.com/apple/swift-nio-zlib-support.git", + "state": { + "branch": null, + "revision": "37760e9a52030bb9011972c5213c3350fa9d41fd", + "version": "1.0.0" + } + } + ] + }, + "version": 1 +} diff --git a/Carthage/Checkouts/Starscream/Package.swift b/Carthage/Checkouts/Starscream/Package.swift new file mode 100644 index 00000000..06e4c202 --- /dev/null +++ b/Carthage/Checkouts/Starscream/Package.swift @@ -0,0 +1,36 @@ +// swift-tools-version:4.2 + +// +// Package.Swift +// Starscream +// +// Created by Dalton Cherry on 5/16/15. +// Copyright (c) 2014-2016 Dalton Cherry. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import PackageDescription + +let package = Package( + name: "Starscream", + products: [ + .library(name: "Starscream", targets: ["Starscream"]) + ], + dependencies: [ + .package(url: "https://github.com/apple/swift-nio-zlib-support.git", from: "1.0.0") + ], + targets: [ + .target(name: "Starscream") + ] +) diff --git a/Carthage/Checkouts/Starscream/README.md b/Carthage/Checkouts/Starscream/README.md new file mode 100644 index 00000000..90a7e0e6 --- /dev/null +++ b/Carthage/Checkouts/Starscream/README.md @@ -0,0 +1,438 @@ +![starscream](https://raw.githubusercontent.com/daltoniam/starscream/assets/starscream.jpg) + +Starscream is a conforming WebSocket ([RFC 6455](http://tools.ietf.org/html/rfc6455)) client library in Swift. + +Its Objective-C counterpart can be found here: [Jetfire](https://github.com/acmacalister/jetfire) + +## Features + +- Conforms to all of the base [Autobahn test suite](http://autobahn.ws/testsuite/). +- Nonblocking. Everything happens in the background, thanks to GCD. +- TLS/WSS support. +- Compression Extensions support ([RFC 7692](https://tools.ietf.org/html/rfc7692)) +- Simple concise codebase at just a few hundred LOC. + +## Example + +First thing is to import the framework. See the Installation instructions on how to add the framework to your project. + +```swift +import Starscream +``` + +Once imported, you can open a connection to your WebSocket server. Note that `socket` is probably best as a property, so it doesn't get deallocated right after being setup. + +```swift +socket = WebSocket(url: URL(string: "ws://localhost:8080/")!) +socket.delegate = self +socket.connect() +``` + +After you are connected, there are some delegate methods that we need to implement. + +### websocketDidConnect + +websocketDidConnect is called as soon as the client connects to the server. + +```swift +func websocketDidConnect(socket: WebSocketClient) { + print("websocket is connected") +} +``` + +### websocketDidDisconnect + +websocketDidDisconnect is called as soon as the client is disconnected from the server. + +```swift +func websocketDidDisconnect(socket: WebSocketClient, error: Error?) { + print("websocket is disconnected: \(error?.localizedDescription)") +} +``` + +### websocketDidReceiveMessage + +websocketDidReceiveMessage is called when the client gets a text frame from the connection. + +```swift +func websocketDidReceiveMessage(socket: WebSocketClient, text: String) { + print("got some text: \(text)") +} +``` + +### websocketDidReceiveData + +websocketDidReceiveData is called when the client gets a binary frame from the connection. + +```swift +func websocketDidReceiveData(socket: WebSocketClient, data: Data) { + print("got some data: \(data.count)") +} +``` + +### Optional: websocketDidReceivePong *(required protocol: WebSocketPongDelegate)* + +websocketDidReceivePong is called when the client gets a pong response from the connection. You need to implement the WebSocketPongDelegate protocol and set an additional delegate, eg: ` socket.pongDelegate = self` + +```swift +func websocketDidReceivePong(socket: WebSocketClient, data: Data?) { + print("Got pong! Maybe some data: \(data?.count)") +} +``` + +Or you can use closures. + +```swift +socket = WebSocket(url: URL(string: "ws://localhost:8080/")!) +//websocketDidConnect +socket.onConnect = { + print("websocket is connected") +} +//websocketDidDisconnect +socket.onDisconnect = { (error: Error?) in + print("websocket is disconnected: \(error?.localizedDescription)") +} +//websocketDidReceiveMessage +socket.onText = { (text: String) in + print("got some text: \(text)") +} +//websocketDidReceiveData +socket.onData = { (data: Data) in + print("got some data: \(data.count)") +} +//you could do onPong as well. +socket.connect() +``` + +One more: you can listen to socket connection and disconnection via notifications. Starscream posts `WebsocketDidConnectNotification` and `WebsocketDidDisconnectNotification`. You can find an `Error` that caused the disconection by accessing `WebsocketDisconnectionErrorKeyName` on notification `userInfo`. + + +## The delegate methods give you a simple way to handle data from the server, but how do you send data? + +### write a binary frame + +The writeData method gives you a simple way to send `Data` (binary) data to the server. + +```swift +socket.write(data: data) //write some Data over the socket! +``` + +### write a string frame + +The writeString method is the same as writeData, but sends text/string. + +```swift +socket.write(string: "Hi Server!") //example on how to write text over the socket! +``` + +### write a ping frame + +The writePing method is the same as write, but sends a ping control frame. + +```swift +socket.write(ping: Data()) //example on how to write a ping control frame over the socket! +``` + +### write a pong frame + + +the writePong method is the same as writePing, but sends a pong control frame. + +```swift +socket.write(pong: Data()) //example on how to write a pong control frame over the socket! +``` + +Starscream will automatically respond to incoming `ping` control frames so you do not need to manually send `pong`s. + +However if for some reason you need to control this process you can turn off the automatic `ping` response by disabling `respondToPingWithPong`. + +```swift +socket.respondToPingWithPong = false //Do not automaticaly respond to incoming pings with pongs. +``` + +In most cases you will not need to do this. + +### disconnect + +The disconnect method does what you would expect and closes the socket. + +```swift +socket.disconnect() +``` + +The socket can be forcefully closed, by specifying a timeout (in milliseconds). A timeout of zero will also close the socket immediately without waiting on the server. + +```swift +socket.disconnect(forceTimeout: 10, closeCode: CloseCode.normal.rawValue) +``` + +### isConnected + +Returns if the socket is connected or not. + +```swift +if socket.isConnected { + // do cool stuff. +} +``` + +### Custom Headers + +You can also override the default websocket headers with your own custom ones like so: + +```swift +var request = URLRequest(url: URL(string: "ws://localhost:8080/")!) +request.timeoutInterval = 5 +request.setValue("someother protocols", forHTTPHeaderField: "Sec-WebSocket-Protocol") +request.setValue("14", forHTTPHeaderField: "Sec-WebSocket-Version") +request.setValue("Everything is Awesome!", forHTTPHeaderField: "My-Awesome-Header") +let socket = WebSocket(request: request) +``` + +### Custom HTTP Method + +Your server may use a different HTTP method when connecting to the websocket: + +```swift +var request = URLRequest(url: URL(string: "ws://localhost:8080/")!) +request.httpMethod = "POST" +request.timeoutInterval = 5 +let socket = WebSocket(request: request) +``` + +### Protocols + +If you need to specify a protocol, simple add it to the init: + +```swift +//chat and superchat are the example protocols here +socket = WebSocket(url: URL(string: "ws://localhost:8080/")!, protocols: ["chat","superchat"]) +socket.delegate = self +socket.connect() +``` + +### Self Signed SSL + +```swift +socket = WebSocket(url: URL(string: "ws://localhost:8080/")!, protocols: ["chat","superchat"]) + +//set this if you want to ignore SSL cert validation, so a self signed SSL certificate can be used. +socket.disableSSLCertValidation = true +``` + +### SSL Pinning + +SSL Pinning is also supported in Starscream. + +```swift +socket = WebSocket(url: URL(string: "ws://localhost:8080/")!, protocols: ["chat","superchat"]) +let data = ... //load your certificate from disk +socket.security = SSLSecurity(certs: [SSLCert(data: data)], usePublicKeys: true) +//socket.security = SSLSecurity() //uses the .cer files in your app's bundle +``` +You load either a `Data` blob of your certificate or you can use a `SecKeyRef` if you have a public key you want to use. The `usePublicKeys` bool is whether to use the certificates for validation or the public keys. The public keys will be extracted from the certificates automatically if `usePublicKeys` is choosen. + +### SSL Cipher Suites + +To use an SSL encrypted connection, you need to tell Starscream about the cipher suites your server supports. + +```swift +socket = WebSocket(url: URL(string: "wss://localhost:8080/")!, protocols: ["chat","superchat"]) + +// Set enabled cipher suites to AES 256 and AES 128 +socket.enabledSSLCipherSuites = [TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256] +``` + +If you don't know which cipher suites are supported by your server, you can try pointing [SSL Labs](https://www.ssllabs.com/ssltest/) at it and checking the results. + +### Compression Extensions + +Compression Extensions ([RFC 7692](https://tools.ietf.org/html/rfc7692)) is supported in Starscream. Compression is enabled by default, however compression will only be used if it is supported by the server as well. You may enable or disable compression via the `.enableCompression` property: + +```swift +socket = WebSocket(url: URL(string: "ws://localhost:8080/")!) +socket.enableCompression = false +``` + +Compression should be disabled if your application is transmitting already-compressed, random, or other uncompressable data. + +### Custom Queue + +A custom queue can be specified when delegate methods are called. By default `DispatchQueue.main` is used, thus making all delegate methods calls run on the main thread. It is important to note that all WebSocket processing is done on a background thread, only the delegate method calls are changed when modifying the queue. The actual processing is always on a background thread and will not pause your app. + +```swift +socket = WebSocket(url: URL(string: "ws://localhost:8080/")!, protocols: ["chat","superchat"]) +//create a custom queue +socket.callbackQueue = DispatchQueue(label: "com.vluxe.starscream.myapp") +``` + +## Example Project + +Check out the SimpleTest project in the examples directory to see how to setup a simple connection to a WebSocket server. + +## Requirements + +Starscream works with iOS 7/OSX 10.9 or above. It is recommended to use iOS 8/10.10 or above for CocoaPods/framework support. To use Starscream with a project targeting iOS 7, you must include all Swift files directly in your project. + +## Installation + +### CocoaPods + +Check out [Get Started](http://cocoapods.org/) tab on [cocoapods.org](http://cocoapods.org/). + +To use Starscream in your project add the following 'Podfile' to your project + + source 'https://github.com/CocoaPods/Specs.git' + platform :ios, '9.0' + use_frameworks! + + pod 'Starscream', '~> 3.0.2' + +Then run: + + pod install + +### Carthage + +Check out the [Carthage](https://github.com/Carthage/Carthage) docs on how to add a install. The `Starscream` framework is already setup with shared schemes. + +[Carthage Install](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) + +You can install Carthage with [Homebrew](http://brew.sh/) using the following command: + +```bash +$ brew update +$ brew install carthage +``` + +To integrate Starscream into your Xcode project using Carthage, specify it in your `Cartfile`: + +``` +github "daltoniam/Starscream" >= 3.0.2 +``` + +### Accio + +Check out the [Accio](https://github.com/JamitLabs/Accio) docs on how to add a install. + +Add the following to your Package.swift: + +```swift +.package(url: "https://github.com/daltoniam/Starscream.git", .upToNextMajor(from: "3.1.0")), +``` + +Next, add `Starscream` to your App targets dependencies like so: + +```swift +.target( + name: "App", + dependencies: [ + "Starscream", + ] +), +``` + +Then run `accio update`. + +### Rogue + +First see the [installation docs](https://github.com/acmacalister/Rogue) for how to install Rogue. + +To install Starscream run the command below in the directory you created the rogue file. + +``` +rogue add https://github.com/daltoniam/Starscream +``` + +Next open the `libs` folder and add the `Starscream.xcodeproj` to your Xcode project. Once that is complete, in your "Build Phases" add the `Starscream.framework` to your "Link Binary with Libraries" phase. Make sure to add the `libs` folder to your `.gitignore` file. + +### Swift Package Manager + +The [Swift Package Manager](https://swift.org/package-manager/) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. + +Once you have your Swift package set up, adding Starscream as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`. + +```swift +dependencies: [ + .Package(url: "https://github.com/daltoniam/Starscream.git", majorVersion: 3) +] +``` + +### Other + +Simply grab the framework (either via git submodule or another package manager). + +Add the `Starscream.xcodeproj` to your Xcode project. Once that is complete, in your "Build Phases" add the `Starscream.framework` to your "Link Binary with Libraries" phase. + +### Add Copy Frameworks Phase + +If you are running this in an OSX app or on a physical iOS device you will need to make sure you add the `Starscream.framework` to be included in your app bundle. To do this, in Xcode, navigate to the target configuration window by clicking on the blue project icon, and selecting the application target under the "Targets" heading in the sidebar. In the tab bar at the top of that window, open the "Build Phases" panel. Expand the "Link Binary with Libraries" group, and add `Starscream.framework`. Click on the + button at the top left of the panel and select "New Copy Files Phase". Rename this new phase to "Copy Frameworks", set the "Destination" to "Frameworks", and add `Starscream.framework` respectively. + + +## WebSocketAdvancedDelegate +The advanced delegate acts just like the simpler delegate but provides some additional information on the connection and incoming frames. + +```swift +socket.advancedDelegate = self +``` + +In most cases you do not need the extra info and should use the normal delegate. + +#### websocketDidReceiveMessage +```swift +func websocketDidReceiveMessage(socket: WebSocketClient, text: String, response: WebSocket.WSResponse) { + print("got some text: \(text)") + print("First frame for this message arrived on \(response.firstFrame)") +} +``` + +#### websocketDidReceiveData +```swift +func websocketDidReceiveData(socket: WebSocketClient, data: Date, response: WebSocket.WSResponse) { + print("got some data it long: \(data.count)") + print("A total of \(response.frameCount) frames were used to send this data") +} +``` + +#### websocketHttpUpgrade +These methods are called when the HTTP upgrade request is sent and when the response returns. +```swift +func websocketHttpUpgrade(socket: WebSocketClient, request: CFHTTPMessage) { + print("the http request was sent we can check the raw http if we need to") +} +``` + +```swift +func websocketHttpUpgrade(socket: WebSocketClient, response: CFHTTPMessage) { + print("the http response has returned.") +} +``` + +## Swift versions + +* Swift 4.2 - 3.0.6 + +## KNOWN ISSUES +- WatchOS does not have the the CFNetwork String constants to modify the stream's SSL behavior. It will be the default Foundation SSL behavior. This means watchOS CANNOT use `SSLCiphers`, `disableSSLCertValidation`, or SSL pinning. All these values set on watchOS will do nothing. +- Linux does not have the security framework, so it CANNOT use SSL pinning or `SSLCiphers` either. + + +## TODOs + +- [ ] Add Unit Tests - Local WebSocket server that runs against Autobahn + +## License + +Starscream is licensed under the Apache v2 License. + +## Contact + +### Dalton Cherry +* https://github.com/daltoniam +* http://twitter.com/daltoniam +* http://daltoniam.com + +### Austin Cherry ### +* https://github.com/acmacalister +* http://twitter.com/acmacalister +* http://austincherry.me diff --git a/Carthage/Checkouts/Starscream/Sources/Info.plist b/Carthage/Checkouts/Starscream/Sources/Info.plist new file mode 100644 index 00000000..d353b3ef --- /dev/null +++ b/Carthage/Checkouts/Starscream/Sources/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + FMWK + CFBundleShortVersionString + 3.1.1 + CFBundleSignature + ???? + CFBundleVersion + $(CURRENT_PROJECT_VERSION) + NSPrincipalClass + + + diff --git a/Carthage/Checkouts/Starscream/Sources/Starscream.h b/Carthage/Checkouts/Starscream/Sources/Starscream.h new file mode 100644 index 00000000..38ff9dfb --- /dev/null +++ b/Carthage/Checkouts/Starscream/Sources/Starscream.h @@ -0,0 +1,19 @@ +// +// Starscream.h +// Starscream +// +// Created by Austin Cherry on 9/25/14. +// Copyright (c) 2014 Vluxe. All rights reserved. +// + +#import + +//! Project version number for Starscream. +FOUNDATION_EXPORT double StarscreamVersionNumber; + +//! Project version string for Starscream. +FOUNDATION_EXPORT const unsigned char StarscreamVersionString[]; + +// In this header, you should import all the public headers of your framework using statements like #import + + diff --git a/Carthage/Checkouts/Starscream/Sources/Starscream/Compression.swift b/Carthage/Checkouts/Starscream/Sources/Starscream/Compression.swift new file mode 100644 index 00000000..ab657902 --- /dev/null +++ b/Carthage/Checkouts/Starscream/Sources/Starscream/Compression.swift @@ -0,0 +1,177 @@ +////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Compression.swift +// +// Created by Joseph Ross on 7/16/14. +// Copyright © 2017 Joseph Ross. +// +// 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. +// +////////////////////////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Compression implementation is implemented in conformance with RFC 7692 Compression Extensions +// for WebSocket: https://tools.ietf.org/html/rfc7692 +// +////////////////////////////////////////////////////////////////////////////////////////////////// + +import Foundation +import zlib + +class Decompressor { + private var strm = z_stream() + private var buffer = [UInt8](repeating: 0, count: 0x2000) + private var inflateInitialized = false + private let windowBits:Int + + init?(windowBits:Int) { + self.windowBits = windowBits + guard initInflate() else { return nil } + } + + private func initInflate() -> Bool { + if Z_OK == inflateInit2_(&strm, -CInt(windowBits), + ZLIB_VERSION, CInt(MemoryLayout.size)) + { + inflateInitialized = true + return true + } + return false + } + + func reset() throws { + teardownInflate() + guard initInflate() else { throw WSError(type: .compressionError, message: "Error for decompressor on reset", code: 0) } + } + + func decompress(_ data: Data, finish: Bool) throws -> Data { + return try data.withUnsafeBytes { (bytes:UnsafePointer) -> Data in + return try decompress(bytes: bytes, count: data.count, finish: finish) + } + } + + func decompress(bytes: UnsafePointer, count: Int, finish: Bool) throws -> Data { + var decompressed = Data() + try decompress(bytes: bytes, count: count, out: &decompressed) + + if finish { + let tail:[UInt8] = [0x00, 0x00, 0xFF, 0xFF] + try decompress(bytes: tail, count: tail.count, out: &decompressed) + } + + return decompressed + + } + + private func decompress(bytes: UnsafePointer, count: Int, out:inout Data) throws { + var res:CInt = 0 + strm.next_in = UnsafeMutablePointer(mutating: bytes) + strm.avail_in = CUnsignedInt(count) + + repeat { + strm.next_out = UnsafeMutablePointer(&buffer) + strm.avail_out = CUnsignedInt(buffer.count) + + res = inflate(&strm, 0) + + let byteCount = buffer.count - Int(strm.avail_out) + out.append(buffer, count: byteCount) + } while res == Z_OK && strm.avail_out == 0 + + guard (res == Z_OK && strm.avail_out > 0) + || (res == Z_BUF_ERROR && Int(strm.avail_out) == buffer.count) + else { + throw WSError(type: .compressionError, message: "Error on decompressing", code: 0) + } + } + + private func teardownInflate() { + if inflateInitialized, Z_OK == inflateEnd(&strm) { + inflateInitialized = false + } + } + + deinit { + teardownInflate() + } +} + +class Compressor { + private var strm = z_stream() + private var buffer = [UInt8](repeating: 0, count: 0x2000) + private var deflateInitialized = false + private let windowBits:Int + + init?(windowBits: Int) { + self.windowBits = windowBits + guard initDeflate() else { return nil } + } + + private func initDeflate() -> Bool { + if Z_OK == deflateInit2_(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, + -CInt(windowBits), 8, Z_DEFAULT_STRATEGY, + ZLIB_VERSION, CInt(MemoryLayout.size)) + { + deflateInitialized = true + return true + } + return false + } + + func reset() throws { + teardownDeflate() + guard initDeflate() else { throw WSError(type: .compressionError, message: "Error for compressor on reset", code: 0) } + } + + func compress(_ data: Data) throws -> Data { + var compressed = Data() + var res:CInt = 0 + data.withUnsafeBytes { (ptr:UnsafePointer) -> Void in + strm.next_in = UnsafeMutablePointer(mutating: ptr) + strm.avail_in = CUnsignedInt(data.count) + + repeat { + strm.next_out = UnsafeMutablePointer(&buffer) + strm.avail_out = CUnsignedInt(buffer.count) + + res = deflate(&strm, Z_SYNC_FLUSH) + + let byteCount = buffer.count - Int(strm.avail_out) + compressed.append(buffer, count: byteCount) + } + while res == Z_OK && strm.avail_out == 0 + + } + + guard res == Z_OK && strm.avail_out > 0 + || (res == Z_BUF_ERROR && Int(strm.avail_out) == buffer.count) + else { + throw WSError(type: .compressionError, message: "Error on compressing", code: 0) + } + + compressed.removeLast(4) + return compressed + } + + private func teardownDeflate() { + if deflateInitialized, Z_OK == deflateEnd(&strm) { + deflateInitialized = false + } + } + + deinit { + teardownDeflate() + } +} + diff --git a/Carthage/Checkouts/Starscream/Sources/Starscream/SSLClientCertificate.swift b/Carthage/Checkouts/Starscream/Sources/Starscream/SSLClientCertificate.swift new file mode 100644 index 00000000..34109122 --- /dev/null +++ b/Carthage/Checkouts/Starscream/Sources/Starscream/SSLClientCertificate.swift @@ -0,0 +1,92 @@ +// +// SSLClientCertificate.swift +// Starscream +// +// Created by Tomasz Trela on 08/03/2018. +// Copyright © 2018 Vluxe. All rights reserved. +// + +import Foundation + +public struct SSLClientCertificateError: LocalizedError { + public var errorDescription: String? + + init(errorDescription: String) { + self.errorDescription = errorDescription + } +} + +public class SSLClientCertificate { + internal let streamSSLCertificates: NSArray + + /** + Convenience init. + - parameter pkcs12Path: Path to pkcs12 file containing private key and X.509 ceritifacte (.p12) + - parameter password: file password, see **kSecImportExportPassphrase** + */ + public convenience init(pkcs12Path: String, password: String) throws { + let pkcs12Url = URL(fileURLWithPath: pkcs12Path) + do { + try self.init(pkcs12Url: pkcs12Url, password: password) + } catch { + throw error + } + } + + /** + Designated init. For more information, see SSLSetCertificate() in Security/SecureTransport.h. + - parameter identity: SecIdentityRef, see **kCFStreamSSLCertificates** + - parameter identityCertificate: CFArray of SecCertificateRefs, see **kCFStreamSSLCertificates** + */ + public init(identity: SecIdentity, identityCertificate: SecCertificate) { + self.streamSSLCertificates = NSArray(objects: identity, identityCertificate) + } + + /** + Convenience init. + - parameter pkcs12Url: URL to pkcs12 file containing private key and X.509 ceritifacte (.p12) + - parameter password: file password, see **kSecImportExportPassphrase** + */ + public convenience init(pkcs12Url: URL, password: String) throws { + let importOptions = [kSecImportExportPassphrase as String : password] as CFDictionary + do { + try self.init(pkcs12Url: pkcs12Url, importOptions: importOptions) + } catch { + throw error + } + } + + /** + Designated init. + - parameter pkcs12Url: URL to pkcs12 file containing private key and X.509 ceritifacte (.p12) + - parameter importOptions: A dictionary containing import options. A + kSecImportExportPassphrase entry is required at minimum. Only password-based + PKCS12 blobs are currently supported. See **SecImportExport.h** + */ + public init(pkcs12Url: URL, importOptions: CFDictionary) throws { + do { + let pkcs12Data = try Data(contentsOf: pkcs12Url) + var rawIdentitiesAndCertificates: CFArray? + let pkcs12CFData: CFData = pkcs12Data as CFData + let importStatus = SecPKCS12Import(pkcs12CFData, importOptions, &rawIdentitiesAndCertificates) + + guard importStatus == errSecSuccess else { + throw SSLClientCertificateError(errorDescription: "(Starscream) Error during 'SecPKCS12Import', see 'SecBase.h' - OSStatus: \(importStatus)") + } + guard let identitiyAndCertificate = (rawIdentitiesAndCertificates as? Array>)?.first else { + throw SSLClientCertificateError(errorDescription: "(Starscream) Error - PKCS12 file is empty") + } + + let identity = identitiyAndCertificate[kSecImportItemIdentity as String] as! SecIdentity + var identityCertificate: SecCertificate? + let copyStatus = SecIdentityCopyCertificate(identity, &identityCertificate) + guard copyStatus == errSecSuccess else { + throw SSLClientCertificateError(errorDescription: "(Starscream) Error during 'SecIdentityCopyCertificate', see 'SecBase.h' - OSStatus: \(copyStatus)") + } + self.streamSSLCertificates = NSArray(objects: identity, identityCertificate!) + } catch { + throw error + } + } +} + diff --git a/Carthage/Checkouts/Starscream/Sources/Starscream/SSLSecurity.swift b/Carthage/Checkouts/Starscream/Sources/Starscream/SSLSecurity.swift new file mode 100644 index 00000000..6a14dd15 --- /dev/null +++ b/Carthage/Checkouts/Starscream/Sources/Starscream/SSLSecurity.swift @@ -0,0 +1,266 @@ +////////////////////////////////////////////////////////////////////////////////////////////////// +// +// SSLSecurity.swift +// Starscream +// +// Created by Dalton Cherry on 5/16/15. +// Copyright (c) 2014-2016 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. +// +////////////////////////////////////////////////////////////////////////////////////////////////// +#if os(Linux) +#else +import Foundation +import Security + +public protocol SSLTrustValidator { + func isValid(_ trust: SecTrust, domain: String?) -> Bool +} + +open class SSLCert { + var certData: Data? + var key: SecKey? + + /** + Designated init for certificates + + - parameter data: is the binary data of the certificate + + - returns: a representation security object to be used with + */ + public init(data: Data) { + self.certData = data + } + + /** + Designated init for public keys + + - parameter key: is the public key to be used + + - returns: a representation security object to be used with + */ + public init(key: SecKey) { + self.key = key + } +} + +open class SSLSecurity : SSLTrustValidator { + public var validatedDN = true //should the domain name be validated? + public var validateEntireChain = true //should the entire cert chain be validated + + var isReady = false //is the key processing done? + var certificates: [Data]? //the certificates + var pubKeys: [SecKey]? //the public keys + var usePublicKeys = false //use public keys or certificate validation? + + /** + Use certs from main app bundle + + - parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation + + - returns: a representation security object to be used with + */ + public convenience init(usePublicKeys: Bool = false) { + let paths = Bundle.main.paths(forResourcesOfType: "cer", inDirectory: ".") + + let certs = paths.reduce([SSLCert]()) { (certs: [SSLCert], path: String) -> [SSLCert] in + var certs = certs + if let data = NSData(contentsOfFile: path) { + certs.append(SSLCert(data: data as Data)) + } + return certs + } + + self.init(certs: certs, usePublicKeys: usePublicKeys) + } + + /** + Designated init + + - parameter certs: is the certificates or public keys to use + - parameter usePublicKeys: is to specific if the publicKeys or certificates should be used for SSL pinning validation + + - returns: a representation security object to be used with + */ + public init(certs: [SSLCert], usePublicKeys: Bool) { + self.usePublicKeys = usePublicKeys + + if self.usePublicKeys { + DispatchQueue.global(qos: .default).async { + let pubKeys = certs.reduce([SecKey]()) { (pubKeys: [SecKey], cert: SSLCert) -> [SecKey] in + var pubKeys = pubKeys + if let data = cert.certData, cert.key == nil { + cert.key = self.extractPublicKey(data) + } + if let key = cert.key { + pubKeys.append(key) + } + return pubKeys + } + + self.pubKeys = pubKeys + self.isReady = true + } + } else { + let certificates = certs.reduce([Data]()) { (certificates: [Data], cert: SSLCert) -> [Data] in + var certificates = certificates + if let data = cert.certData { + certificates.append(data) + } + return certificates + } + self.certificates = certificates + self.isReady = true + } + } + + /** + Valid the trust and domain name. + + - parameter trust: is the serverTrust to validate + - parameter domain: is the CN domain to validate + + - returns: if the key was successfully validated + */ + open func isValid(_ trust: SecTrust, domain: String?) -> Bool { + + var tries = 0 + while !self.isReady { + usleep(1000) + tries += 1 + if tries > 5 { + return false //doesn't appear it is going to ever be ready... + } + } + var policy: SecPolicy + if self.validatedDN { + policy = SecPolicyCreateSSL(true, domain as NSString?) + } else { + policy = SecPolicyCreateBasicX509() + } + SecTrustSetPolicies(trust,policy) + if self.usePublicKeys { + if let keys = self.pubKeys { + let serverPubKeys = publicKeyChain(trust) + for serverKey in serverPubKeys as [AnyObject] { + for key in keys as [AnyObject] { + if serverKey.isEqual(key) { + return true + } + } + } + } + } else if let certs = self.certificates { + let serverCerts = certificateChain(trust) + var collect = [SecCertificate]() + for cert in certs { + collect.append(SecCertificateCreateWithData(nil,cert as CFData)!) + } + SecTrustSetAnchorCertificates(trust,collect as NSArray) + var result: SecTrustResultType = .unspecified + SecTrustEvaluate(trust,&result) + if result == .unspecified || result == .proceed { + if !validateEntireChain { + return true + } + var trustedCount = 0 + for serverCert in serverCerts { + for cert in certs { + if cert == serverCert { + trustedCount += 1 + break + } + } + } + if trustedCount == serverCerts.count { + return true + } + } + } + return false + } + + /** + Get the public key from a certificate data + + - parameter data: is the certificate to pull the public key from + + - returns: a public key + */ + public func extractPublicKey(_ data: Data) -> SecKey? { + guard let cert = SecCertificateCreateWithData(nil, data as CFData) else { return nil } + + return extractPublicKey(cert, policy: SecPolicyCreateBasicX509()) + } + + /** + Get the public key from a certificate + + - parameter data: is the certificate to pull the public key from + + - returns: a public key + */ + public func extractPublicKey(_ cert: SecCertificate, policy: SecPolicy) -> SecKey? { + var possibleTrust: SecTrust? + SecTrustCreateWithCertificates(cert, policy, &possibleTrust) + + guard let trust = possibleTrust else { return nil } + var result: SecTrustResultType = .unspecified + SecTrustEvaluate(trust, &result) + return SecTrustCopyPublicKey(trust) + } + + /** + Get the certificate chain for the trust + + - parameter trust: is the trust to lookup the certificate chain for + + - returns: the certificate chain for the trust + */ + public func certificateChain(_ trust: SecTrust) -> [Data] { + let certificates = (0.. [Data] in + var certificates = certificates + let cert = SecTrustGetCertificateAtIndex(trust, index) + certificates.append(SecCertificateCopyData(cert!) as Data) + return certificates + } + + return certificates + } + + /** + Get the public key chain for the trust + + - parameter trust: is the trust to lookup the certificate chain and extract the public keys + + - returns: the public keys from the certifcate chain for the trust + */ + public func publicKeyChain(_ trust: SecTrust) -> [SecKey] { + let policy = SecPolicyCreateBasicX509() + let keys = (0.. [SecKey] in + var keys = keys + let cert = SecTrustGetCertificateAtIndex(trust, index) + if let key = extractPublicKey(cert!, policy: policy) { + keys.append(key) + } + + return keys + } + + return keys + } + + +} +#endif diff --git a/Carthage/Checkouts/Starscream/Sources/Starscream/WebSocket.swift b/Carthage/Checkouts/Starscream/Sources/Starscream/WebSocket.swift new file mode 100644 index 00000000..7d48a20d --- /dev/null +++ b/Carthage/Checkouts/Starscream/Sources/Starscream/WebSocket.swift @@ -0,0 +1,1356 @@ +////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Websocket.swift +// +// Created by Dalton Cherry on 7/16/14. +// Copyright (c) 2014-2017 Dalton Cherry. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +////////////////////////////////////////////////////////////////////////////////////////////////// + +import Foundation +import CoreFoundation +import CommonCrypto + +public let WebsocketDidConnectNotification = "WebsocketDidConnectNotification" +public let WebsocketDidDisconnectNotification = "WebsocketDidDisconnectNotification" +public let WebsocketDisconnectionErrorKeyName = "WebsocketDisconnectionErrorKeyName" + +//Standard WebSocket close codes +public enum CloseCode : UInt16 { + case normal = 1000 + case goingAway = 1001 + case protocolError = 1002 + case protocolUnhandledType = 1003 + // 1004 reserved. + case noStatusReceived = 1005 + //1006 reserved. + case encoding = 1007 + case policyViolated = 1008 + case messageTooBig = 1009 +} + +public enum ErrorType: Error { + case outputStreamWriteError //output stream error during write + case compressionError + case invalidSSLError //Invalid SSL certificate + case writeTimeoutError //The socket timed out waiting to be ready to write + case protocolError //There was an error parsing the WebSocket frames + case upgradeError //There was an error during the HTTP upgrade + case closeError //There was an error during the close (socket probably has been dereferenced) +} + +public struct WSError: Error { + public let type: ErrorType + public let message: String + public let code: Int +} + +//WebSocketClient is setup to be dependency injection for testing +public protocol WebSocketClient: class { + var delegate: WebSocketDelegate? {get set} + var pongDelegate: WebSocketPongDelegate? {get set} + var disableSSLCertValidation: Bool {get set} + var overrideTrustHostname: Bool {get set} + var desiredTrustHostname: String? {get set} + var sslClientCertificate: SSLClientCertificate? {get set} + #if os(Linux) + #else + var security: SSLTrustValidator? {get set} + var enabledSSLCipherSuites: [SSLCipherSuite]? {get set} + #endif + var isConnected: Bool {get} + + func connect() + func disconnect(forceTimeout: TimeInterval?, closeCode: UInt16) + func write(string: String, completion: (() -> ())?) + func write(data: Data, completion: (() -> ())?) + func write(ping: Data, completion: (() -> ())?) + func write(pong: Data, completion: (() -> ())?) +} + +//implements some of the base behaviors +extension WebSocketClient { + public func write(string: String) { + write(string: string, completion: nil) + } + + public func write(data: Data) { + write(data: data, completion: nil) + } + + public func write(ping: Data) { + write(ping: ping, completion: nil) + } + + public func write(pong: Data) { + write(pong: pong, completion: nil) + } + + public func disconnect() { + disconnect(forceTimeout: nil, closeCode: CloseCode.normal.rawValue) + } +} + +//SSL settings for the stream +public struct SSLSettings { + public let useSSL: Bool + public let disableCertValidation: Bool + public var overrideTrustHostname: Bool + public var desiredTrustHostname: String? + public let sslClientCertificate: SSLClientCertificate? + #if os(Linux) + #else + public let cipherSuites: [SSLCipherSuite]? + #endif +} + +public protocol WSStreamDelegate: class { + func newBytesInStream() + func streamDidError(error: Error?) +} + +//This protocol is to allow custom implemention of the underlining stream. This way custom socket libraries (e.g. linux) can be used +public protocol WSStream { + var delegate: WSStreamDelegate? {get set} + func connect(url: URL, port: Int, timeout: TimeInterval, ssl: SSLSettings, completion: @escaping ((Error?) -> Void)) + func write(data: Data) -> Int + func read() -> Data? + func cleanup() + #if os(Linux) || os(watchOS) + #else + func sslTrust() -> (trust: SecTrust?, domain: String?) + #endif +} + +open class FoundationStream : NSObject, WSStream, StreamDelegate { + private let workQueue = DispatchQueue(label: "com.vluxe.starscream.websocket", attributes: []) + private var inputStream: InputStream? + private var outputStream: OutputStream? + public weak var delegate: WSStreamDelegate? + let BUFFER_MAX = 4096 + + public var enableSOCKSProxy = false + + public func connect(url: URL, port: Int, timeout: TimeInterval, ssl: SSLSettings, completion: @escaping ((Error?) -> Void)) { + var readStream: Unmanaged? + var writeStream: Unmanaged? + let h = url.host! as NSString + CFStreamCreatePairWithSocketToHost(nil, h, UInt32(port), &readStream, &writeStream) + inputStream = readStream!.takeRetainedValue() + outputStream = writeStream!.takeRetainedValue() + + #if os(watchOS) //watchOS us unfortunately is missing the kCFStream properties to make this work + #else + if enableSOCKSProxy { + let proxyDict = CFNetworkCopySystemProxySettings() + let socksConfig = CFDictionaryCreateMutableCopy(nil, 0, proxyDict!.takeRetainedValue()) + let propertyKey = CFStreamPropertyKey(rawValue: kCFStreamPropertySOCKSProxy) + CFWriteStreamSetProperty(outputStream, propertyKey, socksConfig) + CFReadStreamSetProperty(inputStream, propertyKey, socksConfig) + } + #endif + + guard let inStream = inputStream, let outStream = outputStream else { return } + inStream.delegate = self + outStream.delegate = self + if ssl.useSSL { + inStream.setProperty(StreamSocketSecurityLevel.negotiatedSSL as AnyObject, forKey: Stream.PropertyKey.socketSecurityLevelKey) + outStream.setProperty(StreamSocketSecurityLevel.negotiatedSSL as AnyObject, forKey: Stream.PropertyKey.socketSecurityLevelKey) + #if os(watchOS) //watchOS us unfortunately is missing the kCFStream properties to make this work + #else + var settings = [NSObject: NSObject]() + if ssl.disableCertValidation { + settings[kCFStreamSSLValidatesCertificateChain] = NSNumber(value: false) + } + if ssl.overrideTrustHostname { + if let hostname = ssl.desiredTrustHostname { + settings[kCFStreamSSLPeerName] = hostname as NSString + } else { + settings[kCFStreamSSLPeerName] = kCFNull + } + } + if let sslClientCertificate = ssl.sslClientCertificate { + settings[kCFStreamSSLCertificates] = sslClientCertificate.streamSSLCertificates + } + + inStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as Stream.PropertyKey) + outStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as Stream.PropertyKey) + #endif + + #if os(Linux) + #else + if let cipherSuites = ssl.cipherSuites { + #if os(watchOS) //watchOS us unfortunately is missing the kCFStream properties to make this work + #else + if let sslContextIn = CFReadStreamCopyProperty(inputStream, CFStreamPropertyKey(rawValue: kCFStreamPropertySSLContext)) as! SSLContext?, + let sslContextOut = CFWriteStreamCopyProperty(outputStream, CFStreamPropertyKey(rawValue: kCFStreamPropertySSLContext)) as! SSLContext? { + let resIn = SSLSetEnabledCiphers(sslContextIn, cipherSuites, cipherSuites.count) + let resOut = SSLSetEnabledCiphers(sslContextOut, cipherSuites, cipherSuites.count) + if resIn != errSecSuccess { + completion(WSError(type: .invalidSSLError, message: "Error setting ingoing cypher suites", code: Int(resIn))) + } + if resOut != errSecSuccess { + completion(WSError(type: .invalidSSLError, message: "Error setting outgoing cypher suites", code: Int(resOut))) + } + } + #endif + } + #endif + } + + CFReadStreamSetDispatchQueue(inStream, workQueue) + CFWriteStreamSetDispatchQueue(outStream, workQueue) + inStream.open() + outStream.open() + + var out = timeout// wait X seconds before giving up + workQueue.async { [weak self] in + while !outStream.hasSpaceAvailable { + usleep(100) // wait until the socket is ready + out -= 100 + if out < 0 { + completion(WSError(type: .writeTimeoutError, message: "Timed out waiting for the socket to be ready for a write", code: 0)) + return + } else if let error = outStream.streamError { + completion(error) + return // disconnectStream will be called. + } else if self == nil { + completion(WSError(type: .closeError, message: "socket object has been dereferenced", code: 0)) + return + } + } + completion(nil) //success! + } + } + + public func write(data: Data) -> Int { + guard let outStream = outputStream else {return -1} + let buffer = UnsafeRawPointer((data as NSData).bytes).assumingMemoryBound(to: UInt8.self) + return outStream.write(buffer, maxLength: data.count) + } + + public func read() -> Data? { + guard let stream = inputStream else {return nil} + let buf = NSMutableData(capacity: BUFFER_MAX) + let buffer = UnsafeMutableRawPointer(mutating: buf!.bytes).assumingMemoryBound(to: UInt8.self) + let length = stream.read(buffer, maxLength: BUFFER_MAX) + if length < 1 { + return nil + } + return Data(bytes: buffer, count: length) + } + + public func cleanup() { + if let stream = inputStream { + stream.delegate = nil + CFReadStreamSetDispatchQueue(stream, nil) + stream.close() + } + if let stream = outputStream { + stream.delegate = nil + CFWriteStreamSetDispatchQueue(stream, nil) + stream.close() + } + outputStream = nil + inputStream = nil + } + + #if os(Linux) || os(watchOS) + #else + public func sslTrust() -> (trust: SecTrust?, domain: String?) { + guard let outputStream = outputStream else { return (nil, nil) } + + let trust = outputStream.property(forKey: kCFStreamPropertySSLPeerTrust as Stream.PropertyKey) as! SecTrust? + var domain = outputStream.property(forKey: kCFStreamSSLPeerName as Stream.PropertyKey) as! String? + if domain == nil, + let sslContextOut = CFWriteStreamCopyProperty(outputStream, CFStreamPropertyKey(rawValue: kCFStreamPropertySSLContext)) as! SSLContext? { + var peerNameLen: Int = 0 + SSLGetPeerDomainNameLength(sslContextOut, &peerNameLen) + var peerName = Data(count: peerNameLen) + let _ = peerName.withUnsafeMutableBytes { (peerNamePtr: UnsafeMutablePointer) in + SSLGetPeerDomainName(sslContextOut, peerNamePtr, &peerNameLen) + } + if let peerDomain = String(bytes: peerName, encoding: .utf8), peerDomain.count > 0 { + domain = peerDomain + } + } + + return (trust, domain) + } + #endif + + /** + Delegate for the stream methods. Processes incoming bytes + */ + open func stream(_ aStream: Stream, handle eventCode: Stream.Event) { + if eventCode == .hasBytesAvailable { + if aStream == inputStream { + delegate?.newBytesInStream() + } + } else if eventCode == .errorOccurred { + delegate?.streamDidError(error: aStream.streamError) + } else if eventCode == .endEncountered { + delegate?.streamDidError(error: nil) + } + } +} + +//WebSocket implementation + +//standard delegate you should use +public protocol WebSocketDelegate: class { + func websocketDidConnect(socket: WebSocketClient) + func websocketDidDisconnect(socket: WebSocketClient, error: Error?) + func websocketDidReceiveMessage(socket: WebSocketClient, text: String) + func websocketDidReceiveData(socket: WebSocketClient, data: Data) +} + +//got pongs +public protocol WebSocketPongDelegate: class { + func websocketDidReceivePong(socket: WebSocketClient, data: Data?) +} + +// A Delegate with more advanced info on messages and connection etc. +public protocol WebSocketAdvancedDelegate: class { + func websocketDidConnect(socket: WebSocket) + func websocketDidDisconnect(socket: WebSocket, error: Error?) + func websocketDidReceiveMessage(socket: WebSocket, text: String, response: WebSocket.WSResponse) + func websocketDidReceiveData(socket: WebSocket, data: Data, response: WebSocket.WSResponse) + func websocketHttpUpgrade(socket: WebSocket, request: String) + func websocketHttpUpgrade(socket: WebSocket, response: String) +} + + +open class WebSocket : NSObject, StreamDelegate, WebSocketClient, WSStreamDelegate { + + public enum OpCode : UInt8 { + case continueFrame = 0x0 + case textFrame = 0x1 + case binaryFrame = 0x2 + // 3-7 are reserved. + case connectionClose = 0x8 + case ping = 0x9 + case pong = 0xA + // B-F reserved. + } + + public static let ErrorDomain = "WebSocket" + + // Where the callback is executed. It defaults to the main UI thread queue. + public var callbackQueue = DispatchQueue.main + + // MARK: - Constants + + let headerWSUpgradeName = "Upgrade" + let headerWSUpgradeValue = "websocket" + let headerWSHostName = "Host" + let headerWSConnectionName = "Connection" + let headerWSConnectionValue = "Upgrade" + let headerWSProtocolName = "Sec-WebSocket-Protocol" + let headerWSVersionName = "Sec-WebSocket-Version" + let headerWSVersionValue = "13" + let headerWSExtensionName = "Sec-WebSocket-Extensions" + let headerWSKeyName = "Sec-WebSocket-Key" + let headerOriginName = "Origin" + let headerWSAcceptName = "Sec-WebSocket-Accept" + let BUFFER_MAX = 4096 + let FinMask: UInt8 = 0x80 + let OpCodeMask: UInt8 = 0x0F + let RSVMask: UInt8 = 0x70 + let RSV1Mask: UInt8 = 0x40 + let MaskMask: UInt8 = 0x80 + let PayloadLenMask: UInt8 = 0x7F + let MaxFrameSize: Int = 32 + let httpSwitchProtocolCode = 101 + let supportedSSLSchemes = ["wss", "https"] + + public class WSResponse { + var isFin = false + public var code: OpCode = .continueFrame + var bytesLeft = 0 + public var frameCount = 0 + public var buffer: NSMutableData? + public let firstFrame = { + return Date() + }() + } + + // MARK: - Delegates + + /// Responds to callback about new messages coming in over the WebSocket + /// and also connection/disconnect messages. + public weak var delegate: WebSocketDelegate? + + /// The optional advanced delegate can be used instead of of the delegate + public weak var advancedDelegate: WebSocketAdvancedDelegate? + + /// Receives a callback for each pong message recived. + public weak var pongDelegate: WebSocketPongDelegate? + + public var onConnect: (() -> Void)? + public var onDisconnect: ((Error?) -> Void)? + public var onText: ((String) -> Void)? + public var onData: ((Data) -> Void)? + public var onPong: ((Data?) -> Void)? + public var onHttpResponseHeaders: (([String: String]) -> Void)? + + public var disableSSLCertValidation = false + public var overrideTrustHostname = false + public var desiredTrustHostname: String? = nil + public var sslClientCertificate: SSLClientCertificate? = nil + + public var enableCompression = true + #if os(Linux) + #else + public var security: SSLTrustValidator? + public var enabledSSLCipherSuites: [SSLCipherSuite]? + #endif + + public var isConnected: Bool { + mutex.lock() + let isConnected = connected + mutex.unlock() + return isConnected + } + public var request: URLRequest //this is only public to allow headers, timeout, etc to be modified on reconnect + public var currentURL: URL { return request.url! } + + public var respondToPingWithPong: Bool = true + + // MARK: - Private + + private struct CompressionState { + var supportsCompression = false + var messageNeedsDecompression = false + var serverMaxWindowBits = 15 + var clientMaxWindowBits = 15 + var clientNoContextTakeover = false + var serverNoContextTakeover = false + var decompressor:Decompressor? = nil + var compressor:Compressor? = nil + } + + private var stream: WSStream + private var connected = false + private var isConnecting = false + private let mutex = NSLock() + private var compressionState = CompressionState() + private var writeQueue = OperationQueue() + private var readStack = [WSResponse]() + private var inputQueue = [Data]() + private var fragBuffer: Data? + private var certValidated = false + private var didDisconnect = false + private var readyToWrite = false + private var headerSecKey = "" + private var canDispatch: Bool { + mutex.lock() + let canWork = readyToWrite + mutex.unlock() + return canWork + } + + /// Used for setting protocols. + public init(request: URLRequest, protocols: [String]? = nil, stream: WSStream = FoundationStream()) { + self.request = request + self.stream = stream + if request.value(forHTTPHeaderField: headerOriginName) == nil { + guard let url = request.url else {return} + var origin = url.absoluteString + if let hostUrl = URL (string: "/", relativeTo: url) { + origin = hostUrl.absoluteString + origin.remove(at: origin.index(before: origin.endIndex)) + } + self.request.setValue(origin, forHTTPHeaderField: headerOriginName) + } + if let protocols = protocols, !protocols.isEmpty { + self.request.setValue(protocols.joined(separator: ","), forHTTPHeaderField: headerWSProtocolName) + } + writeQueue.maxConcurrentOperationCount = 1 + } + + public convenience init(url: URL, protocols: [String]? = nil) { + var request = URLRequest(url: url) + request.timeoutInterval = 5 + self.init(request: request, protocols: protocols) + } + + // Used for specifically setting the QOS for the write queue. + public convenience init(url: URL, writeQueueQOS: QualityOfService, protocols: [String]? = nil) { + self.init(url: url, protocols: protocols) + writeQueue.qualityOfService = writeQueueQOS + } + + /** + Connect to the WebSocket server on a background thread. + */ + open func connect() { + guard !isConnecting else { return } + didDisconnect = false + isConnecting = true + createHTTPRequest() + } + + /** + Disconnect from the server. I send a Close control frame to the server, then expect the server to respond with a Close control frame and close the socket from its end. I notify my delegate once the socket has been closed. + + If you supply a non-nil `forceTimeout`, I wait at most that long (in seconds) for the server to close the socket. After the timeout expires, I close the socket and notify my delegate. + + If you supply a zero (or negative) `forceTimeout`, I immediately close the socket (without sending a Close control frame) and notify my delegate. + + - Parameter forceTimeout: Maximum time to wait for the server to close the socket. + - Parameter closeCode: The code to send on disconnect. The default is the normal close code for cleanly disconnecting a webSocket. + */ + open func disconnect(forceTimeout: TimeInterval? = nil, closeCode: UInt16 = CloseCode.normal.rawValue) { + guard isConnected else { return } + switch forceTimeout { + case .some(let seconds) where seconds > 0: + let milliseconds = Int(seconds * 1_000) + callbackQueue.asyncAfter(deadline: .now() + .milliseconds(milliseconds)) { [weak self] in + self?.disconnectStream(nil) + } + fallthrough + case .none: + writeError(closeCode) + default: + disconnectStream(nil) + break + } + } + + /** + Write a string to the websocket. This sends it as a text frame. + + If you supply a non-nil completion block, I will perform it when the write completes. + + - parameter string: The string to write. + - parameter completion: The (optional) completion handler. + */ + open func write(string: String, completion: (() -> ())? = nil) { + guard isConnected else { return } + dequeueWrite(string.data(using: String.Encoding.utf8)!, code: .textFrame, writeCompletion: completion) + } + + /** + Write binary data to the websocket. This sends it as a binary frame. + + If you supply a non-nil completion block, I will perform it when the write completes. + + - parameter data: The data to write. + - parameter completion: The (optional) completion handler. + */ + open func write(data: Data, completion: (() -> ())? = nil) { + guard isConnected else { return } + dequeueWrite(data, code: .binaryFrame, writeCompletion: completion) + } + + /** + Write a ping to the websocket. This sends it as a control frame. + Yodel a sound to the planet. This sends it as an astroid. http://youtu.be/Eu5ZJELRiJ8?t=42s + */ + open func write(ping: Data, completion: (() -> ())? = nil) { + guard isConnected else { return } + dequeueWrite(ping, code: .ping, writeCompletion: completion) + } + + /** + Write a pong to the websocket. This sends it as a control frame. + Respond to a Yodel. + */ + open func write(pong: Data, completion: (() -> ())? = nil) { + guard isConnected else { return } + dequeueWrite(pong, code: .pong, writeCompletion: completion) + } + + /** + Private method that starts the connection. + */ + private func createHTTPRequest() { + guard let url = request.url else {return} + var port = url.port + if port == nil { + if supportedSSLSchemes.contains(url.scheme!) { + port = 443 + } else { + port = 80 + } + } + request.setValue(headerWSUpgradeValue, forHTTPHeaderField: headerWSUpgradeName) + request.setValue(headerWSConnectionValue, forHTTPHeaderField: headerWSConnectionName) + headerSecKey = generateWebSocketKey() + request.setValue(headerWSVersionValue, forHTTPHeaderField: headerWSVersionName) + request.setValue(headerSecKey, forHTTPHeaderField: headerWSKeyName) + + if enableCompression { + let val = "permessage-deflate; client_max_window_bits; server_max_window_bits=15" + request.setValue(val, forHTTPHeaderField: headerWSExtensionName) + } + let hostValue = request.allHTTPHeaderFields?[headerWSHostName] ?? "\(url.host!):\(port!)" + request.setValue(hostValue, forHTTPHeaderField: headerWSHostName) + + var path = url.absoluteString + let offset = (url.scheme?.count ?? 2) + 3 + path = String(path[path.index(path.startIndex, offsetBy: offset).. String { + var key = "" + let seed = 16 + for _ in 0.., bufferLen: Int) { + let code = processHTTP(buffer, bufferLen: bufferLen) + switch code { + case 0: + break + case -1: + fragBuffer = Data(bytes: buffer, count: bufferLen) + break // do nothing, we are going to collect more data + default: + doDisconnect(WSError(type: .upgradeError, message: "Invalid HTTP upgrade", code: code)) + } + } + + /** + Finds the HTTP Packet in the TCP stream, by looking for the CRLF. + */ + private func processHTTP(_ buffer: UnsafePointer, bufferLen: Int) -> Int { + let CRLFBytes = [UInt8(ascii: "\r"), UInt8(ascii: "\n"), UInt8(ascii: "\r"), UInt8(ascii: "\n")] + var k = 0 + var totalSize = 0 + for i in 0.. 0 { + let code = validateResponse(buffer, bufferLen: totalSize) + if code != 0 { + return code + } + isConnecting = false + mutex.lock() + connected = true + mutex.unlock() + didDisconnect = false + if canDispatch { + callbackQueue.async { [weak self] in + guard let self = self else { return } + self.onConnect?() + self.delegate?.websocketDidConnect(socket: self) + self.advancedDelegate?.websocketDidConnect(socket: self) + NotificationCenter.default.post(name: NSNotification.Name(WebsocketDidConnectNotification), object: self) + } + } + //totalSize += 1 //skip the last \n + let restSize = bufferLen - totalSize + if restSize > 0 { + processRawMessagesInBuffer(buffer + totalSize, bufferLen: restSize) + } + return 0 //success + } + return -1 // Was unable to find the full TCP header. + } + + /** + Validates the HTTP is a 101 as per the RFC spec. + */ + private func validateResponse(_ buffer: UnsafePointer, bufferLen: Int) -> Int { + guard let str = String(data: Data(bytes: buffer, count: bufferLen), encoding: .utf8) else { return -1 } + let splitArr = str.components(separatedBy: "\r\n") + var code = -1 + var i = 0 + var headers = [String: String]() + for str in splitArr { + if i == 0 { + let responseSplit = str.components(separatedBy: .whitespaces) + guard responseSplit.count > 1 else { return -1 } + if let c = Int(responseSplit[1]) { + code = c + } + } else { + let responseSplit = str.components(separatedBy: ":") + guard responseSplit.count > 1 else { break } + let key = responseSplit[0].trimmingCharacters(in: .whitespaces) + let val = responseSplit[1].trimmingCharacters(in: .whitespaces) + headers[key.lowercased()] = val + } + i += 1 + } + advancedDelegate?.websocketHttpUpgrade(socket: self, response: str) + onHttpResponseHeaders?(headers) + if code != httpSwitchProtocolCode { + return code + } + + if let extensionHeader = headers[headerWSExtensionName.lowercased()] { + processExtensionHeader(extensionHeader) + } + + if let acceptKey = headers[headerWSAcceptName.lowercased()] { + if acceptKey.count > 0 { + if headerSecKey.count > 0 { + let sha = "\(headerSecKey)258EAFA5-E914-47DA-95CA-C5AB0DC85B11".sha1Base64() + if sha != acceptKey as String { + return -1 + } + } + return 0 + } + } + return -1 + } + + /** + Parses the extension header, setting up the compression parameters. + */ + func processExtensionHeader(_ extensionHeader: String) { + let parts = extensionHeader.components(separatedBy: ";") + for p in parts { + let part = p.trimmingCharacters(in: .whitespaces) + if part == "permessage-deflate" { + compressionState.supportsCompression = true + } else if part.hasPrefix("server_max_window_bits=") { + let valString = part.components(separatedBy: "=")[1] + if let val = Int(valString.trimmingCharacters(in: .whitespaces)) { + compressionState.serverMaxWindowBits = val + } + } else if part.hasPrefix("client_max_window_bits=") { + let valString = part.components(separatedBy: "=")[1] + if let val = Int(valString.trimmingCharacters(in: .whitespaces)) { + compressionState.clientMaxWindowBits = val + } + } else if part == "client_no_context_takeover" { + compressionState.clientNoContextTakeover = true + } else if part == "server_no_context_takeover" { + compressionState.serverNoContextTakeover = true + } + } + if compressionState.supportsCompression { + compressionState.decompressor = Decompressor(windowBits: compressionState.serverMaxWindowBits) + compressionState.compressor = Compressor(windowBits: compressionState.clientMaxWindowBits) + } + } + + /** + Read a 16 bit big endian value from a buffer + */ + private static func readUint16(_ buffer: UnsafePointer, 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, 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, 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, offset: Int, value: UInt64) { + for i in 0...7 { + buffer[offset + i] = UInt8((value >> (8*UInt64(7 - i))) & 0xff) + } + } + + /** + Process one message at the start of `buffer`. Return another buffer (sharing storage) that contains the leftover contents of `buffer` that I didn't process. + */ + private func processOneRawMessage(inBuffer buffer: UnsafeBufferPointer) -> UnsafeBufferPointer { + let response = readStack.last + guard let baseAddress = buffer.baseAddress else {return emptyBuffer} + let bufferLen = buffer.count + if response != nil && bufferLen < 2 { + fragBuffer = Data(buffer: buffer) + return emptyBuffer + } + if let response = response, response.bytesLeft > 0 { + var len = response.bytesLeft + var extra = bufferLen - response.bytesLeft + if response.bytesLeft > bufferLen { + len = bufferLen + extra = 0 + } + response.bytesLeft -= len + response.buffer?.append(Data(bytes: baseAddress, count: len)) + _ = processResponse(response) + return buffer.fromOffset(bufferLen - extra) + } else { + let isFin = (FinMask & baseAddress[0]) + let receivedOpcodeRawValue = (OpCodeMask & baseAddress[0]) + let receivedOpcode = OpCode(rawValue: receivedOpcodeRawValue) + let isMasked = (MaskMask & baseAddress[1]) + let payloadLen = (PayloadLenMask & baseAddress[1]) + var offset = 2 + if compressionState.supportsCompression && receivedOpcode != .continueFrame { + compressionState.messageNeedsDecompression = (RSV1Mask & baseAddress[0]) > 0 + } + if (isMasked > 0 || (RSVMask & baseAddress[0]) > 0) && receivedOpcode != .pong && !compressionState.messageNeedsDecompression { + let errCode = CloseCode.protocolError.rawValue + doDisconnect(WSError(type: .protocolError, message: "masked and rsv data is not currently supported", code: Int(errCode))) + writeError(errCode) + return emptyBuffer + } + let isControlFrame = (receivedOpcode == .connectionClose || receivedOpcode == .ping) + if !isControlFrame && (receivedOpcode != .binaryFrame && receivedOpcode != .continueFrame && + receivedOpcode != .textFrame && receivedOpcode != .pong) { + let errCode = CloseCode.protocolError.rawValue + doDisconnect(WSError(type: .protocolError, message: "unknown opcode: \(receivedOpcodeRawValue)", code: Int(errCode))) + writeError(errCode) + return emptyBuffer + } + if isControlFrame && isFin == 0 { + let errCode = CloseCode.protocolError.rawValue + doDisconnect(WSError(type: .protocolError, message: "control frames can't be fragmented", code: Int(errCode))) + writeError(errCode) + return emptyBuffer + } + var closeCode = CloseCode.normal.rawValue + if receivedOpcode == .connectionClose { + if payloadLen == 1 { + closeCode = CloseCode.protocolError.rawValue + } else if payloadLen > 1 { + closeCode = WebSocket.readUint16(baseAddress, offset: offset) + if closeCode < 1000 || (closeCode > 1003 && closeCode < 1007) || (closeCode > 1013 && closeCode < 3000) { + closeCode = CloseCode.protocolError.rawValue + } + } + if payloadLen < 2 { + doDisconnect(WSError(type: .protocolError, message: "connection closed by server", code: Int(closeCode))) + writeError(closeCode) + return emptyBuffer + } + } else if isControlFrame && payloadLen > 125 { + writeError(CloseCode.protocolError.rawValue) + return emptyBuffer + } + var dataLength = UInt64(payloadLen) + if dataLength == 127 { + dataLength = WebSocket.readUint64(baseAddress, offset: offset) + offset += MemoryLayout.size + } else if dataLength == 126 { + dataLength = UInt64(WebSocket.readUint16(baseAddress, offset: offset)) + offset += MemoryLayout.size + } + if bufferLen < offset || UInt64(bufferLen - offset) < dataLength { + fragBuffer = Data(bytes: baseAddress, count: bufferLen) + return emptyBuffer + } + var len = dataLength + if dataLength > UInt64(bufferLen) { + len = UInt64(bufferLen-offset) + } + if receivedOpcode == .connectionClose && len > 0 { + let size = MemoryLayout.size + offset += size + len -= UInt64(size) + } + let data: Data + if compressionState.messageNeedsDecompression, let decompressor = compressionState.decompressor { + do { + data = try decompressor.decompress(bytes: baseAddress+offset, count: Int(len), finish: isFin > 0) + if isFin > 0 && compressionState.serverNoContextTakeover { + try decompressor.reset() + } + } catch { + let closeReason = "Decompression failed: \(error)" + let closeCode = CloseCode.encoding.rawValue + doDisconnect(WSError(type: .protocolError, message: closeReason, code: Int(closeCode))) + writeError(closeCode) + return emptyBuffer + } + } else { + data = Data(bytes: baseAddress+offset, count: Int(len)) + } + + if receivedOpcode == .connectionClose { + var closeReason = "connection closed by server" + if let customCloseReason = String(data: data, encoding: .utf8) { + closeReason = customCloseReason + } else { + closeCode = CloseCode.protocolError.rawValue + } + doDisconnect(WSError(type: .protocolError, message: closeReason, code: Int(closeCode))) + writeError(closeCode) + return emptyBuffer + } + if receivedOpcode == .pong { + if canDispatch { + callbackQueue.async { [weak self] in + guard let self = self else { return } + let pongData: Data? = data.count > 0 ? data : nil + self.onPong?(pongData) + self.pongDelegate?.websocketDidReceivePong(socket: self, data: pongData) + } + } + return buffer.fromOffset(offset + Int(len)) + } + var response = readStack.last + if isControlFrame { + response = nil // Don't append pings. + } + if isFin == 0 && receivedOpcode == .continueFrame && response == nil { + let errCode = CloseCode.protocolError.rawValue + doDisconnect(WSError(type: .protocolError, message: "continue frame before a binary or text frame", code: Int(errCode))) + writeError(errCode) + return emptyBuffer + } + var isNew = false + if response == nil { + if receivedOpcode == .continueFrame { + let errCode = CloseCode.protocolError.rawValue + doDisconnect(WSError(type: .protocolError, message: "first frame can't be a continue frame", code: Int(errCode))) + writeError(errCode) + return emptyBuffer + } + isNew = true + response = WSResponse() + response!.code = receivedOpcode! + response!.bytesLeft = Int(dataLength) + response!.buffer = NSMutableData(data: data) + } else { + if receivedOpcode == .continueFrame { + response!.bytesLeft = Int(dataLength) + } else { + let errCode = CloseCode.protocolError.rawValue + doDisconnect(WSError(type: .protocolError, message: "second and beyond of fragment message must be a continue frame", code: Int(errCode))) + writeError(errCode) + return emptyBuffer + } + response!.buffer!.append(data) + } + if let response = response { + response.bytesLeft -= Int(len) + response.frameCount += 1 + response.isFin = isFin > 0 ? true : false + if isNew { + readStack.append(response) + } + _ = processResponse(response) + } + + let step = Int(offset + numericCast(len)) + return buffer.fromOffset(step) + } + } + + /** + Process all messages in the buffer if possible. + */ + private func processRawMessagesInBuffer(_ pointer: UnsafePointer, bufferLen: Int) { + var buffer = UnsafeBufferPointer(start: pointer, count: bufferLen) + repeat { + buffer = processOneRawMessage(inBuffer: buffer) + } while buffer.count >= 2 + if buffer.count > 0 { + fragBuffer = Data(buffer: buffer) + } + } + + /** + Process the finished response of a buffer. + */ + private func processResponse(_ response: WSResponse) -> Bool { + if response.isFin && response.bytesLeft <= 0 { + if response.code == .ping { + if respondToPingWithPong { + let data = response.buffer! // local copy so it is perverse for writing + dequeueWrite(data as Data, code: .pong) + } + } else if response.code == .textFrame { + guard let str = String(data: response.buffer! as Data, encoding: .utf8) else { + writeError(CloseCode.encoding.rawValue) + return false + } + if canDispatch { + callbackQueue.async { [weak self] in + guard let self = self else { return } + self.onText?(str) + self.delegate?.websocketDidReceiveMessage(socket: self, text: str) + self.advancedDelegate?.websocketDidReceiveMessage(socket: self, text: str, response: response) + } + } + } else if response.code == .binaryFrame { + if canDispatch { + let data = response.buffer! // local copy so it is perverse for writing + callbackQueue.async { [weak self] in + guard let self = self else { return } + self.onData?(data as Data) + self.delegate?.websocketDidReceiveData(socket: self, data: data as Data) + self.advancedDelegate?.websocketDidReceiveData(socket: self, data: data as Data, response: response) + } + } + } + readStack.removeLast() + return true + } + return false + } + + /** + Write an error to the socket + */ + private func writeError(_ code: UInt16) { + let buf = NSMutableData(capacity: MemoryLayout.size) + let buffer = UnsafeMutableRawPointer(mutating: buf!.bytes).assumingMemoryBound(to: UInt8.self) + WebSocket.writeUint16(buffer, offset: 0, value: code) + dequeueWrite(Data(bytes: buffer, count: MemoryLayout.size), code: .connectionClose) + } + + /** + Used to write things to the stream + */ + private func dequeueWrite(_ data: Data, code: OpCode, writeCompletion: (() -> ())? = nil) { + let operation = BlockOperation() + operation.addExecutionBlock { [weak self, weak operation] in + //stream isn't ready, let's wait + guard let self = self else { return } + guard let sOperation = operation else { return } + var offset = 2 + var firstByte:UInt8 = self.FinMask | code.rawValue + var data = data + if [.textFrame, .binaryFrame].contains(code), let compressor = self.compressionState.compressor { + do { + data = try compressor.compress(data) + if self.compressionState.clientNoContextTakeover { + try compressor.reset() + } + firstByte |= self.RSV1Mask + } catch { + // TODO: report error? We can just send the uncompressed frame. + } + } + let dataLength = data.count + let frame = NSMutableData(capacity: dataLength + self.MaxFrameSize) + let buffer = UnsafeMutableRawPointer(frame!.mutableBytes).assumingMemoryBound(to: UInt8.self) + buffer[0] = firstByte + if dataLength < 126 { + buffer[1] = CUnsignedChar(dataLength) + } else if dataLength <= Int(UInt16.max) { + buffer[1] = 126 + WebSocket.writeUint16(buffer, offset: offset, value: UInt16(dataLength)) + offset += MemoryLayout.size + } else { + buffer[1] = 127 + WebSocket.writeUint64(buffer, offset: offset, value: UInt64(dataLength)) + offset += MemoryLayout.size + } + buffer[1] |= self.MaskMask + let maskKey = UnsafeMutablePointer(buffer + offset) + _ = SecRandomCopyBytes(kSecRandomDefault, Int(MemoryLayout.size), maskKey) + offset += MemoryLayout.size + + for i in 0...size] + offset += 1 + } + var total = 0 + while !sOperation.isCancelled { + if !self.readyToWrite { + self.doDisconnect(WSError(type: .outputStreamWriteError, message: "output stream had an error during write", code: 0)) + break + } + let stream = self.stream + let writeBuffer = UnsafeRawPointer(frame!.bytes+total).assumingMemoryBound(to: UInt8.self) + let len = stream.write(data: Data(bytes: writeBuffer, count: offset-total)) + if len <= 0 { + self.doDisconnect(WSError(type: .outputStreamWriteError, message: "output stream had an error during write", code: 0)) + break + } else { + total += len + } + if total >= offset { + if let callback = writeCompletion { + self.callbackQueue.async { + callback() + } + } + + break + } + } + } + writeQueue.addOperation(operation) + } + + /** + Used to preform the disconnect delegate + */ + private func doDisconnect(_ error: Error?) { + guard !didDisconnect else { return } + didDisconnect = true + isConnecting = false + mutex.lock() + connected = false + mutex.unlock() + guard canDispatch else {return} + callbackQueue.async { [weak self] in + guard let self = self else { return } + self.onDisconnect?(error) + self.delegate?.websocketDidDisconnect(socket: self, error: error) + self.advancedDelegate?.websocketDidDisconnect(socket: self, error: error) + let userInfo = error.map{ [WebsocketDisconnectionErrorKeyName: $0] } + NotificationCenter.default.post(name: NSNotification.Name(WebsocketDidDisconnectNotification), object: self, userInfo: userInfo) + } + } + + // MARK: - Deinit + + deinit { + mutex.lock() + readyToWrite = false + cleanupStream() + mutex.unlock() + writeQueue.cancelAllOperations() + } + +} + +private extension String { + func sha1Base64() -> String { + let data = self.data(using: String.Encoding.utf8)! + var digest = [UInt8](repeating: 0, count:Int(CC_SHA1_DIGEST_LENGTH)) + data.withUnsafeBytes { _ = CC_SHA1($0, CC_LONG(data.count), &digest) } + return Data(bytes: digest).base64EncodedString() + } +} + +private extension Data { + + init(buffer: UnsafeBufferPointer) { + self.init(bytes: buffer.baseAddress!, count: buffer.count) + } + +} + +private extension UnsafeBufferPointer { + + func fromOffset(_ offset: Int) -> UnsafeBufferPointer { + return UnsafeBufferPointer(start: baseAddress?.advanced(by: offset), count: count - offset) + } + +} + +private let emptyBuffer = UnsafeBufferPointer(start: nil, count: 0) + +#if swift(>=4) +#else +fileprivate extension String { + var count: Int { + return self.characters.count + } +} +#endif diff --git a/Carthage/Checkouts/Starscream/Starscream.podspec b/Carthage/Checkouts/Starscream/Starscream.podspec new file mode 100644 index 00000000..02422808 --- /dev/null +++ b/Carthage/Checkouts/Starscream/Starscream.podspec @@ -0,0 +1,16 @@ +Pod::Spec.new do |s| + s.name = "Starscream" + s.version = "3.1.1" + s.summary = "A conforming WebSocket RFC 6455 client library in Swift." + s.homepage = "https://github.com/daltoniam/Starscream" + s.license = 'Apache License, Version 2.0' + s.author = {'Dalton Cherry' => 'http://daltoniam.com', 'Austin Cherry' => 'http://austincherry.me'} + s.source = { :git => 'https://github.com/daltoniam/Starscream.git', :tag => "#{s.version}"} + s.social_media_url = 'http://twitter.com/daltoniam' + s.ios.deployment_target = '8.0' + s.osx.deployment_target = '10.10' + s.tvos.deployment_target = '9.0' + s.watchos.deployment_target = '2.0' + s.source_files = 'Sources/**/*.swift' + s.swift_version = '5.0' +end diff --git a/Carthage/Checkouts/Starscream/Tests/CompressionTests.swift b/Carthage/Checkouts/Starscream/Tests/CompressionTests.swift new file mode 100644 index 00000000..d62560bd --- /dev/null +++ b/Carthage/Checkouts/Starscream/Tests/CompressionTests.swift @@ -0,0 +1,67 @@ +////////////////////////////////////////////////////////////////////////////////////////////////// +// +// CompressionTests.swift +// +// Created by Joseph Ross on 7/16/14. +// Copyright © 2017 Joseph Ross. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +////////////////////////////////////////////////////////////////////////////////////////////////// + +import XCTest +@testable import Starscream + +class CompressionTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testBasic() { + let compressor = Compressor(windowBits: 15)! + let decompressor = Decompressor(windowBits: 15)! + + let rawData = "Hello, World! Hello, World! Hello, World! Hello, World! Hello, World!".data(using: .utf8)! + + let compressed = try! compressor.compress(rawData) + let uncompressed = try! decompressor.decompress(compressed, finish: true) + + XCTAssert(rawData == uncompressed) + } + + func testHugeData() { + let compressor = Compressor(windowBits: 15)! + let decompressor = Decompressor(windowBits: 15)! + + // 2 Gigs! +// var rawData = Data(repeating: 0, count: 0x80000000) + var rawData = Data(repeating: 0, count: 0x80000) + let rawDataLen = rawData.count + rawData.withUnsafeMutableBytes { (ptr: UnsafeMutablePointer) -> Void in + arc4random_buf(ptr, rawDataLen) + } + + let compressed = try! compressor.compress(rawData) + let uncompressed = try! decompressor.decompress(compressed, finish: true) + + XCTAssert(rawData == uncompressed) + } + +} diff --git a/Carthage/Checkouts/Starscream/Tests/Info.plist b/Carthage/Checkouts/Starscream/Tests/Info.plist new file mode 100644 index 00000000..ba72822e --- /dev/null +++ b/Carthage/Checkouts/Starscream/Tests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/Carthage/Checkouts/Starscream/Tests/StarscreamTests/StarscreamTests.swift b/Carthage/Checkouts/Starscream/Tests/StarscreamTests/StarscreamTests.swift new file mode 100644 index 00000000..b078f936 --- /dev/null +++ b/Carthage/Checkouts/Starscream/Tests/StarscreamTests/StarscreamTests.swift @@ -0,0 +1,35 @@ +// +// StarscreamTests.swift +// StarscreamTests +// +// Created by Austin Cherry on 9/25/14. +// Copyright (c) 2014 Vluxe. All rights reserved. +// + +import XCTest + +class StarscreamTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + XCTAssert(true, "Pass") + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measure() { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/Carthage/Checkouts/Starscream/build.sh b/Carthage/Checkouts/Starscream/build.sh new file mode 100755 index 00000000..912295c9 --- /dev/null +++ b/Carthage/Checkouts/Starscream/build.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +set -o pipefail && xcodebuild -project Starscream.xcodeproj -scheme Starscream CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO clean build | xcpretty +swift build +pod repo update +pod lib lint --verbose --allow-warnings diff --git a/Carthage/Checkouts/Starscream/examples/AutobahnTest/.gitignore b/Carthage/Checkouts/Starscream/examples/AutobahnTest/.gitignore new file mode 100644 index 00000000..ad59cdc4 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/AutobahnTest/.gitignore @@ -0,0 +1,27 @@ +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control? +# +# Pods/ + +# Xcode +.DS_Store +build +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ +*.hmap +*.xccheckout +*.xcodeproj/*.xcworkspace \ No newline at end of file diff --git a/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/AppDelegate.swift b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/AppDelegate.swift new file mode 100644 index 00000000..7e1a59ac --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// Autobahn +// +// Created by Dalton Cherry on 7/24/15. +// Copyright (c) 2015 vluxe. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Base.lproj/LaunchScreen.xib b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Base.lproj/LaunchScreen.xib new file mode 100644 index 00000000..0b8771f6 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Base.lproj/LaunchScreen.xib @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Base.lproj/Main.storyboard b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Base.lproj/Main.storyboard new file mode 100644 index 00000000..c768e2eb --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Images.xcassets/AppIcon.appiconset/Contents.json b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..36d2c80d --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,68 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Info.plist b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Info.plist new file mode 100644 index 00000000..4d851d95 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/Info.plist @@ -0,0 +1,47 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.vluxe.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/ViewController.swift b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/ViewController.swift new file mode 100644 index 00000000..bac1a3a4 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/AutobahnTest/Autobahn/ViewController.swift @@ -0,0 +1,166 @@ +// +// ViewController.swift +// Autobahn +// +// Created by Dalton Cherry on 7/24/15. +// Copyright (c) 2015 vluxe. All rights reserved. +// + +import UIKit +import Starscream + +class ViewController: UIViewController { + + let host = "localhost:9001" + var socketArray = [WebSocket]() + var caseCount = 300 //starting cases + override func viewDidLoad() { + super.viewDidLoad() + getCaseCount() + //getTestInfo(1) + } + + func removeSocket(_ s: WebSocket?) { + socketArray = socketArray.filter{$0 != s} + } + + func getCaseCount() { + + let s = WebSocket(url: URL(string: "ws://\(host)/getCaseCount")!, protocols: []) + socketArray.append(s) + s.onText = { [weak self] (text: String) in + if let c = Int(text) { + print("number of cases is: \(c)") + self?.caseCount = c + } + } + s.onDisconnect = { [weak self, weak s] (error: Error?) in + self?.getTestInfo(1) + self?.removeSocket(s) + } + s.connect() + } + + func getTestInfo(_ caseNum: Int) { + let s = createSocket("getCaseInfo",caseNum) + socketArray.append(s) + s.onText = { (text: String) in +// let data = text.dataUsingEncoding(NSUTF8StringEncoding) +// do { +// let resp: AnyObject? = try NSJSONSerialization.JSONObjectWithData(data!, +// options: NSJSONReadingOptions()) +// if let dict = resp as? Dictionary { +// let num = dict["id"] +// let summary = dict["description"] +// if let n = num, let sum = summary { +// print("running case:\(caseNum) id:\(n) summary: \(sum)") +// } +// } +// } catch { +// print("error parsing the json") +// } + + } + var once = false + s.onDisconnect = { [weak self, weak s] (error: Error?) in + if !once { + once = true + self?.runTest(caseNum) + } + self?.removeSocket(s) + } + s.connect() + } + + func runTest(_ caseNum: Int) { + let s = createSocket("runCase",caseNum) + self.socketArray.append(s) + s.onText = { [weak s] (text: String) in + s?.write(string: text) + } + s.onData = { [weak s] (data: Data) in + s?.write(data: data) + } + var once = false + s.onDisconnect = {[weak self, weak s] (error: Error?) in + if !once { + once = true + print("case:\(caseNum) finished") + //self?.verifyTest(caseNum) //disabled since it slows down the tests + let nextCase = caseNum+1 + if nextCase <= (self?.caseCount)! { + self?.runTest(nextCase) + //self?.getTestInfo(nextCase) //disabled since it slows down the tests + } else { + self?.finishReports() + } + self?.removeSocket(s) + } + } + s.connect() + } + + func verifyTest(_ caseNum: Int) { + let s = createSocket("getCaseStatus",caseNum) + self.socketArray.append(s) + s.onText = { (text: String) in + let data = text.data(using: String.Encoding.utf8) + do { + let resp: Any? = try JSONSerialization.jsonObject(with: data!, + options: JSONSerialization.ReadingOptions()) + if let dict = resp as? Dictionary { + if let status = dict["behavior"] { + if status == "OK" { + print("SUCCESS: \(caseNum)") + return + } + } + print("FAILURE: \(caseNum)") + } + } catch { + print("error parsing the json") + } + } + var once = false + s.onDisconnect = { [weak self, weak s] (error: Error?) in + if !once { + once = true + let nextCase = caseNum+1 + print("next test is: \(nextCase)") + if nextCase <= (self?.caseCount)! { + self?.getTestInfo(nextCase) + } else { + self?.finishReports() + } + } + self?.removeSocket(s) + } + s.connect() + } + + func finishReports() { + let s = createSocket("updateReports",0) + self.socketArray.append(s) + s.onDisconnect = { [weak self, weak s] (error: Error?) in + print("finished all the tests!") + self?.removeSocket(s) + } + s.connect() + } + + func createSocket(_ cmd: String, _ caseNum: Int) -> WebSocket { + return WebSocket(url: URL(string: "ws://\(host)\(buildPath(cmd,caseNum))")!, protocols: []) + } + + func buildPath(_ cmd: String, _ caseNum: Int) -> String { + return "/\(cmd)?case=\(caseNum)&agent=Starscream" + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + +} + diff --git a/Carthage/Checkouts/Starscream/examples/AutobahnTest/AutobahnTests/AutobahnTests.swift b/Carthage/Checkouts/Starscream/examples/AutobahnTest/AutobahnTests/AutobahnTests.swift new file mode 100644 index 00000000..6eccc039 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/AutobahnTest/AutobahnTests/AutobahnTests.swift @@ -0,0 +1,36 @@ +// +// AutobahnTests.swift +// AutobahnTests +// +// Created by Dalton Cherry on 7/24/15. +// Copyright (c) 2015 vluxe. All rights reserved. +// + +import UIKit +import XCTest + +class AutobahnTests: XCTestCase { + + override func setUp() { + super.setUp() + // Put setup code here. This method is called before the invocation of each test method in the class. + } + + override func tearDown() { + // Put teardown code here. This method is called after the invocation of each test method in the class. + super.tearDown() + } + + func testExample() { + // This is an example of a functional test case. + XCTAssert(true, "Pass") + } + + func testPerformanceExample() { + // This is an example of a performance test case. + self.measure() { + // Put the code you want to measure the time of here. + } + } + +} diff --git a/Carthage/Checkouts/Starscream/examples/AutobahnTest/AutobahnTests/Info.plist b/Carthage/Checkouts/Starscream/examples/AutobahnTest/AutobahnTests/Info.plist new file mode 100644 index 00000000..06dadd73 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/AutobahnTest/AutobahnTests/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + com.vluxe.$(PRODUCT_NAME:rfc1034identifier) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + + diff --git a/Carthage/Checkouts/Starscream/examples/SimpleTest/.gitignore b/Carthage/Checkouts/Starscream/examples/SimpleTest/.gitignore new file mode 100644 index 00000000..ad59cdc4 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/SimpleTest/.gitignore @@ -0,0 +1,27 @@ +# CocoaPods +# +# We recommend against adding the Pods directory to your .gitignore. However +# you should judge for yourself, the pros and cons are mentioned at: +# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control? +# +# Pods/ + +# Xcode +.DS_Store +build +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 +xcuserdata +profile +*.moved-aside +DerivedData +.idea/ +*.hmap +*.xccheckout +*.xcodeproj/*.xcworkspace \ No newline at end of file diff --git a/Carthage/Checkouts/Starscream/examples/SimpleTest/README.md b/Carthage/Checkouts/Starscream/examples/SimpleTest/README.md new file mode 100644 index 00000000..69f494a5 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/SimpleTest/README.md @@ -0,0 +1,20 @@ +# Simple Test + +This is a very simple example on how to use Starscream. + +# Usage + +First make sure you have the gem dependencies of websocket server. + +``` +gem install em-websocket +gem install faker +``` + +Next simply run: + +``` +ruby ws-server.rb +``` + +After that, start and run the xCode project. Echo to your heart's desire. \ No newline at end of file diff --git a/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/AppDelegate.swift b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/AppDelegate.swift new file mode 100644 index 00000000..61a4ee58 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/AppDelegate.swift @@ -0,0 +1,46 @@ +// +// AppDelegate.swift +// SimpleTest +// +// Created by Dalton Cherry on 8/12/14. +// Copyright (c) 2014 vluxe. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Base.lproj/Main.storyboard b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Base.lproj/Main.storyboard new file mode 100644 index 00000000..4b831e75 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Base.lproj/Main.storyboard @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Images.xcassets/AppIcon.appiconset/Contents.json b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Images.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..b7f3352e --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Images.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,58 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Images.xcassets/LaunchImage.launchimage/Contents.json b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Images.xcassets/LaunchImage.launchimage/Contents.json new file mode 100644 index 00000000..6f870a46 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Images.xcassets/LaunchImage.launchimage/Contents.json @@ -0,0 +1,51 @@ +{ + "images" : [ + { + "orientation" : "portrait", + "idiom" : "iphone", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "iphone", + "subtype" : "retina4", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "1x" + }, + { + "orientation" : "portrait", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + }, + { + "orientation" : "landscape", + "idiom" : "ipad", + "extent" : "full-screen", + "minimum-system-version" : "7.0", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Info.plist b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Info.plist new file mode 100644 index 00000000..fa00b2c9 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/ViewController.swift b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/ViewController.swift new file mode 100644 index 00000000..1e0a8537 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/SimpleTest/SimpleTest/ViewController.swift @@ -0,0 +1,67 @@ +// +// ViewController.swift +// SimpleTest +// +// Created by Dalton Cherry on 8/12/14. +// Copyright (c) 2014 vluxe. All rights reserved. +// + +import UIKit +import Starscream + +class ViewController: UIViewController, WebSocketDelegate { + var socket: WebSocket! + + override func viewDidLoad() { + super.viewDidLoad() + var request = URLRequest(url: URL(string: "http://localhost:8080")!) + request.timeoutInterval = 5 + socket = WebSocket(request: request) + socket.delegate = self + socket.connect() + } + + // MARK: Websocket Delegate Methods. + + func websocketDidConnect(socket: WebSocketClient) { + print("websocket is connected") + } + + func websocketDidDisconnect(socket: WebSocketClient, error: Error?) { + if let e = error as? WSError { + print("websocket is disconnected: \(e.message)") + } else if let e = error { + print("websocket is disconnected: \(e.localizedDescription)") + } else { + print("websocket disconnected") + } + } + + func websocketDidReceiveMessage(socket: WebSocketClient, text: String) { + print("Received text: \(text)") + } + + func websocketDidReceiveData(socket: WebSocketClient, data: Data) { + print("Received data: \(data.count)") + } + + // MARK: Write Text Action + + @IBAction func writeText(_ sender: UIBarButtonItem) { + socket.write(string: "hello there!") + } + + // MARK: Disconnect Action + + @IBAction func disconnect(_ sender: UIBarButtonItem) { + if socket.isConnected { + sender.title = "Connect" + socket.disconnect() + } else { + sender.title = "Disconnect" + socket.connect() + } + } + +} + diff --git a/Carthage/Checkouts/Starscream/examples/SimpleTest/ws-server.rb b/Carthage/Checkouts/Starscream/examples/SimpleTest/ws-server.rb new file mode 100644 index 00000000..5177fe3e --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/SimpleTest/ws-server.rb @@ -0,0 +1,25 @@ +require 'em-websocket' +require 'faker' + +EM.run { + EM::WebSocket.run(:host => "0.0.0.0", :port => 8080) do |ws| + ws.onopen { |handshake| + puts "WebSocket connection open" + puts "origin: #{handshake.origin}" + puts "headers: #{handshake.headers}" + + ws.send "Hello Client, you connected to #{handshake.path}" + } + + ws.onerror do |error| + puts "[error] #{error}" + end + + ws.onclose { puts "Connection closed" } + + ws.onmessage { |msg| + puts "message from client: #{msg}" + ws.send +Faker::Hacker.say_something_smart + } + end +} diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Podfile b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Podfile new file mode 100644 index 00000000..62f87cb4 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Podfile @@ -0,0 +1,11 @@ +# Uncomment the next line to define a global platform for your project +# platform :ios, '9.0' + +target 'WebSocketsOrgEcho' do + # Comment the next line if you're not using Swift and don't want to use dynamic frameworks + use_frameworks! + + # Pods for WebSocketsOrgEcho + + pod 'Starscream', :path => '../../' +end diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Podfile.lock b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Podfile.lock new file mode 100644 index 00000000..49f58e0c --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Podfile.lock @@ -0,0 +1,16 @@ +PODS: + - Starscream (3.0.6) + +DEPENDENCIES: + - Starscream (from `../../`) + +EXTERNAL SOURCES: + Starscream: + :path: "../../" + +SPEC CHECKSUMS: + Starscream: 96cd79a6b7ef6a2ff2d00638c73bd195a5322586 + +PODFILE CHECKSUM: 96d91933fe13671aaa81af8a8675ff7698068845 + +COCOAPODS: 1.6.0.beta.1 diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Local Podspecs/Starscream.podspec.json b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Local Podspecs/Starscream.podspec.json new file mode 100644 index 00000000..514469bd --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Local Podspecs/Starscream.podspec.json @@ -0,0 +1,24 @@ +{ + "name": "Starscream", + "version": "3.0.6", + "summary": "A conforming WebSocket RFC 6455 client library in Swift.", + "homepage": "https://github.com/daltoniam/Starscream", + "license": "Apache License, Version 2.0", + "authors": { + "Dalton Cherry": "http://daltoniam.com", + "Austin Cherry": "http://austincherry.me" + }, + "source": { + "git": "https://github.com/daltoniam/Starscream.git", + "tag": "3.0.6" + }, + "social_media_url": "http://twitter.com/daltoniam", + "platforms": { + "ios": "8.0", + "osx": "10.10", + "tvos": "9.0", + "watchos": "2.0" + }, + "source_files": "Sources/**/*.swift", + "swift_version": "4.2" +} diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Manifest.lock b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Manifest.lock new file mode 100644 index 00000000..49f58e0c --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Manifest.lock @@ -0,0 +1,16 @@ +PODS: + - Starscream (3.0.6) + +DEPENDENCIES: + - Starscream (from `../../`) + +EXTERNAL SOURCES: + Starscream: + :path: "../../" + +SPEC CHECKSUMS: + Starscream: 96cd79a6b7ef6a2ff2d00638c73bd195a5322586 + +PODFILE CHECKSUM: 96d91933fe13671aaa81af8a8675ff7698068845 + +COCOAPODS: 1.6.0.beta.1 diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-Info.plist b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-Info.plist new file mode 100644 index 00000000..2243fe6e --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0.0 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-acknowledgements.markdown b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-acknowledgements.markdown new file mode 100644 index 00000000..7d03b3d7 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-acknowledgements.markdown @@ -0,0 +1,182 @@ +# Acknowledgements +This application makes use of the following third party libraries: + +## Starscream + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + Copyright (c) 2014-2016 Dalton Cherry. + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. +Generated by CocoaPods - https://cocoapods.org diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-acknowledgements.plist b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-acknowledgements.plist new file mode 100644 index 00000000..7c82be47 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-acknowledgements.plist @@ -0,0 +1,5 @@ + + + + + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-dummy.m b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-dummy.m new file mode 100644 index 00000000..fdcfa1ac --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Pods_WebSocketsOrgEcho : NSObject +@end +@implementation PodsDummy_Pods_WebSocketsOrgEcho +@end diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-frameworks.sh b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-frameworks.sh new file mode 100755 index 00000000..53a9c475 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-frameworks.sh @@ -0,0 +1,158 @@ +#!/bin/sh +set -e +set -u +set -o pipefail + +if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then + # If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy + # frameworks to, so exit 0 (signalling the script phase was successful). + exit 0 +fi + +echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" +mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + +COCOAPODS_PARALLEL_CODE_SIGN="${COCOAPODS_PARALLEL_CODE_SIGN:-false}" +SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" + +# Used as a return value for each invocation of `strip_invalid_archs` function. +STRIP_BINARY_RETVAL=0 + +# This protects against multiple targets copying the same framework dependency at the same time. The solution +# was originally proposed here: https://lists.samba.org/archive/rsync/2008-February/020158.html +RSYNC_PROTECT_TMP_FILES=(--filter "P .*.??????") + +# Copies and strips a vendored framework +install_framework() +{ + if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then + local source="${BUILT_PRODUCTS_DIR}/$1" + elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then + local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" + elif [ -r "$1" ]; then + local source="$1" + fi + + local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" + + if [ -L "${source}" ]; then + echo "Symlinked..." + source="$(readlink "${source}")" + fi + + # Use filter instead of exclude so missing patterns don't throw errors. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" + + local basename + basename="$(basename -s .framework "$1")" + binary="${destination}/${basename}.framework/${basename}" + + if ! [ -r "$binary" ]; then + binary="${destination}/${basename}" + elif [ -L "${binary}" ]; then + echo "Destination binary is symlinked..." + dirname="$(dirname "${binary}")" + binary="${dirname}/$(readlink "${binary}")" + fi + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then + strip_invalid_archs "$binary" + fi + + # Resign the code if required by the build settings to avoid unstable apps + code_sign_if_enabled "${destination}/$(basename "$1")" + + # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. + if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then + local swift_runtime_libs + swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) + for lib in $swift_runtime_libs; do + echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" + rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" + code_sign_if_enabled "${destination}/${lib}" + done + fi +} + +# Copies and strips a vendored dSYM +install_dsym() { + local source="$1" + if [ -r "$source" ]; then + # Copy the dSYM into a the targets temp dir. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${DERIVED_FILES_DIR}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${DERIVED_FILES_DIR}" + + local basename + basename="$(basename -s .framework.dSYM "$source")" + binary="${DERIVED_FILES_DIR}/${basename}.framework.dSYM/Contents/Resources/DWARF/${basename}" + + # Strip invalid architectures so "fat" simulator / device frameworks work on device + if [[ "$(file "$binary")" == *"Mach-O dSYM companion"* ]]; then + strip_invalid_archs "$binary" + fi + + if [[ $STRIP_BINARY_RETVAL == 1 ]]; then + # Move the stripped file into its final destination. + echo "rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${DERIVED_FILES_DIR}/${basename}.framework.dSYM\" \"${DWARF_DSYM_FOLDER_PATH}\"" + rsync --delete -av "${RSYNC_PROTECT_TMP_FILES[@]}" --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${DERIVED_FILES_DIR}/${basename}.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}" + else + # The dSYM was not stripped at all, in this case touch a fake folder so the input/output paths from Xcode do not reexecute this script because the file is missing. + touch "${DWARF_DSYM_FOLDER_PATH}/${basename}.framework.dSYM" + fi + fi +} + +# Signs a framework with the provided identity +code_sign_if_enabled() { + if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then + # Use the current code_sign_identity + echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" + local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'" + + if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + code_sign_cmd="$code_sign_cmd &" + fi + echo "$code_sign_cmd" + eval "$code_sign_cmd" + fi +} + +# Strip invalid architectures +strip_invalid_archs() { + binary="$1" + # Get architectures for current target binary + binary_archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)" + # Intersect them with the architectures we are building for + intersected_archs="$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)" + # If there are no archs supported by this binary then warn the user + if [[ -z "$intersected_archs" ]]; then + echo "warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS)." + STRIP_BINARY_RETVAL=0 + return + fi + stripped="" + for arch in $binary_archs; do + if ! [[ "${ARCHS}" == *"$arch"* ]]; then + # Strip non-valid architectures in-place + lipo -remove "$arch" -output "$binary" "$binary" || exit 1 + stripped="$stripped $arch" + fi + done + if [[ "$stripped" ]]; then + echo "Stripped $binary of architectures:$stripped" + fi + STRIP_BINARY_RETVAL=1 +} + + +if [[ "$CONFIGURATION" == "Debug" ]]; then + install_framework "${BUILT_PRODUCTS_DIR}/Starscream/Starscream.framework" +fi +if [[ "$CONFIGURATION" == "Release" ]]; then + install_framework "${BUILT_PRODUCTS_DIR}/Starscream/Starscream.framework" +fi +if [ "${COCOAPODS_PARALLEL_CODE_SIGN}" == "true" ]; then + wait +fi diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-umbrella.h b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-umbrella.h new file mode 100644 index 00000000..04075b3a --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho-umbrella.h @@ -0,0 +1,16 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + + +FOUNDATION_EXPORT double Pods_WebSocketsOrgEchoVersionNumber; +FOUNDATION_EXPORT const unsigned char Pods_WebSocketsOrgEchoVersionString[]; + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.debug.xcconfig b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.debug.xcconfig new file mode 100644 index 00000000..6abce856 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.debug.xcconfig @@ -0,0 +1,11 @@ +ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Starscream" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Starscream/Starscream.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "Starscream" +OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.modulemap b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.modulemap new file mode 100644 index 00000000..ffcb5055 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.modulemap @@ -0,0 +1,6 @@ +framework module Pods_WebSocketsOrgEcho { + umbrella header "Pods-WebSocketsOrgEcho-umbrella.h" + + export * + module * { export * } +} diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.release.xcconfig b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.release.xcconfig new file mode 100644 index 00000000..6abce856 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Pods-WebSocketsOrgEcho/Pods-WebSocketsOrgEcho.release.xcconfig @@ -0,0 +1,11 @@ +ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES +FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Starscream" +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' +OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Starscream/Starscream.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "Starscream" +OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_PODFILE_DIR_PATH = ${SRCROOT}/. +PODS_ROOT = ${SRCROOT}/Pods diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-Info.plist b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-Info.plist new file mode 100644 index 00000000..e822e160 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + ${EXECUTABLE_NAME} + CFBundleIdentifier + ${PRODUCT_BUNDLE_IDENTIFIER} + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + ${PRODUCT_NAME} + CFBundlePackageType + FMWK + CFBundleShortVersionString + 3.0.6 + CFBundleSignature + ???? + CFBundleVersion + ${CURRENT_PROJECT_VERSION} + NSPrincipalClass + + + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-dummy.m b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-dummy.m new file mode 100644 index 00000000..94456b3b --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-dummy.m @@ -0,0 +1,5 @@ +#import +@interface PodsDummy_Starscream : NSObject +@end +@implementation PodsDummy_Starscream +@end diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-prefix.pch b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-prefix.pch new file mode 100644 index 00000000..beb2a244 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-prefix.pch @@ -0,0 +1,12 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-umbrella.h b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-umbrella.h new file mode 100644 index 00000000..7bffee0b --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream-umbrella.h @@ -0,0 +1,16 @@ +#ifdef __OBJC__ +#import +#else +#ifndef FOUNDATION_EXPORT +#if defined(__cplusplus) +#define FOUNDATION_EXPORT extern "C" +#else +#define FOUNDATION_EXPORT extern +#endif +#endif +#endif + + +FOUNDATION_EXPORT double StarscreamVersionNumber; +FOUNDATION_EXPORT const unsigned char StarscreamVersionString[]; + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream.modulemap b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream.modulemap new file mode 100644 index 00000000..2b909707 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream.modulemap @@ -0,0 +1,6 @@ +framework module Starscream { + umbrella header "Starscream-umbrella.h" + + export * + module * { export * } +} diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream.xcconfig b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream.xcconfig new file mode 100644 index 00000000..9cedac42 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/Pods/Target Support Files/Starscream/Starscream.xcconfig @@ -0,0 +1,9 @@ +CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Starscream +GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 +OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS +PODS_BUILD_DIR = ${BUILD_DIR} +PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) +PODS_ROOT = ${SRCROOT} +PODS_TARGET_SRCROOT = ${PODS_ROOT}/../../.. +PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} +SKIP_INSTALL = YES diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho.xcworkspace/contents.xcworkspacedata b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..7722c6bb --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,10 @@ + + + + + + + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/AppDelegate.swift b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/AppDelegate.swift new file mode 100644 index 00000000..60a688a6 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/AppDelegate.swift @@ -0,0 +1,21 @@ +// +// AppDelegate.swift +// WebSocketsOrgEcho +// +// Created by Kristaps Grinbergs on 08/10/2018. +// Copyright © 2018 Starscream. All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { + return true + } + +} + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Assets.xcassets/AppIcon.appiconset/Contents.json b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 00000000..d8db8d65 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,98 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Assets.xcassets/Contents.json b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Assets.xcassets/Contents.json new file mode 100644 index 00000000..da4a164c --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Base.lproj/LaunchScreen.storyboard b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 00000000..bfa36129 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Base.lproj/Main.storyboard b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Base.lproj/Main.storyboard new file mode 100644 index 00000000..b13794d4 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Base.lproj/Main.storyboard @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Info.plist b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Info.plist new file mode 100644 index 00000000..16be3b68 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/URL+Extensions.swift b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/URL+Extensions.swift new file mode 100644 index 00000000..d6c37891 --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/URL+Extensions.swift @@ -0,0 +1,19 @@ +// +// URL+Extensions.swift +// Example +// +// Created by Kristaps Grinbergs on 08/10/2018. +// Copyright © 2018 Kristaps Grinbergs. All rights reserved. +// + +import Foundation + +extension URL { + init(staticString string: StaticString) { + guard let url = URL(string: "\(string)") else { + preconditionFailure("Invalid static URL string: \(string)") + } + + self = url + } +} diff --git a/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/ViewController.swift b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/ViewController.swift new file mode 100644 index 00000000..d40fa8bb --- /dev/null +++ b/Carthage/Checkouts/Starscream/examples/WebSocketsOrgEcho/WebSocketsOrgEcho/ViewController.swift @@ -0,0 +1,42 @@ +// +// ViewController.swift +// WebSocketsOrgEcho +// +// Created by Kristaps Grinbergs on 08/10/2018. +// Copyright © 2018 Starscream. All rights reserved. +// + +import UIKit + +import Starscream + +class ViewController: UIViewController, WebSocketDelegate { + + var socket: WebSocket = WebSocket(url: URL(staticString: "wss://echo.websocket.org")) + + func websocketDidConnect(socket: WebSocketClient) { + print("websocketDidConnect") + } + + func websocketDidDisconnect(socket: WebSocketClient, error: Error?) { + print("websocketDidDisconnect", error ?? "") + } + + func websocketDidReceiveMessage(socket: WebSocketClient, text: String) { + print("websocketDidReceiveMessage", text) + } + + func websocketDidReceiveData(socket: WebSocketClient, data: Data) { + print("websocketDidReceiveData", data) + } + + override func viewDidLoad() { + super.viewDidLoad() + + socket.delegate = self + } + + @IBAction func connect(_ sender: Any) { + socket.connect() + } +} diff --git a/Carthage/Checkouts/Starscream/fastlane/Fastfile b/Carthage/Checkouts/Starscream/fastlane/Fastfile new file mode 100644 index 00000000..069321f9 --- /dev/null +++ b/Carthage/Checkouts/Starscream/fastlane/Fastfile @@ -0,0 +1,28 @@ +default_platform(:ios) + +update_fastlane + +platform :ios do + desc "Deploy new version" + lane :release do + ensure_git_branch + version = version_get_podspec(path: "Starscream.podspec") + changelog = prompt(text: "Changelog: ", multi_line_end_keyword: "END") + + github_token = ENV['GITHUB_TOKEN'] + if !github_token || github_token.empty? + github_token = prompt(text: "Please enter your GitHub token: ") + end + + github_release = set_github_release( + repository_name: "daltoniam/Starscream", + api_token: github_token, + name: version, + tag_name: version, + description: changelog, + commitish: "master" + ) + sh("git fetch --tags") + pod_push(allow_warnings: true, verbose: true) + end +end diff --git a/Carthage/Checkouts/Starscream/fastlane/README.md b/Carthage/Checkouts/Starscream/fastlane/README.md new file mode 100644 index 00000000..655d2070 --- /dev/null +++ b/Carthage/Checkouts/Starscream/fastlane/README.md @@ -0,0 +1,29 @@ +fastlane documentation +================ +# Installation + +Make sure you have the latest version of the Xcode command line tools installed: + +``` +xcode-select --install +``` + +Install _fastlane_ using +``` +[sudo] gem install fastlane -NV +``` +or alternatively using `brew cask install fastlane` + +# Available Actions +## iOS +### ios release +``` +fastlane ios release +``` +Depoy new version + +---- + +This README.md is auto-generated and will be re-generated every time [fastlane](https://fastlane.tools) is run. +More information about fastlane can be found on [fastlane.tools](https://fastlane.tools). +The documentation of fastlane can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/Carthage/Checkouts/Starscream/release.sh b/Carthage/Checkouts/Starscream/release.sh new file mode 100755 index 00000000..7e244db9 --- /dev/null +++ b/Carthage/Checkouts/Starscream/release.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +bundle install +bundle exec fastlane release diff --git a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj index 21c31ee5..a6e8ea57 100644 --- a/Socket.IO-Client-Swift.xcodeproj/project.pbxproj +++ b/Socket.IO-Client-Swift.xcodeproj/project.pbxproj @@ -49,6 +49,7 @@ DD52BF924BEF05E1235CFD29 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD52BA1F41F2E4B3DC20260E /* SocketIOClient.swift */; }; DD52BFBC9E7CC32D3515AC80 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD52B645273A873667BC2D43 /* SocketEngineSpec.swift */; }; DD52BFEB4DBD3BF8D93DAEFF /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD52B6DCCBBAC6BE9C22568D /* SocketEventHandler.swift */; }; + FF1BBA9A23B9DDA5002F5DBD /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FF1BBA9923B9DDA5002F5DBD /* Starscream.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -115,6 +116,7 @@ DD52BE9AD8B2BD7F841CD1D4 /* SocketEngineWebsocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketEngineWebsocket.swift; sourceTree = ""; }; DD52BED81BF312B0E90E92AC /* SocketLogger.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketLogger.swift; sourceTree = ""; }; DD52BFF2E3216CDC364BB8AF /* SocketAckEmitter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketAckEmitter.swift; sourceTree = ""; }; + FF1BBA9923B9DDA5002F5DBD /* Starscream.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Starscream.framework; path = Carthage/Build/iOS/Starscream.framework; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -123,6 +125,7 @@ buildActionMask = 2147483647; files = ( 74DA21741F09440F009C19EE /* libz.tbd in Frameworks */, + FF1BBA9A23B9DDA5002F5DBD /* Starscream.framework in Frameworks */, 6CA08A981D615C0B0061FD2A /* Security.framework in Frameworks */, 74D0F5961F8053950037C4DC /* Starscream.framework in Frameworks */, ); @@ -233,6 +236,7 @@ 6CA08A9B1D615C190061FD2A /* Frameworks */ = { isa = PBXGroup; children = ( + FF1BBA9923B9DDA5002F5DBD /* Starscream.framework */, 749FA1A11F811408002FBB30 /* Foundation.framework */, 749FA19F1F8112E7002FBB30 /* Starscream.framework.dSYM */, 74D0F58D1F804FED0037C4DC /* libz.tbd */, @@ -699,7 +703,10 @@ "ENABLE_BITCODE[sdk=macosx*]" = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); FRAMEWORK_VERSION = A; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; @@ -770,7 +777,10 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); FRAMEWORK_VERSION = A; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES;