diff --git a/Arcohol.xcodeproj/project.pbxproj b/Arcohol.xcodeproj/project.pbxproj index 0549b9c..1bcba8a 100644 --- a/Arcohol.xcodeproj/project.pbxproj +++ b/Arcohol.xcodeproj/project.pbxproj @@ -413,13 +413,16 @@ TargetAttributes = { 9F15219B1D64B44C00B264B0 = { CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 0800; }; 9F1521AF1D64B44C00B264B0 = { CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 0800; TestTargetID = 9F15219B1D64B44C00B264B0; }; 9F1521BA1D64B44C00B264B0 = { CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 0800; TestTargetID = 9F15219B1D64B44C00B264B0; }; }; @@ -702,6 +705,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = manuel.marcos.Arcohol; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 2; }; name = Debug; @@ -716,6 +720,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = manuel.marcos.Arcohol; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 2; }; name = Release; @@ -728,6 +733,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = manuel.marcos.ArcoholTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Arcohol.app/Arcohol"; }; name = Debug; @@ -740,6 +746,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = manuel.marcos.ArcoholTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Arcohol.app/Arcohol"; }; name = Release; @@ -751,6 +758,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = manuel.marcos.ArcoholUITests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_TARGET_NAME = Arcohol; }; name = Debug; @@ -762,6 +770,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = manuel.marcos.ArcoholUITests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_TARGET_NAME = Arcohol; }; name = Release; diff --git a/Arcohol/AppDelegate.swift b/Arcohol/AppDelegate.swift index a87feeb..c26c10e 100644 --- a/Arcohol/AppDelegate.swift +++ b/Arcohol/AppDelegate.swift @@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } - func applicationWillResignActive(application: UIApplication) { + 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) { + 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) { + 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) { + 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) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } } diff --git a/Arcohol/BaseCollectionViewController.swift b/Arcohol/BaseCollectionViewController.swift index e06b316..2f9dcd6 100644 --- a/Arcohol/BaseCollectionViewController.swift +++ b/Arcohol/BaseCollectionViewController.swift @@ -10,19 +10,19 @@ import Foundation import UIKit protocol ContainterViewControllerProtocol { - func didSelectCategory(wineArray: [Wine]) - func didSelectWine(row: Int) + func didSelectCategory(_ wineArray: [Wine]) + func didSelectWine(_ row: Int) } class BaseCollectionViewController: UICollectionViewController { var delegate: ContainterViewControllerProtocol? - private let reuseBottomIdentifier = "BottomCollectionViewCell" + fileprivate let reuseBottomIdentifier = "BottomCollectionViewCell" - override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) { + override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { self.collectionView!.collectionViewLayout.invalidateLayout() } - func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { + func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize { return CGSize(width: self.collectionView!.frame.height, height: self.collectionView!.frame.height) } } diff --git a/Arcohol/BottomCollectionViewController.swift b/Arcohol/BottomCollectionViewController.swift index 619d539..20776a1 100644 --- a/Arcohol/BottomCollectionViewController.swift +++ b/Arcohol/BottomCollectionViewController.swift @@ -10,38 +10,38 @@ import Foundation import UIKit class BottomCollectionViewController: BaseCollectionViewController { - private let reuseBottomIdentifier = "BottomCollectionViewCell" + fileprivate let reuseBottomIdentifier = "BottomCollectionViewCell" var array: [Wine] = [] { didSet { - dispatch_async(dispatch_get_main_queue()) { [unowned self] in + DispatchQueue.main.async { [unowned self] in self.collectionView?.reloadData() // Scroll to the beginning - let indexPath = NSIndexPath(forItem:0, inSection: 0) - self.collectionView?.scrollToItemAtIndexPath(indexPath, atScrollPosition: UICollectionViewScrollPosition.Left, animated: true) + let indexPath = IndexPath(item:0, section: 0) + self.collectionView?.scrollToItem(at: indexPath, at: UICollectionViewScrollPosition.left, animated: true) } } } - override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return array.count } - override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { + override func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 } - override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { - let cell = self.collectionView!.dequeueReusableCellWithReuseIdentifier(reuseBottomIdentifier, forIndexPath: indexPath) as! BottomCollectionViewCell - cell.labelName.text = array[indexPath.row].wineName - cell.labelColour.text = array[indexPath.row].wineColour - cell.labelCountry.text = array[indexPath.row].wineCountryName - cell.labelTastingNotes.text = array[indexPath.row].wineNotes - let image = UIImage(named: array[indexPath.row].wineImageName()) + override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = self.collectionView!.dequeueReusableCell(withReuseIdentifier: reuseBottomIdentifier, for: indexPath) as! BottomCollectionViewCell + cell.labelName.text = array[(indexPath as NSIndexPath).row].wineName + cell.labelColour.text = array[(indexPath as NSIndexPath).row].wineColour + cell.labelCountry.text = array[(indexPath as NSIndexPath).row].wineCountryName + cell.labelTastingNotes.text = array[(indexPath as NSIndexPath).row].wineNotes + let image = UIImage(named: array[(indexPath as NSIndexPath).row].wineImageName()) cell.imageView.image = image return cell } - override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { - self.delegate?.didSelectWine(indexPath.row) + override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + self.delegate?.didSelectWine((indexPath as NSIndexPath).row) } } diff --git a/Arcohol/Category.swift b/Arcohol/Category.swift index f19121c..a8a9c04 100644 --- a/Arcohol/Category.swift +++ b/Arcohol/Category.swift @@ -10,7 +10,7 @@ import Foundation import UIKit class Category: UIView { - @IBOutlet private var contentView: UIView? + @IBOutlet fileprivate var contentView: UIView? @IBOutlet var imageView: UIImageView? @IBOutlet var labelName: UILabel? var name: String? { @@ -32,12 +32,12 @@ class Category: UIView { self.commonInit() } - private func commonInit() { + fileprivate func commonInit() { self.translatesAutoresizingMaskIntoConstraints = false - NSBundle.mainBundle().loadNibNamed("Category", owner: self, options: nil) + Bundle.main.loadNibNamed("Category", owner: self, options: nil) guard let content = contentView else { return } content.frame = self.bounds - content.autoresizingMask = [.FlexibleHeight, .FlexibleWidth] + content.autoresizingMask = [.flexibleHeight, .flexibleWidth] self.addSubview(content) } } diff --git a/Arcohol/NetworkManager.swift b/Arcohol/NetworkManager.swift index 17ff102..afa33b5 100644 --- a/Arcohol/NetworkManager.swift +++ b/Arcohol/NetworkManager.swift @@ -7,40 +7,39 @@ // import Foundation -import SocketIOClientSwift - +import SocketIO // TODO: Fix and Create the network layer class NetworkManager { - let socket = SocketIOClient(socketURL: NSURL(string: Constants.EndPoints.raspberryPiEndPoint)!, options: [.Log(true), .ForcePolling(true)]) + let socket = SocketIOClient(socketURL: URL(string: Constants.EndPoints.raspberryPiEndPoint)!) - private func connectSocket(completionHandler:(connected: Bool) -> ()) { + fileprivate func connectSocket(_ completionHandler:@escaping (_ connected: Bool) -> ()) { - if self.socket.status == SocketIOClientStatus.Connected { - completionHandler(connected: true) + if self.socket.status == SocketIOClientStatus.connected { + completionHandler(true) } self.socket.reconnects = false socket.on("error") {data in - completionHandler(connected: false) + completionHandler(false) } self.socket.on("control") {data, ack in - completionHandler(connected: true) + completionHandler(true) } self.socket.connect() } - private func emit(segmentsArray: [Int]) { + fileprivate func emit(_ segmentsArray: [Int]) { self.socket.emit("control", ["segmentSet": segmentsArray]) } - func emitToSocket(segmentsArray: [Int], completionHandler:(success: Bool) -> ()) { + func emitToSocket(_ segmentsArray: [Int], completionHandler:@escaping (_ success: Bool) -> ()) { self.connectSocket { (connected) in if connected { self.emit(segmentsArray) - completionHandler(success: true) + completionHandler(true) } else { - completionHandler(success: false) + completionHandler(false) } } } diff --git a/Arcohol/Test.swift b/Arcohol/Test.swift index dee1f7e..a58c83b 100644 --- a/Arcohol/Test.swift +++ b/Arcohol/Test.swift @@ -10,8 +10,8 @@ import Foundation import UIKit class Test: UIView { - @IBOutlet private var contentView: UIView? - @IBOutlet private var textField: UITextField? + @IBOutlet fileprivate var contentView: UIView? + @IBOutlet fileprivate var textField: UITextField? // for using CustomView in code override init(frame: CGRect) { @@ -25,16 +25,16 @@ class Test: UIView { self.commonInit() } - private func commonInit() { + fileprivate func commonInit() { self.translatesAutoresizingMaskIntoConstraints = false - NSBundle.mainBundle().loadNibNamed("Test", owner: self, options: nil) + Bundle.main.loadNibNamed("Test", owner: self, options: nil) guard let content = contentView else { return } content.frame = self.bounds - content.autoresizingMask = [.FlexibleHeight, .FlexibleWidth] + content.autoresizingMask = [.flexibleHeight, .flexibleWidth] self.addSubview(content) } - @IBAction func test(sender: AnyObject) { + @IBAction func test(_ sender: AnyObject) { NetworkManager.sharedInstance.emitToSocket([Int((self.textField?.text)!)!]) { (success) in if !success { print("Error") diff --git a/Arcohol/TopCollectionViewController.swift b/Arcohol/TopCollectionViewController.swift index d8c37af..2d046c2 100644 --- a/Arcohol/TopCollectionViewController.swift +++ b/Arcohol/TopCollectionViewController.swift @@ -10,56 +10,56 @@ import Foundation import UIKit class TopCollectionViewController: BaseCollectionViewController { - private let reuseTopIdentifier = "TopCollectionViewCell" + fileprivate let reuseTopIdentifier = "TopCollectionViewCell" var array: [WineCategory] = [] { didSet { - dispatch_async(dispatch_get_main_queue()) { [unowned self] in + DispatchQueue.main.async { [unowned self] in self.collectionView?.reloadData() } } } - override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { + override func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return array.count } - override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { + override func numberOfSections(in collectionView: UICollectionView) -> Int { return 1 } - override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { - let cell = self.collectionView!.dequeueReusableCellWithReuseIdentifier(reuseTopIdentifier, forIndexPath: indexPath) as! TopCollectionViewCell - cell.label.text = array[indexPath.row].wineCategoryName - let image = UIImage(named: cell.selected ? array[indexPath.row].wineCategoryImageNameHighlight() : array[indexPath.row].wineCategoryImageNameNormal()) + override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { + let cell = self.collectionView!.dequeueReusableCell(withReuseIdentifier: reuseTopIdentifier, for: indexPath) as! TopCollectionViewCell + cell.label.text = array[(indexPath as NSIndexPath).row].wineCategoryName + let image = UIImage(named: cell.isSelected ? array[(indexPath as NSIndexPath).row].wineCategoryImageNameHighlight() : array[(indexPath as NSIndexPath).row].wineCategoryImageNameNormal()) cell.imageView.image = image return cell } - override func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) { - self.delegate?.didSelectCategory(array[indexPath.row].winesArray) - if let cell = collectionView.cellForItemAtIndexPath(indexPath) as? TopCollectionViewCell { - self.categoryCellSelected(true, cell: cell, index: indexPath.row) + override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { + self.delegate?.didSelectCategory(array[(indexPath as NSIndexPath).row].winesArray) + if let cell = collectionView.cellForItem(at: indexPath) as? TopCollectionViewCell { + self.categoryCellSelected(true, cell: cell, index: (indexPath as NSIndexPath).row) } } - override func collectionView(collectionView: UICollectionView, didDeselectItemAtIndexPath indexPath: NSIndexPath) { - if let cell = collectionView.cellForItemAtIndexPath(indexPath) as? TopCollectionViewCell { - self.categoryCellSelected(false, cell: cell, index: indexPath.row) + override func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { + if let cell = collectionView.cellForItem(at: indexPath) as? TopCollectionViewCell { + self.categoryCellSelected(false, cell: cell, index: (indexPath as NSIndexPath).row) } } - func findItemRowForName(name: String) { - if let index = array.indexOf({$0.wineCategoryName == name}) { - let indexPath = NSIndexPath(forItem:index, inSection: 0) - self.collectionView?.scrollToItemAtIndexPath(NSIndexPath(forItem:index, inSection: 0), atScrollPosition: UICollectionViewScrollPosition.Left, animated: true) - if let cell = self.collectionView?.cellForItemAtIndexPath(indexPath) as? TopCollectionViewCell { - self.categoryCellSelected(true, cell: cell, index: indexPath.row) - self.delegate?.didSelectCategory(array[indexPath.row].winesArray) + func findItemRowForName(_ name: String) { + if let index = array.index(where: {$0.wineCategoryName == name}) { + let indexPath = IndexPath(item:index, section: 0) + self.collectionView?.scrollToItem(at: IndexPath(item:index, section: 0), at: UICollectionViewScrollPosition.left, animated: true) + if let cell = self.collectionView?.cellForItem(at: indexPath) as? TopCollectionViewCell { + self.categoryCellSelected(true, cell: cell, index: (indexPath as NSIndexPath).row) + self.delegate?.didSelectCategory(array[(indexPath as NSIndexPath).row].winesArray) } } } - func categoryCellSelected(selected: Bool, cell: TopCollectionViewCell, index: Int) { + func categoryCellSelected(_ selected: Bool, cell: TopCollectionViewCell, index: Int) { cell.imageView.image = UIImage(named: selected ? array[index].wineCategoryImageNameHighlight() : array[index].wineCategoryImageNameNormal()) } diff --git a/Arcohol/ViewController.swift b/Arcohol/ViewController.swift index 553a74f..288848a 100644 --- a/Arcohol/ViewController.swift +++ b/Arcohol/ViewController.swift @@ -21,57 +21,58 @@ class ViewController: UIViewController, ContainterViewControllerProtocol, WineCa override func viewDidLoad() { super.viewDidLoad() overlayView.wineCategoryOverlayViewProtocolDelegate = self - self.view.addSubview(overlayView) - self.view.addConstraints([NSLayoutConstraint.init(item: overlayView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0), - NSLayoutConstraint.init(item: overlayView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0), - NSLayoutConstraint.init(item: overlayView, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 0), - NSLayoutConstraint.init(item: overlayView, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Right, multiplier: 1, constant: 0)]) +// self.view.addSubview(overlayView) +// self.view.addConstraints([NSLayoutConstraint.init(item: overlayView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0), +// NSLayoutConstraint.init(item: overlayView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0), +// NSLayoutConstraint.init(item: overlayView, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 0), +// NSLayoutConstraint.init(item: overlayView, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Right, multiplier: 1, constant: 0)]) -// let testView: Test = Test() -// -// self.view.addSubview(testView) -// self.view.addConstraints([NSLayoutConstraint.init(item: testView, attribute: NSLayoutAttribute.Top, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 0), -// NSLayoutConstraint.init(item: testView, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Bottom, multiplier: 1, constant: 0), -// NSLayoutConstraint.init(item: testView, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 0), -// NSLayoutConstraint.init(item: testView, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Right, multiplier: 1, constant: 0)]) -// + let testView: Test = Test() + + self.view.addSubview(testView) + self.view.addConstraints([NSLayoutConstraint.init(item: testView, attribute: NSLayoutAttribute.top, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.top, multiplier: 1, constant: 0), + NSLayoutConstraint.init(item: testView, attribute: NSLayoutAttribute.bottom, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.bottom, multiplier: 1, constant: 0), + NSLayoutConstraint.init(item: testView, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.left, multiplier: 1, constant: 0), + NSLayoutConstraint.init(item: testView, attribute: NSLayoutAttribute.right, relatedBy: NSLayoutRelation.equal, toItem: self.view, attribute: NSLayoutAttribute.right, multiplier: 1, constant: 0)]) - dispatch_async(dispatch_get_global_queue(Int(QOS_CLASS_UTILITY.rawValue), 0)) { + + DispatchQueue.global().async { do { self.topContainerCollectionViewController?.array = try WineDataManager.sharedInstance.importCollectionOfWineCategories() - } catch WineDataManager.WineCategoryError.FileNotFound { + } catch WineDataManager.WineCategoryError.fileNotFound { print("FileNotFound") - } catch WineDataManager.WineCategoryError.MalformedDictionary { + } catch WineDataManager.WineCategoryError.malformedDictionary { print("MalformedDictionary") - } catch WineDataManager.WineCategoryError.WineArrayNotFound { + } catch WineDataManager.WineCategoryError.wineArrayNotFound { print("WineArrayNotFound") - } catch WineDataManager.WineCategoryError.WineNotFound { + } catch WineDataManager.WineCategoryError.wineNotFound { print("WineNotFound") - } catch WineDataManager.WineCategoryError.CategoryNotFound { + } catch WineDataManager.WineCategoryError.categoryNotFound { print("CategoryNotFound") } catch { print("some error") } } + } - override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if (segue.identifier == Constants.SegueIdentifiers.topCollectionView) { - guard segue.destinationViewController.isKindOfClass(TopCollectionViewController) else { return } - topContainerCollectionViewController = (segue.destinationViewController as! TopCollectionViewController) + guard segue.destination.isKind(of: TopCollectionViewController.self) else { return } + topContainerCollectionViewController = (segue.destination as! TopCollectionViewController) topContainerCollectionViewController?.delegate = self } if (segue.identifier == Constants.SegueIdentifiers.bottomCollectionView) { - guard segue.destinationViewController.isKindOfClass(BottomCollectionViewController) else { return } - bottomContainerCollectionViewController = (segue.destinationViewController as! BottomCollectionViewController) + guard segue.destination.isKind(of: BottomCollectionViewController.self) else { return } + bottomContainerCollectionViewController = (segue.destination as! BottomCollectionViewController) bottomContainerCollectionViewController?.delegate = self } } // MARK: - Delegation - func didSelectCategory(wineArray: [Wine]) { + func didSelectCategory(_ wineArray: [Wine]) { self.bottomContainerCollectionViewController?.array = wineArray // TODO: Create a clousure that returns an array with all the winesegments @@ -87,7 +88,7 @@ class ViewController: UIViewController, ContainterViewControllerProtocol, WineCa } } - func didSelectWine(row: Int) { + func didSelectWine(_ row: Int) { NetworkManager.sharedInstance.emitToSocket([(self.bottomContainerCollectionViewController?.array[row].wineSegment)!]) { (success) in if !success { print("Error") @@ -95,13 +96,13 @@ class ViewController: UIViewController, ContainterViewControllerProtocol, WineCa } } - func categoryNameTapped(name: String) { + func categoryNameTapped(_ name: String) { self.overlayView.alpha = 1 - UIView.animateWithDuration(0.5, animations: { + UIView.animate(withDuration: 0.5, animations: { self.overlayView.alpha = 0 - }) { (completion) in + }, completion: { (completion) in self.overlayView.removeFromSuperview() - } + }) self.topContainerCollectionViewController?.findItemRowForName(name) } diff --git a/Arcohol/WineCategoriesOverlayView.swift b/Arcohol/WineCategoriesOverlayView.swift index 911f185..e9d0d88 100644 --- a/Arcohol/WineCategoriesOverlayView.swift +++ b/Arcohol/WineCategoriesOverlayView.swift @@ -10,17 +10,17 @@ import Foundation import UIKit protocol WineCategoriesOverlayViewProtocol { - func categoryNameTapped(name: String) + func categoryNameTapped(_ name: String) } class WineCategoriesOverlayView: UIView { - @IBOutlet private var contentView: Category? - @IBOutlet private var categoryMeat: Category? - @IBOutlet private var categoryFish: Category? - @IBOutlet private var categoryPasta: Category? - @IBOutlet private var categoryCheese: Category? - @IBOutlet private var categoryVegetables: Category? - @IBOutlet private var categoryOccasions: Category? + @IBOutlet fileprivate var contentView: Category? + @IBOutlet fileprivate var categoryMeat: Category? + @IBOutlet fileprivate var categoryFish: Category? + @IBOutlet fileprivate var categoryPasta: Category? + @IBOutlet fileprivate var categoryCheese: Category? + @IBOutlet fileprivate var categoryVegetables: Category? + @IBOutlet fileprivate var categoryOccasions: Category? var wineCategoryOverlayViewProtocolDelegate: WineCategoriesOverlayViewProtocol? // for using CustomView in code @@ -35,12 +35,12 @@ class WineCategoriesOverlayView: UIView { self.commonInit() } - private func commonInit() { + fileprivate func commonInit() { self.translatesAutoresizingMaskIntoConstraints = false - NSBundle.mainBundle().loadNibNamed("WineCategoriesOverlayView", owner: self, options: nil) + Bundle.main.loadNibNamed("WineCategoriesOverlayView", owner: self, options: nil) guard let content = contentView else { return } content.frame = self.bounds - content.autoresizingMask = [.FlexibleHeight, .FlexibleWidth] + content.autoresizingMask = [.flexibleHeight, .flexibleWidth] self.setUpViews() self.addSubview(content) } @@ -61,7 +61,7 @@ class WineCategoriesOverlayView: UIView { categoryOccasions?.addGestureRecognizer(UITapGestureRecognizer.init(target: self, action: #selector(WineCategoriesOverlayView.viewTapped))) } - func viewTapped(sender: UITapGestureRecognizer) { + func viewTapped(_ sender: UITapGestureRecognizer) { if let view = sender.view as? Category { self.wineCategoryOverlayViewProtocolDelegate?.categoryNameTapped(view.name!) } diff --git a/Arcohol/WineCategory.swift b/Arcohol/WineCategory.swift index a463644..a4eac30 100644 --- a/Arcohol/WineCategory.swift +++ b/Arcohol/WineCategory.swift @@ -25,7 +25,7 @@ struct WineCategory { return "icon\(self.wineCategoryName)Highlight" } - func equalToName(name: String) -> Bool { + func equalToName(_ name: String) -> Bool { return true } } diff --git a/Arcohol/WineDataManager.swift b/Arcohol/WineDataManager.swift index 8a4de24..6d66451 100644 --- a/Arcohol/WineDataManager.swift +++ b/Arcohol/WineDataManager.swift @@ -10,35 +10,35 @@ import Foundation class WineDataManager { - enum WineCategoryError: ErrorType { - case FileNotFound - case FileContentNotFound - case MalformedDictionary - case WineArrayNotFound - case WineNotFound - case CategoryNotFound + enum WineCategoryError: Error { + case fileNotFound + case fileContentNotFound + case malformedDictionary + case wineArrayNotFound + case wineNotFound + case categoryNotFound } func importCollectionOfWineCategories() throws -> [WineCategory] { // TODO: do the import on a background thread - guard let path = NSBundle.mainBundle().pathForResource("Wines", ofType: "plist") else { - throw WineCategoryError.FileNotFound + guard let path = Bundle.main.path(forResource: "Wines", ofType: "plist") else { + throw WineCategoryError.fileNotFound } guard let arrayOfItems: NSArray = NSArray(contentsOfFile: path) else { - throw WineCategoryError.FileContentNotFound + throw WineCategoryError.fileContentNotFound } var mutableCategoryArray = [WineCategory]() for category in arrayOfItems { guard let categoryDictionary = category as? NSDictionary else { - throw WineCategoryError.MalformedDictionary + throw WineCategoryError.malformedDictionary } guard let wineArray = categoryDictionary["wineArray"] as? NSArray else { - throw WineCategoryError.WineArrayNotFound + throw WineCategoryError.wineArrayNotFound } var mutableWineArray = [Wine]() for wine in wineArray { guard let wineObject = wine as? NSDictionary else { - throw WineCategoryError.MalformedDictionary + throw WineCategoryError.malformedDictionary } guard let wineName = wineObject["wineName"] as? String, let wineCountryName = wineObject["countryName"] as? String, @@ -48,13 +48,13 @@ class WineDataManager { let wineABV = wineObject["abv"] as? String, let wineTastingNotes = wineObject["tastingNotes"] as? String, let wineSegment = wineObject["wineSegment"] as? String else { - throw WineCategoryError.WineNotFound + throw WineCategoryError.wineNotFound } let wine: Wine = Wine(wineName: wineName, wineCountryName: wineCountryName, wineGrape: wineGrape, wineColour: wineColour, wineVintage: wineVintage, wineABV: wineABV, wineNotes: wineTastingNotes, wineSegment: Int(wineSegment)!) mutableWineArray.append(wine) } guard let categoryName = categoryDictionary["categoryName"] as? String else { - throw WineCategoryError.CategoryNotFound + throw WineCategoryError.categoryNotFound } let category: WineCategory = WineCategory(wineCategoryName: categoryName, winesArray: mutableWineArray) mutableCategoryArray.append(category) diff --git a/ArcoholTests/ArcoholTests.swift b/ArcoholTests/ArcoholTests.swift index 7aa3d1c..00f3c9b 100644 --- a/ArcoholTests/ArcoholTests.swift +++ b/ArcoholTests/ArcoholTests.swift @@ -28,7 +28,7 @@ class ArcoholTests: XCTestCase { func testPerformanceExample() { // This is an example of a performance test case. - self.measureBlock { + self.measure { // Put the code you want to measure the time of here. } } diff --git a/Podfile.lock b/Podfile.lock index 3656d04..4978c97 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -1,12 +1,12 @@ PODS: - - Socket.IO-Client-Swift (6.1.6) + - Socket.IO-Client-Swift (8.0.1) DEPENDENCIES: - - Socket.IO-Client-Swift (~> 6.1.6) + - Socket.IO-Client-Swift (~> 8.0.1) SPEC CHECKSUMS: - Socket.IO-Client-Swift: 5eddbfafd3c035a77d365d5b58da93cc488af11f + Socket.IO-Client-Swift: 4a5ef0bafb016f404b34d5b99c4386534492a8c6 -PODFILE CHECKSUM: 543430bc93929305af00796a6b26baeeaeaab24b +PODFILE CHECKSUM: 54668e632ec142a19932359496d2c60a7b6f169f COCOAPODS: 1.0.1 diff --git a/Pods/Manifest.lock b/Pods/Manifest.lock index 3656d04..4978c97 100644 --- a/Pods/Manifest.lock +++ b/Pods/Manifest.lock @@ -1,12 +1,12 @@ PODS: - - Socket.IO-Client-Swift (6.1.6) + - Socket.IO-Client-Swift (8.0.1) DEPENDENCIES: - - Socket.IO-Client-Swift (~> 6.1.6) + - Socket.IO-Client-Swift (~> 8.0.1) SPEC CHECKSUMS: - Socket.IO-Client-Swift: 5eddbfafd3c035a77d365d5b58da93cc488af11f + Socket.IO-Client-Swift: 4a5ef0bafb016f404b34d5b99c4386534492a8c6 -PODFILE CHECKSUM: 543430bc93929305af00796a6b26baeeaeaab24b +PODFILE CHECKSUM: 54668e632ec142a19932359496d2c60a7b6f169f COCOAPODS: 1.0.1 diff --git a/Pods/Pods.xcodeproj/project.pbxproj b/Pods/Pods.xcodeproj/project.pbxproj index f5b97bf..181c4ef 100644 --- a/Pods/Pods.xcodeproj/project.pbxproj +++ b/Pods/Pods.xcodeproj/project.pbxproj @@ -7,35 +7,36 @@ objects = { /* Begin PBXBuildFile section */ - 03CB6B1C98525AD0979684C025FD5E5E /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8FF773F767E909FA900F67BAF08AF6A /* SocketClientManager.swift */; }; - 049DDDD7FE558D16C05DDC448352E073 /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = B8E646DB4E27C271B3772BD011E03A38 /* SocketIOClientOption.swift */; }; - 14011724990E2F6C0AF7DDB854176638 /* Socket.IO-Client-Swift-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = C6BE8EE8A38ECE687B6CAC84498111AC /* Socket.IO-Client-Swift-dummy.m */; }; - 234F53C3472B6509B3808A7487CE8DBA /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = B29865E9455BF96BB3F1C9D1314A2A33 /* SocketAckEmitter.swift */; }; - 29FB02244BCA51391D906720112C1B76 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 822F51C720958FCAD37DFD889C32CA33 /* SocketIOClientSpec.swift */; }; - 4331472AD5477A7D9E2CB4DBB7F08132 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7655864815FAB2CDD140E00E5078DBE /* SocketTypes.swift */; }; - 527B8F6B91FD83DAA0347E3F062DE498 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2815F87124A5D4BE841207E934FA6D24 /* SocketEventHandler.swift */; }; - 5610EE1D21C36C0556713B72955A331F /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9D3C0A3B1755EA912B83795ED3063FB /* SocketLogger.swift */; }; + 03C30702E1993CA7413C8D6996DBAFE9 /* SocketEnginePollable.swift in Sources */ = {isa = PBXBuildFile; fileRef = E330F9F321E4350813202BD51BC3F67A /* SocketEnginePollable.swift */; }; + 062E86AFFB047735919651497656C774 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 525F0BEBFC24363C1C12BFED1C52E09A /* SocketEnginePacketType.swift */; }; + 0810A6DD7E08F305A98BCE35CCFED5E3 /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 996BB3B147D524EF800F2194B91709F1 /* SSLSecurity.swift */; }; + 14CD6432BD66911BF0756CCA3719B838 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = FD80A7ADAB722173423A36E7463C4AFB /* SocketTypes.swift */; }; + 186694AA6A5F32E3506B6C9DBB5E7BA7 /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = F306E01D91D86C36440F2FAD6F23C988 /* SocketIOClientStatus.swift */; }; + 18D5F01ED03AA00A14BC24E1F20EBEA6 /* SocketAckEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9B59BDFD692606D25A027C43E6C89A5C /* SocketAckEmitter.swift */; }; + 3579B5BA0B1D6134CB3E7C4190DDCE91 /* SocketEngineWebsocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5603ECF44D6231ED2C54E8BC2F385A37 /* SocketEngineWebsocket.swift */; }; + 3CAFF869002D41A4F1DFDAF00466A687 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D9571AF94B7FB655E7868AEF99404CB /* SocketAnyEvent.swift */; }; + 45AC0A69712A48D3381E223356302221 /* Socket.IO-Client-Swift-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 87905EC17B5665096942646DB7542569 /* Socket.IO-Client-Swift-dummy.m */; }; + 523F875EFEFD9BE5B34A2A1E2C164C4E /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 043D782257DB50BC7B57630A5BD577C6 /* SocketEventHandler.swift */; }; + 53C42BFA16212B5964E6BCD4873A58AA /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 38EAE89FD26A461FD18EFD671BC2A669 /* SocketIOClient.swift */; }; 571467C4A2F3663C0419955437DF122F /* Pods-Arcohol-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 3BE41648AABD7EEF14E180A676511FFB /* Pods-Arcohol-dummy.m */; }; - 5A8275AFF81D9C96BCDA17AF1C6D131F /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 58B69047D3D50DBCBE7EC73BD7A6B885 /* SocketAnyEvent.swift */; }; - 5AD7313D104764FF60FBFBFD76B1D8EF /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D09B0AEC21752DCC4DFA00386555EBD5 /* SocketParsable.swift */; }; - 6B1F200197020B857719659A7E20B040 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = BA28E93B3F91F281A7562A9D21D52D9C /* SocketEngine.swift */; }; - 6F4FE59B12D6BC7352222B79D6EFC44C /* SSLSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BDBAD22A8C5C840F186680CEB94E2B3 /* SSLSecurity.swift */; }; - 73424D948E7D2A6B01CB0C0C57F60B1B /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 502EDA3C32A8FC048F415CE623D152DB /* SocketPacket.swift */; }; - 7C3F612FB7AB60C7DB523BAF6D51328F /* SocketEnginePollable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1539D268AB6B09F93E243519B2AE278F /* SocketEnginePollable.swift */; }; - 817790FDBEB293D4B5A8F8051419F7EE /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25C3095B25C6E5A4B8CF6B4236CDF1AF /* SocketEnginePacketType.swift */; }; - 912EA989E866FD86F1C237C184F54D6A /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 625EB61367D5A09ADDB64EBA4E8C3C9D /* SocketIOClientStatus.swift */; }; - 91B3FD542CF053544A54B194F5DA3EC8 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 166FE6A4BC5475673619A7EDC6991C51 /* SocketEngineClient.swift */; }; + 66117ECBD4A5322564796765B04E7A3A /* SocketExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F83D48B450D21095FBEC2185F938BE67 /* SocketExtensions.swift */; }; + 66B0F80F7D00E5141CB3EAB3EA4EE28D /* SocketClientManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B1526DC8C1273F235789BF159D7714F /* SocketClientManager.swift */; }; + 82796CCBECD04E6D62AE6BABF2307CF0 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 320E64E91F0F5C8DABC045FC2BF66DF1 /* SocketIOClientSpec.swift */; }; + 88463E6CFA34ED3854192C5B9A1DDAC2 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 51D342D3CD8230E8928AFA54BF2F79D0 /* SocketEngineClient.swift */; }; + 8C84E1BC54EF785AD64533B260CF0193 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31F0F03BBE73D643AD0486ADFE0A8AC5 /* SocketEngine.swift */; }; 95F59DA2323ADAB186B65E6AB3100A06 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEC22C73C1608DFA5D5D78BDCB218219 /* Foundation.framework */; }; - A061F7ED6F385A4065B69218A9D8C844 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99BE209484D9FE966D8F4C9E9762326D /* SocketAckManager.swift */; }; + A65E7C98E5AA2103F0A7F3F0101BB2B4 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 117F685036DDF69767FA0894A36AFD79 /* SocketPacket.swift */; }; + B3FF76737F84E0814C07F2CA361C7EBC /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 670BE73CF5968D8D6D6C8AAC526F90E2 /* SocketStringReader.swift */; }; C1EFE62F20C5AA3B3F9219C7D6912D51 /* Pods-Arcohol-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 40CD5CE0B1FA769C5E4189E9D0B2E83C /* Pods-Arcohol-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; - C2601C14EF4AF22724C31CBEE1371578 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC1035ED4CAB59B50944F190B5B6E5ED /* SocketEngineSpec.swift */; }; - CC9F84C5C170FB4E35314F8993B79659 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = B74B5E2E87423A29A9634BCAF68F39C8 /* SocketIOClient.swift */; }; - D085DEC0BAAA33ED2102E739CB7A2306 /* SocketExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = F37F6C04579156D158BC2A303AC08ED5 /* SocketExtensions.swift */; }; + C362EF4CB2838AE65D746B10BF3272B2 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1670BB5EB79304C745E1AE522C2461EE /* SocketEngineSpec.swift */; }; + CC1F5508A94C491F045BA087E327912A /* SocketParsable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6AE9ACCB4FBAE731DCA98FD8DB00CF2B /* SocketParsable.swift */; }; D28A6170845A4020E634A837356D0293 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEC22C73C1608DFA5D5D78BDCB218219 /* Foundation.framework */; }; - DE3ADBE4B6F607DF2BA016A77F375D95 /* SocketEngineWebsocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9E6DE3609E206DF66F748B3276E73E /* SocketEngineWebsocket.swift */; }; - ED210888D25EAD27C921F2E220FCCE6F /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B922915C6A8FAB2E50CDFFC28FD0F01 /* WebSocket.swift */; }; - F0B2CB6984CD2572A4BC90A92DE712FF /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = AEB5025F8DFEEB35BA0CA8D68DBD5DBB /* SocketStringReader.swift */; }; - FE1D84525CA6F79641E42088DE55B70C /* Socket.IO-Client-Swift-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 2DE34C6C99418B3D68A58C5C9BD7F185 /* Socket.IO-Client-Swift-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + D96A8934D0D8BCEB3A1B1ABDC3B07A39 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F244CCBBA45069AA8A524715B8E5966 /* SocketAckManager.swift */; }; + E3DE2F998F4CC68E36A6B28306E0D85D /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 29A3BB339105AF5BC77EB85BD3CB18E6 /* SocketLogger.swift */; }; + F2E4CAC7605E553DC9B1795EDDE003C4 /* SocketIOClientConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9693A3F4FEDC4DE12781103EE82CB97D /* SocketIOClientConfiguration.swift */; }; + FB1720D79CF4AF499E5987765D5A2A70 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = F36F6652863175FDE16D90EF0BEF19B7 /* WebSocket.swift */; }; + FE1D84525CA6F79641E42088DE55B70C /* Socket.IO-Client-Swift-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F57EC4469168DB9A573C09EAF2AEF49 /* Socket.IO-Client-Swift-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; }; + FEF096B0F01D05C6474B89472B4B999F /* SocketIOClientOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = AC6DB44BEB912798F945A7288622BC11 /* SocketIOClientOption.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -49,49 +50,50 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 069FB6E5640A7B99DEB8F8D257F66FE1 /* Pods_Arcohol.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Arcohol.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 043D782257DB50BC7B57630A5BD577C6 /* SocketEventHandler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEventHandler.swift; path = Source/SocketEventHandler.swift; sourceTree = ""; }; + 05DD98DF656FDC7D8E64CD40CC3F4047 /* Socket.IO-Client-Swift.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Socket.IO-Client-Swift.modulemap"; sourceTree = ""; }; 0A16579676B5ECFFEB5DFADBCB295126 /* Pods-Arcohol-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-Arcohol-acknowledgements.plist"; sourceTree = ""; }; - 0A9E6DE3609E206DF66F748B3276E73E /* SocketEngineWebsocket.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEngineWebsocket.swift; path = Source/SocketEngineWebsocket.swift; sourceTree = ""; }; 0CFE4296667075DED87E834A607506D4 /* Pods-Arcohol-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Arcohol-frameworks.sh"; sourceTree = ""; }; - 1079B0BDBE38B922CCF99B449589A936 /* Socket.IO-Client-Swift-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Socket.IO-Client-Swift-prefix.pch"; sourceTree = ""; }; - 1539D268AB6B09F93E243519B2AE278F /* SocketEnginePollable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEnginePollable.swift; path = Source/SocketEnginePollable.swift; sourceTree = ""; }; - 166FE6A4BC5475673619A7EDC6991C51 /* SocketEngineClient.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEngineClient.swift; path = Source/SocketEngineClient.swift; sourceTree = ""; }; + 0F244CCBBA45069AA8A524715B8E5966 /* SocketAckManager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketAckManager.swift; path = Source/SocketAckManager.swift; sourceTree = ""; }; + 117F685036DDF69767FA0894A36AFD79 /* SocketPacket.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketPacket.swift; path = Source/SocketPacket.swift; sourceTree = ""; }; + 1670BB5EB79304C745E1AE522C2461EE /* SocketEngineSpec.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEngineSpec.swift; path = Source/SocketEngineSpec.swift; sourceTree = ""; }; 1B203281D5F24899CA64B5889E2E8643 /* Pods-Arcohol-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-Arcohol-resources.sh"; sourceTree = ""; }; - 1BDBAD22A8C5C840F186680CEB94E2B3 /* SSLSecurity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Source/SSLSecurity.swift; sourceTree = ""; }; - 25C3095B25C6E5A4B8CF6B4236CDF1AF /* SocketEnginePacketType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEnginePacketType.swift; path = Source/SocketEnginePacketType.swift; sourceTree = ""; }; - 2815F87124A5D4BE841207E934FA6D24 /* SocketEventHandler.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEventHandler.swift; path = Source/SocketEventHandler.swift; sourceTree = ""; }; - 2DE34C6C99418B3D68A58C5C9BD7F185 /* Socket.IO-Client-Swift-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Socket.IO-Client-Swift-umbrella.h"; sourceTree = ""; }; + 29A3BB339105AF5BC77EB85BD3CB18E6 /* SocketLogger.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketLogger.swift; path = Source/SocketLogger.swift; sourceTree = ""; }; + 2B1526DC8C1273F235789BF159D7714F /* SocketClientManager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketClientManager.swift; path = Source/SocketClientManager.swift; sourceTree = ""; }; + 31F0F03BBE73D643AD0486ADFE0A8AC5 /* SocketEngine.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEngine.swift; path = Source/SocketEngine.swift; sourceTree = ""; }; + 320E64E91F0F5C8DABC045FC2BF66DF1 /* SocketIOClientSpec.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketIOClientSpec.swift; path = Source/SocketIOClientSpec.swift; sourceTree = ""; }; + 38EAE89FD26A461FD18EFD671BC2A669 /* SocketIOClient.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketIOClient.swift; path = Source/SocketIOClient.swift; sourceTree = ""; }; 3BE41648AABD7EEF14E180A676511FFB /* Pods-Arcohol-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-Arcohol-dummy.m"; sourceTree = ""; }; - 3C50D7AABBEC7F19B9FD8A492CA6399E /* Socket.IO-Client-Swift.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Socket.IO-Client-Swift.xcconfig"; sourceTree = ""; }; + 3F57EC4469168DB9A573C09EAF2AEF49 /* Socket.IO-Client-Swift-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Socket.IO-Client-Swift-umbrella.h"; sourceTree = ""; }; 401E355ACC7A4E12C202F216778E9B4E /* Pods-Arcohol-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-Arcohol-acknowledgements.markdown"; sourceTree = ""; }; + 40C539E114ECE2F3CF5FC273633E7F1A /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 40CD5CE0B1FA769C5E4189E9D0B2E83C /* Pods-Arcohol-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-Arcohol-umbrella.h"; sourceTree = ""; }; - 4551330B1096E79150485203522B1A03 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 502EDA3C32A8FC048F415CE623D152DB /* SocketPacket.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketPacket.swift; path = Source/SocketPacket.swift; sourceTree = ""; }; - 58B69047D3D50DBCBE7EC73BD7A6B885 /* SocketAnyEvent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketAnyEvent.swift; path = Source/SocketAnyEvent.swift; sourceTree = ""; }; - 625EB61367D5A09ADDB64EBA4E8C3C9D /* SocketIOClientStatus.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketIOClientStatus.swift; path = Source/SocketIOClientStatus.swift; sourceTree = ""; }; + 4E852147BB8CA11C60363B97C1193E41 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 51D342D3CD8230E8928AFA54BF2F79D0 /* SocketEngineClient.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEngineClient.swift; path = Source/SocketEngineClient.swift; sourceTree = ""; }; + 525F0BEBFC24363C1C12BFED1C52E09A /* SocketEnginePacketType.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEnginePacketType.swift; path = Source/SocketEnginePacketType.swift; sourceTree = ""; }; + 5603ECF44D6231ED2C54E8BC2F385A37 /* SocketEngineWebsocket.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEngineWebsocket.swift; path = Source/SocketEngineWebsocket.swift; sourceTree = ""; }; + 670BE73CF5968D8D6D6C8AAC526F90E2 /* SocketStringReader.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketStringReader.swift; path = Source/SocketStringReader.swift; sourceTree = ""; }; + 696543B53FC53FFDD264779FD4A0A353 /* Pods_Arcohol.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Arcohol.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 6AE9ACCB4FBAE731DCA98FD8DB00CF2B /* SocketParsable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketParsable.swift; path = Source/SocketParsable.swift; sourceTree = ""; }; 6B335879329C16DE49266EEABC5A8C6C /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 7B922915C6A8FAB2E50CDFFC28FD0F01 /* WebSocket.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Source/WebSocket.swift; sourceTree = ""; }; - 822F51C720958FCAD37DFD889C32CA33 /* SocketIOClientSpec.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketIOClientSpec.swift; path = Source/SocketIOClientSpec.swift; sourceTree = ""; }; + 6D9571AF94B7FB655E7868AEF99404CB /* SocketAnyEvent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketAnyEvent.swift; path = Source/SocketAnyEvent.swift; sourceTree = ""; }; + 87905EC17B5665096942646DB7542569 /* Socket.IO-Client-Swift-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Socket.IO-Client-Swift-dummy.m"; sourceTree = ""; }; 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; - 99BE209484D9FE966D8F4C9E9762326D /* SocketAckManager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketAckManager.swift; path = Source/SocketAckManager.swift; sourceTree = ""; }; + 9693A3F4FEDC4DE12781103EE82CB97D /* SocketIOClientConfiguration.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketIOClientConfiguration.swift; path = Source/SocketIOClientConfiguration.swift; sourceTree = ""; }; + 996BB3B147D524EF800F2194B91709F1 /* SSLSecurity.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SSLSecurity.swift; path = Source/SSLSecurity.swift; sourceTree = ""; }; + 9B59BDFD692606D25A027C43E6C89A5C /* SocketAckEmitter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketAckEmitter.swift; path = Source/SocketAckEmitter.swift; sourceTree = ""; }; + 9F9012D1CF800972BED941165B70893F /* Socket.IO-Client-Swift.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Socket.IO-Client-Swift.xcconfig"; sourceTree = ""; }; A815CCA81B4C721F1241E47248BE5DAD /* Pods-Arcohol.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Arcohol.release.xcconfig"; sourceTree = ""; }; - A8FF773F767E909FA900F67BAF08AF6A /* SocketClientManager.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketClientManager.swift; path = Source/SocketClientManager.swift; sourceTree = ""; }; - AEB5025F8DFEEB35BA0CA8D68DBD5DBB /* SocketStringReader.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketStringReader.swift; path = Source/SocketStringReader.swift; sourceTree = ""; }; - B29865E9455BF96BB3F1C9D1314A2A33 /* SocketAckEmitter.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketAckEmitter.swift; path = Source/SocketAckEmitter.swift; sourceTree = ""; }; - B74B5E2E87423A29A9634BCAF68F39C8 /* SocketIOClient.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketIOClient.swift; path = Source/SocketIOClient.swift; sourceTree = ""; }; - B8E646DB4E27C271B3772BD011E03A38 /* SocketIOClientOption.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketIOClientOption.swift; path = Source/SocketIOClientOption.swift; sourceTree = ""; }; - BA28E93B3F91F281A7562A9D21D52D9C /* SocketEngine.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEngine.swift; path = Source/SocketEngine.swift; sourceTree = ""; }; - C6BE8EE8A38ECE687B6CAC84498111AC /* Socket.IO-Client-Swift-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Socket.IO-Client-Swift-dummy.m"; sourceTree = ""; }; - C7655864815FAB2CDD140E00E5078DBE /* SocketTypes.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketTypes.swift; path = Source/SocketTypes.swift; sourceTree = ""; }; - CA4D8C7D0F3EDB74DB8692D8D7ABA6B6 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + AC6DB44BEB912798F945A7288622BC11 /* SocketIOClientOption.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketIOClientOption.swift; path = Source/SocketIOClientOption.swift; sourceTree = ""; }; CEC22C73C1608DFA5D5D78BDCB218219 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; }; - D09B0AEC21752DCC4DFA00386555EBD5 /* SocketParsable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketParsable.swift; path = Source/SocketParsable.swift; sourceTree = ""; }; - D9D3C0A3B1755EA912B83795ED3063FB /* SocketLogger.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketLogger.swift; path = Source/SocketLogger.swift; sourceTree = ""; }; - DB53A73CD62DFA07EFA9FA89C144D96E /* Socket.IO-Client-Swift.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Socket.IO-Client-Swift.modulemap"; sourceTree = ""; }; - DC1035ED4CAB59B50944F190B5B6E5ED /* SocketEngineSpec.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEngineSpec.swift; path = Source/SocketEngineSpec.swift; sourceTree = ""; }; + E330F9F321E4350813202BD51BC3F67A /* SocketEnginePollable.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketEnginePollable.swift; path = Source/SocketEnginePollable.swift; sourceTree = ""; }; E3C064F8397C36D065779ECB096E0238 /* Pods-Arcohol.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-Arcohol.modulemap"; sourceTree = ""; }; EFA56843B4CFBEEE36AD7836ACA072F6 /* Pods-Arcohol.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-Arcohol.debug.xcconfig"; sourceTree = ""; }; - F37F6C04579156D158BC2A303AC08ED5 /* SocketExtensions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketExtensions.swift; path = Source/SocketExtensions.swift; sourceTree = ""; }; + F306E01D91D86C36440F2FAD6F23C988 /* SocketIOClientStatus.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketIOClientStatus.swift; path = Source/SocketIOClientStatus.swift; sourceTree = ""; }; + F36F6652863175FDE16D90EF0BEF19B7 /* WebSocket.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = Source/WebSocket.swift; sourceTree = ""; }; + F57959BBDDA9210163F0CBFB7527AE25 /* Socket.IO-Client-Swift-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Socket.IO-Client-Swift-prefix.pch"; sourceTree = ""; }; + F83D48B450D21095FBEC2185F938BE67 /* SocketExtensions.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketExtensions.swift; path = Source/SocketExtensions.swift; sourceTree = ""; }; + FD80A7ADAB722173423A36E7463C4AFB /* SocketTypes.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; name = SocketTypes.swift; path = Source/SocketTypes.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -114,21 +116,36 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 0E43C302EA1016DC8CBE932C0326B474 /* Pods */ = { + 06FCB82AA93FF76BA547AB1D3AB0ADFF /* Socket.IO-Client-Swift */ = { isa = PBXGroup; children = ( - B5ABB993FD7DA2179EFDB1B82DE31638 /* Socket.IO-Client-Swift */, + 9B59BDFD692606D25A027C43E6C89A5C /* SocketAckEmitter.swift */, + 0F244CCBBA45069AA8A524715B8E5966 /* SocketAckManager.swift */, + 6D9571AF94B7FB655E7868AEF99404CB /* SocketAnyEvent.swift */, + 2B1526DC8C1273F235789BF159D7714F /* SocketClientManager.swift */, + 31F0F03BBE73D643AD0486ADFE0A8AC5 /* SocketEngine.swift */, + 51D342D3CD8230E8928AFA54BF2F79D0 /* SocketEngineClient.swift */, + 525F0BEBFC24363C1C12BFED1C52E09A /* SocketEnginePacketType.swift */, + E330F9F321E4350813202BD51BC3F67A /* SocketEnginePollable.swift */, + 1670BB5EB79304C745E1AE522C2461EE /* SocketEngineSpec.swift */, + 5603ECF44D6231ED2C54E8BC2F385A37 /* SocketEngineWebsocket.swift */, + 043D782257DB50BC7B57630A5BD577C6 /* SocketEventHandler.swift */, + F83D48B450D21095FBEC2185F938BE67 /* SocketExtensions.swift */, + 38EAE89FD26A461FD18EFD671BC2A669 /* SocketIOClient.swift */, + 9693A3F4FEDC4DE12781103EE82CB97D /* SocketIOClientConfiguration.swift */, + AC6DB44BEB912798F945A7288622BC11 /* SocketIOClientOption.swift */, + 320E64E91F0F5C8DABC045FC2BF66DF1 /* SocketIOClientSpec.swift */, + F306E01D91D86C36440F2FAD6F23C988 /* SocketIOClientStatus.swift */, + 29A3BB339105AF5BC77EB85BD3CB18E6 /* SocketLogger.swift */, + 117F685036DDF69767FA0894A36AFD79 /* SocketPacket.swift */, + 6AE9ACCB4FBAE731DCA98FD8DB00CF2B /* SocketParsable.swift */, + 670BE73CF5968D8D6D6C8AAC526F90E2 /* SocketStringReader.swift */, + FD80A7ADAB722173423A36E7463C4AFB /* SocketTypes.swift */, + 996BB3B147D524EF800F2194B91709F1 /* SSLSecurity.swift */, + F36F6652863175FDE16D90EF0BEF19B7 /* WebSocket.swift */, + C964BA47013163C7F484F1A789B76193 /* Support Files */, ); - name = Pods; - sourceTree = ""; - }; - 1CDF3417F78DF43BBCE4EC9213580D9D /* Products */ = { - isa = PBXGroup; - children = ( - 069FB6E5640A7B99DEB8F8D257F66FE1 /* Pods_Arcohol.framework */, - 4551330B1096E79150485203522B1A03 /* SocketIOClientSwift.framework */, - ); - name = Products; + path = "Socket.IO-Client-Swift"; sourceTree = ""; }; 3DCAB2B7CDE207B3958B6CB957FCC758 /* iOS */ = { @@ -147,68 +164,54 @@ name = "Targets Support Files"; sourceTree = ""; }; + 706F69B59FBFAF23670F4512D9E9BA3B /* Products */ = { + isa = PBXGroup; + children = ( + 696543B53FC53FFDD264779FD4A0A353 /* Pods_Arcohol.framework */, + 40C539E114ECE2F3CF5FC273633E7F1A /* SocketIO.framework */, + ); + name = Products; + sourceTree = ""; + }; 7DB346D0F39D3F0E887471402A8071AB = { isa = PBXGroup; children = ( 93A4A3777CF96A4AAC1D13BA6DCCEA73 /* Podfile */, BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */, - 0E43C302EA1016DC8CBE932C0326B474 /* Pods */, - 1CDF3417F78DF43BBCE4EC9213580D9D /* Products */, + 87AC66C613B2A233B3C94B7B15C485E3 /* Pods */, + 706F69B59FBFAF23670F4512D9E9BA3B /* Products */, 63FEE20CC24D5FA66E78E537C72516E1 /* Targets Support Files */, ); sourceTree = ""; }; - A4E1078ED347FE1F68D710BA603943A1 /* Support Files */ = { + 87AC66C613B2A233B3C94B7B15C485E3 /* Pods */ = { isa = PBXGroup; children = ( - CA4D8C7D0F3EDB74DB8692D8D7ABA6B6 /* Info.plist */, - DB53A73CD62DFA07EFA9FA89C144D96E /* Socket.IO-Client-Swift.modulemap */, - 3C50D7AABBEC7F19B9FD8A492CA6399E /* Socket.IO-Client-Swift.xcconfig */, - C6BE8EE8A38ECE687B6CAC84498111AC /* Socket.IO-Client-Swift-dummy.m */, - 1079B0BDBE38B922CCF99B449589A936 /* Socket.IO-Client-Swift-prefix.pch */, - 2DE34C6C99418B3D68A58C5C9BD7F185 /* Socket.IO-Client-Swift-umbrella.h */, + 06FCB82AA93FF76BA547AB1D3AB0ADFF /* Socket.IO-Client-Swift */, ); - name = "Support Files"; - path = "../Target Support Files/Socket.IO-Client-Swift"; + name = Pods; sourceTree = ""; }; - B5ABB993FD7DA2179EFDB1B82DE31638 /* Socket.IO-Client-Swift */ = { + BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = { isa = PBXGroup; children = ( - B29865E9455BF96BB3F1C9D1314A2A33 /* SocketAckEmitter.swift */, - 99BE209484D9FE966D8F4C9E9762326D /* SocketAckManager.swift */, - 58B69047D3D50DBCBE7EC73BD7A6B885 /* SocketAnyEvent.swift */, - A8FF773F767E909FA900F67BAF08AF6A /* SocketClientManager.swift */, - BA28E93B3F91F281A7562A9D21D52D9C /* SocketEngine.swift */, - 166FE6A4BC5475673619A7EDC6991C51 /* SocketEngineClient.swift */, - 25C3095B25C6E5A4B8CF6B4236CDF1AF /* SocketEnginePacketType.swift */, - 1539D268AB6B09F93E243519B2AE278F /* SocketEnginePollable.swift */, - DC1035ED4CAB59B50944F190B5B6E5ED /* SocketEngineSpec.swift */, - 0A9E6DE3609E206DF66F748B3276E73E /* SocketEngineWebsocket.swift */, - 2815F87124A5D4BE841207E934FA6D24 /* SocketEventHandler.swift */, - F37F6C04579156D158BC2A303AC08ED5 /* SocketExtensions.swift */, - B74B5E2E87423A29A9634BCAF68F39C8 /* SocketIOClient.swift */, - B8E646DB4E27C271B3772BD011E03A38 /* SocketIOClientOption.swift */, - 822F51C720958FCAD37DFD889C32CA33 /* SocketIOClientSpec.swift */, - 625EB61367D5A09ADDB64EBA4E8C3C9D /* SocketIOClientStatus.swift */, - D9D3C0A3B1755EA912B83795ED3063FB /* SocketLogger.swift */, - 502EDA3C32A8FC048F415CE623D152DB /* SocketPacket.swift */, - D09B0AEC21752DCC4DFA00386555EBD5 /* SocketParsable.swift */, - AEB5025F8DFEEB35BA0CA8D68DBD5DBB /* SocketStringReader.swift */, - C7655864815FAB2CDD140E00E5078DBE /* SocketTypes.swift */, - 1BDBAD22A8C5C840F186680CEB94E2B3 /* SSLSecurity.swift */, - 7B922915C6A8FAB2E50CDFFC28FD0F01 /* WebSocket.swift */, - A4E1078ED347FE1F68D710BA603943A1 /* Support Files */, + 3DCAB2B7CDE207B3958B6CB957FCC758 /* iOS */, ); - path = "Socket.IO-Client-Swift"; + name = Frameworks; sourceTree = ""; }; - BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = { + C964BA47013163C7F484F1A789B76193 /* Support Files */ = { isa = PBXGroup; children = ( - 3DCAB2B7CDE207B3958B6CB957FCC758 /* iOS */, + 4E852147BB8CA11C60363B97C1193E41 /* Info.plist */, + 05DD98DF656FDC7D8E64CD40CC3F4047 /* Socket.IO-Client-Swift.modulemap */, + 9F9012D1CF800972BED941165B70893F /* Socket.IO-Client-Swift.xcconfig */, + 87905EC17B5665096942646DB7542569 /* Socket.IO-Client-Swift-dummy.m */, + F57959BBDDA9210163F0CBFB7527AE25 /* Socket.IO-Client-Swift-prefix.pch */, + 3F57EC4469168DB9A573C09EAF2AEF49 /* Socket.IO-Client-Swift-umbrella.h */, ); - name = Frameworks; + name = "Support Files"; + path = "../Target Support Files/Socket.IO-Client-Swift"; sourceTree = ""; }; DFE02B4FC364C71CD7AA950A2E629A02 /* Pods-Arcohol */ = { @@ -266,14 +269,14 @@ ); name = "Pods-Arcohol"; productName = "Pods-Arcohol"; - productReference = 069FB6E5640A7B99DEB8F8D257F66FE1 /* Pods_Arcohol.framework */; + productReference = 696543B53FC53FFDD264779FD4A0A353 /* Pods_Arcohol.framework */; productType = "com.apple.product-type.framework"; }; 817A78155994576628C43D95A52F7D72 /* Socket.IO-Client-Swift */ = { isa = PBXNativeTarget; buildConfigurationList = E80894D3310EFBE9D1338B69302D12A9 /* Build configuration list for PBXNativeTarget "Socket.IO-Client-Swift" */; buildPhases = ( - 5056A50BA7DA6DEBA32A4B5B79728E59 /* Sources */, + 04E2F18F190936066695FB0EFA8AC223 /* Sources */, B86D9465EB2A2EB06FF85170C11F5A3A /* Frameworks */, BCFD74671CC1E7B6518EFC34B382E70E /* Headers */, ); @@ -283,7 +286,7 @@ ); name = "Socket.IO-Client-Swift"; productName = "Socket.IO-Client-Swift"; - productReference = 4551330B1096E79150485203522B1A03 /* SocketIOClientSwift.framework */; + productReference = 40C539E114ECE2F3CF5FC273633E7F1A /* SocketIO.framework */; productType = "com.apple.product-type.framework"; }; /* End PBXNativeTarget section */ @@ -303,7 +306,7 @@ en, ); mainGroup = 7DB346D0F39D3F0E887471402A8071AB; - productRefGroup = 1CDF3417F78DF43BBCE4EC9213580D9D /* Products */; + productRefGroup = 706F69B59FBFAF23670F4512D9E9BA3B /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( @@ -314,34 +317,35 @@ /* End PBXProject section */ /* Begin PBXSourcesBuildPhase section */ - 5056A50BA7DA6DEBA32A4B5B79728E59 /* Sources */ = { + 04E2F18F190936066695FB0EFA8AC223 /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 14011724990E2F6C0AF7DDB854176638 /* Socket.IO-Client-Swift-dummy.m in Sources */, - 234F53C3472B6509B3808A7487CE8DBA /* SocketAckEmitter.swift in Sources */, - A061F7ED6F385A4065B69218A9D8C844 /* SocketAckManager.swift in Sources */, - 5A8275AFF81D9C96BCDA17AF1C6D131F /* SocketAnyEvent.swift in Sources */, - 03CB6B1C98525AD0979684C025FD5E5E /* SocketClientManager.swift in Sources */, - 6B1F200197020B857719659A7E20B040 /* SocketEngine.swift in Sources */, - 91B3FD542CF053544A54B194F5DA3EC8 /* SocketEngineClient.swift in Sources */, - 817790FDBEB293D4B5A8F8051419F7EE /* SocketEnginePacketType.swift in Sources */, - 7C3F612FB7AB60C7DB523BAF6D51328F /* SocketEnginePollable.swift in Sources */, - C2601C14EF4AF22724C31CBEE1371578 /* SocketEngineSpec.swift in Sources */, - DE3ADBE4B6F607DF2BA016A77F375D95 /* SocketEngineWebsocket.swift in Sources */, - 527B8F6B91FD83DAA0347E3F062DE498 /* SocketEventHandler.swift in Sources */, - D085DEC0BAAA33ED2102E739CB7A2306 /* SocketExtensions.swift in Sources */, - CC9F84C5C170FB4E35314F8993B79659 /* SocketIOClient.swift in Sources */, - 049DDDD7FE558D16C05DDC448352E073 /* SocketIOClientOption.swift in Sources */, - 29FB02244BCA51391D906720112C1B76 /* SocketIOClientSpec.swift in Sources */, - 912EA989E866FD86F1C237C184F54D6A /* SocketIOClientStatus.swift in Sources */, - 5610EE1D21C36C0556713B72955A331F /* SocketLogger.swift in Sources */, - 73424D948E7D2A6B01CB0C0C57F60B1B /* SocketPacket.swift in Sources */, - 5AD7313D104764FF60FBFBFD76B1D8EF /* SocketParsable.swift in Sources */, - F0B2CB6984CD2572A4BC90A92DE712FF /* SocketStringReader.swift in Sources */, - 4331472AD5477A7D9E2CB4DBB7F08132 /* SocketTypes.swift in Sources */, - 6F4FE59B12D6BC7352222B79D6EFC44C /* SSLSecurity.swift in Sources */, - ED210888D25EAD27C921F2E220FCCE6F /* WebSocket.swift in Sources */, + 45AC0A69712A48D3381E223356302221 /* Socket.IO-Client-Swift-dummy.m in Sources */, + 18D5F01ED03AA00A14BC24E1F20EBEA6 /* SocketAckEmitter.swift in Sources */, + D96A8934D0D8BCEB3A1B1ABDC3B07A39 /* SocketAckManager.swift in Sources */, + 3CAFF869002D41A4F1DFDAF00466A687 /* SocketAnyEvent.swift in Sources */, + 66B0F80F7D00E5141CB3EAB3EA4EE28D /* SocketClientManager.swift in Sources */, + 8C84E1BC54EF785AD64533B260CF0193 /* SocketEngine.swift in Sources */, + 88463E6CFA34ED3854192C5B9A1DDAC2 /* SocketEngineClient.swift in Sources */, + 062E86AFFB047735919651497656C774 /* SocketEnginePacketType.swift in Sources */, + 03C30702E1993CA7413C8D6996DBAFE9 /* SocketEnginePollable.swift in Sources */, + C362EF4CB2838AE65D746B10BF3272B2 /* SocketEngineSpec.swift in Sources */, + 3579B5BA0B1D6134CB3E7C4190DDCE91 /* SocketEngineWebsocket.swift in Sources */, + 523F875EFEFD9BE5B34A2A1E2C164C4E /* SocketEventHandler.swift in Sources */, + 66117ECBD4A5322564796765B04E7A3A /* SocketExtensions.swift in Sources */, + 53C42BFA16212B5964E6BCD4873A58AA /* SocketIOClient.swift in Sources */, + F2E4CAC7605E553DC9B1795EDDE003C4 /* SocketIOClientConfiguration.swift in Sources */, + FEF096B0F01D05C6474B89472B4B999F /* SocketIOClientOption.swift in Sources */, + 82796CCBECD04E6D62AE6BABF2307CF0 /* SocketIOClientSpec.swift in Sources */, + 186694AA6A5F32E3506B6C9DBB5E7BA7 /* SocketIOClientStatus.swift in Sources */, + E3DE2F998F4CC68E36A6B28306E0D85D /* SocketLogger.swift in Sources */, + A65E7C98E5AA2103F0A7F3F0101BB2B4 /* SocketPacket.swift in Sources */, + CC1F5508A94C491F045BA087E327912A /* SocketParsable.swift in Sources */, + B3FF76737F84E0814C07F2CA361C7EBC /* SocketStringReader.swift in Sources */, + 14CD6432BD66911BF0756CCA3719B838 /* SocketTypes.swift in Sources */, + 0810A6DD7E08F305A98BCE35CCFED5E3 /* SSLSecurity.swift in Sources */, + FB1720D79CF4AF499E5987765D5A2A70 /* WebSocket.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -432,9 +436,9 @@ }; name = Release; }; - 5CC0FCCDCA0BA54856A56E4562F3AADB /* Release */ = { + 652C4FE3D8A3962FFB280805783B946E /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 3C50D7AABBEC7F19B9FD8A492CA6399E /* Socket.IO-Client-Swift.xcconfig */; + baseConfigurationReference = 9F9012D1CF800972BED941165B70893F /* Socket.IO-Client-Swift.xcconfig */; buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; @@ -452,9 +456,10 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MODULEMAP_FILE = "Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift.modulemap"; MTL_ENABLE_DEBUG_INFO = NO; - PRODUCT_NAME = SocketIOClientSwift; + PRODUCT_NAME = SocketIO; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -499,9 +504,9 @@ }; name = Release; }; - 9DB2B1580DF1236C35CABED7A593C77A /* Debug */ = { + 86B25AA43DE0049824F9CF5C4E1D6149 /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 3C50D7AABBEC7F19B9FD8A492CA6399E /* Socket.IO-Client-Swift.xcconfig */; + baseConfigurationReference = 9F9012D1CF800972BED941165B70893F /* Socket.IO-Client-Swift.xcconfig */; buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; CURRENT_PROJECT_VERSION = 1; @@ -519,10 +524,11 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MODULEMAP_FILE = "Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift.modulemap"; MTL_ENABLE_DEBUG_INFO = YES; - PRODUCT_NAME = SocketIOClientSwift; + PRODUCT_NAME = SocketIO; SDKROOT = iphoneos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -595,8 +601,8 @@ E80894D3310EFBE9D1338B69302D12A9 /* Build configuration list for PBXNativeTarget "Socket.IO-Client-Swift" */ = { isa = XCConfigurationList; buildConfigurations = ( - 9DB2B1580DF1236C35CABED7A593C77A /* Debug */, - 5CC0FCCDCA0BA54856A56E4562F3AADB /* Release */, + 86B25AA43DE0049824F9CF5C4E1D6149 /* Debug */, + 652C4FE3D8A3962FFB280805783B946E /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/Pods/Socket.IO-Client-Swift/README.md b/Pods/Socket.IO-Client-Swift/README.md index 7549222..11ad99f 100644 --- a/Pods/Socket.IO-Client-Swift/README.md +++ b/Pods/Socket.IO-Client-Swift/README.md @@ -5,7 +5,8 @@ Socket.IO-client for iOS/OS X. ##Example ```swift -let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8080")!, options: [.Log(true), .ForcePolling(true)]) +import SocketIO +let socket = SocketIOClient(socketURL: URL(string: "http://localhost:8080")!, config: [.log(true), .forcePolling(true)]) socket.on("connect") {data, ack in print("socket connected") @@ -13,7 +14,7 @@ socket.on("connect") {data, ack in socket.on("currentAmount") {data, ack in if let cur = data[0] as? Double { - socket.emitWithAck("canUpdate", cur)(timeoutAfter: 0) {data in + socket.emitWithAck("canUpdate", cur)(0) {data in socket.emit("update", ["amount": cur + 2.50]) } @@ -26,8 +27,9 @@ socket.connect() ##Objective-C Example ```objective-c +@import SocketIO; NSURL* url = [[NSURL alloc] initWithString:@"http://localhost:8080"]; -SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url options:@{@"log": @YES, @"forcePolling": @YES}]; +SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @YES, @"forcePolling": @YES}]; [socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) { NSLog(@"socket connected"); @@ -55,13 +57,17 @@ SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url options:@ - Can be used from Objective-C ##Installation -Requires Swift 2.2/Xcode 7.3 +Requires Swift 3/Xcode 8.x -If you need Swift 2.1/Xcode 7.2 use v5.5.0 (Pre-Swift 2.2 support is no longer maintained) +If you need swift 2.3 use the swift2.3 branch (Pre-Swift 3 support is no longer maintained) -If you need Swift 1.2/Xcode 6.3/4 use v2.4.5 (Pre-Swift 2 support is no longer maintained) +If you need swift 2.2 use 7.x (Pre-Swift 3 support is no longer maintained) -If you need Swift 1.1/Xcode 6.2 use v1.5.2. (Pre-Swift 1.2 support is no longer maintained) +If you need Swift 2.1 use v5.5.0 (Pre-Swift 2.2 support is no longer maintained) + +If you need Swift 1.2 use v2.4.5 (Pre-Swift 2 support is no longer maintained) + +If you need Swift 1.1 use v1.5.2. (Pre-Swift 1.2 support is no longer maintained) Manually (iOS 7+) ----------------- @@ -77,18 +83,18 @@ import PackageDescription let package = Package( name: "YourSocketIOProject", dependencies: [ - .Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 6) + .Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 8) ] ) ``` -Then import `import SocketIOClientSwift`. +Then import `import SocketIO`. Carthage ----------------- Add this line to your `Cartfile`: ``` -github "socketio/socket.io-client-swift" ~> 6.1.6 # Or latest version +github "socketio/socket.io-client-swift" ~> 8.0.1 # Or latest version ``` Run `carthage update --platform ios,macosx`. @@ -101,7 +107,7 @@ Create `Podfile` and add `pod 'Socket.IO-Client-Swift'`: use_frameworks! target 'YourApp' do - pod 'Socket.IO-Client-Swift', '~> 6.1.6' # Or latest version + pod 'Socket.IO-Client-Swift', '~> 8.0.1' # Or latest version end ``` @@ -115,13 +121,13 @@ Import the module: Swift: ```swift -import SocketIOClientSwift +import SocketIO ``` Objective-C: ```Objective-C -@import SocketIOClientSwift; +@import SocketIO; ``` CocoaSeeds @@ -130,7 +136,7 @@ CocoaSeeds Add this line to your `Seedfile`: ``` -github "socketio/socket.io-client-swift", "v6.1.6", :files => "Source/*.swift" # Or latest version +github "socketio/socket.io-client-swift", "v8.0.1", :files => "Source/*.swift" # Or latest version ``` Run `seed install`. @@ -139,7 +145,7 @@ Run `seed install`. ##API Constructors ----------- -`init(var socketURL: NSURL, options: Set = [])` - Creates a new SocketIOClient. options is a Set of SocketIOClientOption. If your socket.io server is secure, you need to specify `https` in your socketURL. +`init(var socketURL: NSURL, config: SocketIOClientConfiguration = [])` - Creates a new SocketIOClient. If your socket.io server is secure, you need to specify `https` in your socketURL. `convenience init(socketURL: NSURL, options: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys. @@ -148,43 +154,43 @@ Options All options are a case of SocketIOClientOption. To get the Objective-C Option, convert the name to lowerCamelCase. ```swift -case ConnectParams([String: AnyObject]) // Dictionary whose contents will be passed with the connection. -case Cookies([NSHTTPCookie]) // An array of NSHTTPCookies. Passed during the handshake. Default is nil. -case DoubleEncodeUTF8(Bool) // Whether or not to double encode utf8. If using the node based server this should be true. Default is true. -case ExtraHeaders([String: String]) // Adds custom headers to the initial request. Default is nil. -case ForcePolling(Bool) // `true` forces the client to use xhr-polling. Default is `false` -case ForceNew(Bool) // Will a create a new engine for each connect. Useful if you find a bug in the engine related to reconnects -case ForceWebsockets(Bool) // `true` forces the client to use WebSockets. Default is `false` -case HandleQueue(dispatch_queue_t) // The dispatch queue that handlers are run on. Default is the main queue. -case Log(Bool) // If `true` socket will log debug messages. Default is false. -case Logger(SocketLogger) // Custom logger that conforms to SocketLogger. Will use the default logging otherwise. -case Nsp(String) // The namespace to connect to. Must begin with /. Default is `/` -case Path(String) // If the server uses a custom path. ex: `"/swift/"`. Default is `""` -case Reconnects(Bool) // Whether to reconnect on server lose. Default is `true` -case ReconnectAttempts(Int) // How many times to reconnect. Default is `-1` (infinite tries) -case ReconnectWait(Int) // Amount of time to wait between reconnects. Default is `10` -case SessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil. -case Secure(Bool) // If the connection should use TLS. Default is false. -case Security(SSLSecurity) // Allows you to set which certs are valid. Useful for SSL pinning. -case SelfSigned(Bool) // Sets WebSocket.selfSignedSSL. Use this if you're using self-signed certs. -case VoipEnabled(Bool) // Only use this option if you're using the client with VoIP services. Changes the way the WebSocket is created. Default is false +case connectParams([String: AnyObject]) // Dictionary whose contents will be passed with the connection. +case cookies([NSHTTPCookie]) // An array of NSHTTPCookies. Passed during the handshake. Default is nil. +case doubleEncodeUTF8(Bool) // Whether or not to double encode utf8. If using the node based server this should be true. Default is true. +case extraHeaders([String: String]) // Adds custom headers to the initial request. Default is nil. +case forcePolling(Bool) // `true` forces the client to use xhr-polling. Default is `false` +case forceNew(Bool) // Will a create a new engine for each connect. Useful if you find a bug in the engine related to reconnects +case forceWebsockets(Bool) // `true` forces the client to use WebSockets. Default is `false` +case handleQueue(dispatch_queue_t) // The dispatch queue that handlers are run on. Default is the main queue. +case log(Bool) // If `true` socket will log debug messages. Default is false. +case logger(SocketLogger) // Custom logger that conforms to SocketLogger. Will use the default logging otherwise. +case nsp(String) // The namespace to connect to. Must begin with /. Default is `/` +case path(String) // If the server uses a custom path. ex: `"/swift/"`. Default is `""` +case reconnects(Bool) // Whether to reconnect on server lose. Default is `true` +case reconnectAttempts(Int) // How many times to reconnect. Default is `-1` (infinite tries) +case reconnectWait(Int) // Amount of time to wait between reconnects. Default is `10` +case sessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil. +case secure(Bool) // If the connection should use TLS. Default is false. +case security(SSLSecurity) // Allows you to set which certs are valid. Useful for SSL pinning. +case selfSigned(Bool) // Sets WebSocket.selfSignedSSL. Use this if you're using self-signed certs. +case voipEnabled(Bool) // Only use this option if you're using the client with VoIP services. Changes the way the WebSocket is created. Default is false ``` Methods ------- -1. `on(event: String, callback: NormalCallback) -> NSUUID` - Adds a handler for an event. Items are passed by an array. `ack` can be used to send an ack when one is requested. See example. Returns a unique id for the handler. -2. `once(event: String, callback: NormalCallback) -> NSUUID` - Adds a handler that will only be executed once. Returns a unique id for the handler. +1. `on(_ event: String, callback: NormalCallback) -> NSUUID` - Adds a handler for an event. Items are passed by an array. `ack` can be used to send an ack when one is requested. See example. Returns a unique id for the handler. +2. `once(_ event: String, callback: NormalCallback) -> NSUUID` - Adds a handler that will only be executed once. Returns a unique id for the handler. 3. `onAny(callback:((event: String, items: AnyObject?)) -> Void)` - Adds a handler for all events. It will be called on any received event. -4. `emit(event: String, _ items: AnyObject...)` - Sends a message. Can send multiple items. -5. `emit(event: String, withItems items: [AnyObject])` - `emit` for Objective-C -6. `emitWithAck(event: String, _ items: AnyObject...) -> (timeoutAfter: UInt64, callback: (NSArray?) -> Void) -> Void` - Sends a message that requests an acknowledgement from the server. Returns a function which you can use to add a handler. See example. Note: The message is not sent until you call the returned function. -7. `emitWithAck(event: String, withItems items: [AnyObject]) -> (UInt64, (NSArray?) -> Void) -> Void` - `emitWithAck` for Objective-C. Note: The message is not sent until you call the returned function. +4. `emit(_ event: String, _ items: AnyObject...)` - Sends a message. Can send multiple items. +5. `emit(_ event: String, withItems items: [AnyObject])` - `emit` for Objective-C +6. `emitWithAck(_ event: String, _ items: AnyObject...) -> (timeoutAfter: UInt64, callback: (NSArray?) -> Void) -> Void` - Sends a message that requests an acknowledgement from the server. Returns a function which you can use to add a handler. See example. Note: The message is not sent until you call the returned function. +7. `emitWithAck(_ event: String, withItems items: [AnyObject]) -> (UInt64, (NSArray?) -> Void) -> Void` - `emitWithAck` for Objective-C. Note: The message is not sent until you call the returned function. 8. `connect()` - Establishes a connection to the server. A "connect" event is fired upon successful connection. 9. `connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called. 10. `disconnect()` - Closes the socket. Reopening a disconnected socket is not fully tested. 11. `reconnect()` - Causes the client to reconnect to the server. -12. `joinNamespace(namespace: String)` - Causes the client to join namespace. Shouldn't need to be called unless you change namespaces manually. +12. `joinNamespace(_ namespace: String)` - Causes the client to join namespace. Shouldn't need to be called unless you change namespaces manually. 13. `leaveNamespace()` - Causes the client to leave the nsp and go back to / -14. `off(event: String)` - Removes all event handlers for event. +14. `off(_ event: String)` - Removes all event handlers for event. 15. `off(id id: NSUUID)` - Removes the event that corresponds to id. 16. `removeAllHandlers()` - Removes all handlers. diff --git a/Pods/Socket.IO-Client-Swift/Source/SSLSecurity.swift b/Pods/Socket.IO-Client-Swift/Source/SSLSecurity.swift index 4ce1f7a..98c9d86 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SSLSecurity.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SSLSecurity.swift @@ -24,8 +24,8 @@ import Foundation import Security public class SSLCert : NSObject { - var certData: NSData? - var key: SecKeyRef? + var certData: Data? + var key: SecKey? /** Designated init for certificates @@ -34,7 +34,7 @@ public class SSLCert : NSObject { - returns: a representation security object to be used with */ - public init(data: NSData) { + public init(data: Data) { self.certData = data } @@ -45,7 +45,7 @@ public class SSLCert : NSObject { - returns: a representation security object to be used with */ - public init(key: SecKeyRef) { + public init(key: SecKey) { self.key = key } } @@ -54,8 +54,8 @@ public class SSLSecurity : NSObject { public var validatedDN = true //should the domain name be validated? var isReady = false //is the key processing done? - var certificates: [NSData]? //the certificates - @nonobjc var pubKeys: [SecKeyRef]? //the public keys + var certificates: [Data]? //the certificates + var pubKeys: [SecKey]? //the public keys var usePublicKeys = false //use public keys or certificate validation? /** @@ -66,12 +66,12 @@ public class SSLSecurity : NSObject { - returns: a representation security object to be used with */ public convenience init(usePublicKeys: Bool = false) { - let paths = NSBundle.mainBundle().pathsForResourcesOfType("cer", inDirectory: ".") + 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)) + certs.append(SSLCert(data: data as Data)) } return certs } @@ -88,15 +88,15 @@ public class SSLSecurity : NSObject { - returns: a representation security object to be used with */ public init(certs: [SSLCert], usePublicKeys: Bool) { - super.init() - self.usePublicKeys = usePublicKeys + super.init() + if self.usePublicKeys { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0)) { - let pubKeys = certs.reduce([SecKeyRef]()) { (pubKeys: [SecKeyRef], cert: SSLCert) -> [SecKeyRef] in + DispatchQueue.global(qos: .default).async { + let pubKeys = certs.reduce([SecKey]()) { (pubKeys: [SecKey], cert: SSLCert) -> [SecKey] in var pubKeys = pubKeys - if let data = cert.certData where cert.key == nil { + if let data = cert.certData, cert.key == nil { cert.key = self.extractPublicKey(data) } if let key = cert.key { @@ -109,7 +109,7 @@ public class SSLSecurity : NSObject { self.isReady = true } } else { - let certificates = certs.reduce([NSData]()) { (certificates: [NSData], cert: SSLCert) -> [NSData] in + let certificates = certs.reduce([Data]()) { (certificates: [Data], cert: SSLCert) -> [Data] in var certificates = certificates if let data = cert.certData { certificates.append(data) @@ -129,26 +129,26 @@ public class SSLSecurity : NSObject { - returns: if the key was successfully validated */ - public func isValid(trust: SecTrustRef, domain: String?) -> Bool { + public func isValid(_ trust: SecTrust, domain: String?) -> Bool { var tries = 0 - while(!self.isReady) { + while !self.isReady { usleep(1000) tries += 1 if tries > 5 { return false //doesn't appear it is going to ever be ready... } } - var policy: SecPolicyRef + var policy: SecPolicy if self.validatedDN { - policy = SecPolicyCreateSSL(true, domain) + policy = SecPolicyCreateSSL(true, domain as NSString?) } else { policy = SecPolicyCreateBasicX509() } SecTrustSetPolicies(trust,policy) if self.usePublicKeys { if let keys = self.pubKeys { - let serverPubKeys = publicKeyChainForTrust(trust) + let serverPubKeys = publicKeyChain(trust) for serverKey in serverPubKeys as [AnyObject] { for key in keys as [AnyObject] { if serverKey.isEqual(key) { @@ -158,16 +158,15 @@ public class SSLSecurity : NSObject { } } } else if let certs = self.certificates { - let serverCerts = certificateChainForTrust(trust) + let serverCerts = certificateChain(trust) var collect = [SecCertificate]() for cert in certs { - collect.append(SecCertificateCreateWithData(nil,cert)!) + collect.append(SecCertificateCreateWithData(nil,cert as CFData)!) } - SecTrustSetAnchorCertificates(trust,collect) - var result: SecTrustResultType = 0 + SecTrustSetAnchorCertificates(trust,collect as NSArray) + var result: SecTrustResultType = .unspecified SecTrustEvaluate(trust,&result) - let r = Int(result) - if r == kSecTrustResultUnspecified || r == kSecTrustResultProceed { + if result == .unspecified || result == .proceed { var trustedCount = 0 for serverCert in serverCerts { for cert in certs { @@ -192,10 +191,10 @@ public class SSLSecurity : NSObject { - returns: a public key */ - func extractPublicKey(data: NSData) -> SecKeyRef? { - guard let cert = SecCertificateCreateWithData(nil, data) else { return nil } + func extractPublicKey(_ data: Data) -> SecKey? { + guard let cert = SecCertificateCreateWithData(nil, data as CFData) else { return nil } - return extractPublicKeyFromCert(cert, policy: SecPolicyCreateBasicX509()) + return extractPublicKey(cert, policy: SecPolicyCreateBasicX509()) } /** @@ -205,13 +204,12 @@ public class SSLSecurity : NSObject { - returns: a public key */ - func extractPublicKeyFromCert(cert: SecCertificate, policy: SecPolicy) -> SecKeyRef? { + func extractPublicKey(_ cert: SecCertificate, policy: SecPolicy) -> SecKey? { var possibleTrust: SecTrust? SecTrustCreateWithCertificates(cert, policy, &possibleTrust) guard let trust = possibleTrust else { return nil } - - var result: SecTrustResultType = 0 + var result: SecTrustResultType = .unspecified SecTrustEvaluate(trust, &result) return SecTrustCopyPublicKey(trust) } @@ -223,11 +221,11 @@ public class SSLSecurity : NSObject { - returns: the certificate chain for the trust */ - func certificateChainForTrust(trust: SecTrustRef) -> [NSData] { - let certificates = (0.. [NSData] in + func certificateChain(_ trust: SecTrust) -> [Data] { + let certificates = (0.. [Data] in var certificates = certificates let cert = SecTrustGetCertificateAtIndex(trust, index) - certificates.append(SecCertificateCopyData(cert!)) + certificates.append(SecCertificateCopyData(cert!) as Data) return certificates } @@ -241,12 +239,12 @@ public class SSLSecurity : NSObject { - returns: the public keys from the certifcate chain for the trust */ - @nonobjc func publicKeyChainForTrust(trust: SecTrustRef) -> [SecKeyRef] { + func publicKeyChain(_ trust: SecTrust) -> [SecKey] { let policy = SecPolicyCreateBasicX509() - let keys = (0.. [SecKeyRef] in + let keys = (0.. [SecKey] in var keys = keys let cert = SecTrustGetCertificateAtIndex(trust, index) - if let key = extractPublicKeyFromCert(cert!, policy: policy) { + if let key = extractPublicKey(cert!, policy: policy) { keys.append(key) } @@ -257,4 +255,4 @@ public class SSLSecurity : NSObject { } -} \ No newline at end of file +} diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketAckEmitter.swift b/Pods/Socket.IO-Client-Swift/Source/SocketAckEmitter.swift index edb2522..511d497 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketAckEmitter.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketAckEmitter.swift @@ -33,15 +33,15 @@ public final class SocketAckEmitter : NSObject { self.ackNum = ackNum } - public func with(items: AnyObject...) { + public func with(_ items: SocketData...) { guard ackNum != -1 else { return } - socket.emitAck(ackNum, withItems: items) + socket.emitAck(ackNum, with: items) } - public func with(items: [AnyObject]) { + public func with(_ items: [Any]) { guard ackNum != -1 else { return } - socket.emitAck(ackNum, withItems: items) + socket.emitAck(ackNum, with: items) } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketAckManager.swift b/Pods/Socket.IO-Client-Swift/Source/SocketAckManager.swift index 682b4f8..ae6a6fa 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketAckManager.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketAckManager.swift @@ -35,7 +35,7 @@ private struct SocketAck : Hashable { self.ack = ack } - init(ack: Int, callback: AckCallback) { + init(ack: Int, callback: @escaping AckCallback) { self.ack = ack self.callback = callback } @@ -52,25 +52,21 @@ private func ==(lhs: SocketAck, rhs: SocketAck) -> Bool { struct SocketAckManager { private var acks = Set(minimumCapacity: 1) - mutating func addAck(ack: Int, callback: AckCallback) { + mutating func addAck(_ ack: Int, callback: @escaping AckCallback) { acks.insert(SocketAck(ack: ack, callback: callback)) } /// Should be called on handle queue - mutating func executeAck(ack: Int, items: [AnyObject], onQueue: dispatch_queue_t) { - let callback = acks.remove(SocketAck(ack: ack)) + mutating func executeAck(_ ack: Int, with items: [Any], onQueue: DispatchQueue) { + let ack = acks.remove(SocketAck(ack: ack)) - dispatch_async(onQueue) { - callback?.callback(items) - } + onQueue.async() { ack?.callback(items) } } /// Should be called on handle queue - mutating func timeoutAck(ack: Int, onQueue: dispatch_queue_t) { - let callback = acks.remove(SocketAck(ack: ack)) + mutating func timeoutAck(_ ack: Int, onQueue: DispatchQueue) { + let ack = acks.remove(SocketAck(ack: ack)) - dispatch_async(onQueue) { - callback?.callback(["NO ACK"]) - } + onQueue.async() { ack?.callback?(["NO ACK"]) } } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketAnyEvent.swift b/Pods/Socket.IO-Client-Swift/Source/SocketAnyEvent.swift index 4c26f0e..b3f2833 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketAnyEvent.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketAnyEvent.swift @@ -26,12 +26,12 @@ import Foundation public final class SocketAnyEvent : NSObject { public let event: String - public let items: NSArray? + public let items: [Any]? override public var description: String { return "SocketAnyEvent: Event: \(event) items: \(items ?? nil)" } - init(event: String, items: NSArray?) { + init(event: String, items: [Any]?) { self.event = event self.items = items } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketClientManager.swift b/Pods/Socket.IO-Client-Swift/Source/SocketClientManager.swift index ae79179..e230272 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketClientManager.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketClientManager.swift @@ -43,12 +43,12 @@ import Foundation manager["room1"]?.emit("hello") ``` */ -public final class SocketClientManager : NSObject { - public static let sharedManager = SocketClientManager() +open class SocketClientManager : NSObject { + open static let sharedManager = SocketClientManager() private var sockets = [String: SocketIOClient]() - public subscript(string: String) -> SocketIOClient? { + open subscript(string: String) -> SocketIOClient? { get { return sockets[string] } @@ -58,25 +58,25 @@ public final class SocketClientManager : NSObject { } } - public func addSocket(socket: SocketIOClient, labeledAs label: String) { + open func addSocket(_ socket: SocketIOClient, labeledAs label: String) { sockets[label] = socket } - public func removeSocket(withLabel label: String) -> SocketIOClient? { - return sockets.removeValueForKey(label) + open func removeSocket(withLabel label: String) -> SocketIOClient? { + return sockets.removeValue(forKey: label) } - public func removeSocket(socket: SocketIOClient) -> SocketIOClient? { + open func removeSocket(_ socket: SocketIOClient) -> SocketIOClient? { var returnSocket: SocketIOClient? for (label, dictSocket) in sockets where dictSocket === socket { - returnSocket = sockets.removeValueForKey(label) + returnSocket = sockets.removeValue(forKey: label) } return returnSocket } - public func removeSockets() { + open func removeSockets() { sockets.removeAll() } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketEngine.swift b/Pods/Socket.IO-Client-Swift/Source/SocketEngine.swift index fb41c09..6caf87e 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketEngine.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketEngine.swift @@ -24,24 +24,24 @@ import Foundation -public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePollable, SocketEngineWebsocket { - public let emitQueue = dispatch_queue_create("com.socketio.engineEmitQueue", DISPATCH_QUEUE_SERIAL) - public let handleQueue = dispatch_queue_create("com.socketio.engineHandleQueue", DISPATCH_QUEUE_SERIAL) - public let parseQueue = dispatch_queue_create("com.socketio.engineParseQueue", DISPATCH_QUEUE_SERIAL) +public final class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, SocketEngineWebsocket { + public let emitQueue = DispatchQueue(label: "com.socketio.engineEmitQueue", attributes: []) + public let handleQueue = DispatchQueue(label: "com.socketio.engineHandleQueue", attributes: []) + public let parseQueue = DispatchQueue(label: "com.socketio.engineParseQueue", attributes: []) - public var connectParams: [String: AnyObject]? { + public var connectParams: [String: Any]? { didSet { (urlPolling, urlWebSocket) = createURLs() } } - + public var postWait = [String]() public var waitingForPoll = false public var waitingForPost = false - + public private(set) var closed = false public private(set) var connected = false - public private(set) var cookies: [NSHTTPCookie]? + public private(set) var cookies: [HTTPCookie]? public private(set) var doubleEncodeUTF8 = true public private(set) var extraHeaders: [String: String]? public private(set) var fastUpgrade = false @@ -50,28 +50,28 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo public private(set) var invalidated = false public private(set) var polling = true public private(set) var probing = false - public private(set) var session: NSURLSession? + public private(set) var session: URLSession? public private(set) var sid = "" public private(set) var socketPath = "/engine.io/" - public private(set) var urlPolling = NSURL() - public private(set) var urlWebSocket = NSURL() + public private(set) var urlPolling = URL(string: "http://localhost/")! + public private(set) var urlWebSocket = URL(string: "http://localhost/")! public private(set) var websocket = false public private(set) var ws: WebSocket? public weak var client: SocketEngineClient? - - private weak var sessionDelegate: NSURLSessionDelegate? + + private weak var sessionDelegate: URLSessionDelegate? private let logType = "SocketEngine" - private let url: NSURL - + private let url: URL + private var pingInterval: Double? private var pingTimeout = 0.0 { didSet { pongsMissedMax = Int(pingTimeout / (pingInterval ?? 25)) } } - + private var pongsMissed = 0 private var pongsMissedMax = 0 private var probeWait = ProbeWaitQueue() @@ -80,45 +80,44 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo private var selfSigned = false private var voipEnabled = false - public init(client: SocketEngineClient, url: NSURL, options: Set) { + public init(client: SocketEngineClient, url: URL, config: SocketIOClientConfiguration) { self.client = client self.url = url - - for option in options { + for option in config { switch option { - case let .ConnectParams(params): + case let .connectParams(params): connectParams = params - case let .Cookies(cookies): + case let .cookies(cookies): self.cookies = cookies - case let .DoubleEncodeUTF8(encode): + case let .doubleEncodeUTF8(encode): doubleEncodeUTF8 = encode - case let .ExtraHeaders(headers): + case let .extraHeaders(headers): extraHeaders = headers - case let .SessionDelegate(delegate): + case let .sessionDelegate(delegate): sessionDelegate = delegate - case let .ForcePolling(force): + case let .forcePolling(force): forcePolling = force - case let .ForceWebsockets(force): + case let .forceWebsockets(force): forceWebsockets = force - case let .Path(path): + case let .path(path): socketPath = path if !socketPath.hasSuffix("/") { socketPath += "/" } - case let .VoipEnabled(enable): + case let .voipEnabled(enable): voipEnabled = enable - case let .Secure(secure): + case let .secure(secure): self.secure = secure - case let .Security(security): - self.security = security - case let .SelfSigned(selfSigned): + case let .selfSigned(selfSigned): self.selfSigned = selfSigned + case let .security(security): + self.security = security default: continue } } - + super.init() sessionDelegate = sessionDelegate ?? self @@ -126,17 +125,17 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo (urlPolling, urlWebSocket) = createURLs() } - public convenience init(client: SocketEngineClient, url: NSURL, options: NSDictionary?) { - self.init(client: client, url: url, options: options?.toSocketOptionsSet() ?? []) + public convenience init(client: SocketEngineClient, url: URL, options: NSDictionary?) { + self.init(client: client, url: url, config: options?.toSocketConfiguration() ?? []) } - + deinit { DefaultSocketLogger.Logger.log("Engine is being released", type: logType) closed = true stopPolling() } - - private func checkAndHandleEngineError(msg: String) { + + private func checkAndHandleEngineError(_ msg: String) { do { let dict = try msg.toNSDictionary() guard let error = dict["message"] as? String else { return } @@ -147,80 +146,74 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo 2: Bad handshake request 3: Bad request */ - didError(error) + didError(reason: error) } catch { - client?.engineDidError("Got unknown error from server \(msg)") + client?.engineDidError(reason: "Got unknown error from server \(msg)") } } - private func checkIfMessageIsBase64Binary(message: String) -> Bool { - if message.hasPrefix("b4") { - // binary in base64 string - let noPrefix = message[message.startIndex.advancedBy(2).. (NSURL, NSURL) { + private func createURLs() -> (URL, URL) { if client == nil { - return (NSURL(), NSURL()) + return (URL(string: "http://localhost/")!, URL(string: "http://localhost/")!) } - let urlPolling = NSURLComponents(string: url.absoluteString)! - let urlWebSocket = NSURLComponents(string: url.absoluteString)! + var urlPolling = URLComponents(string: url.absoluteString)! + var urlWebSocket = URLComponents(string: url.absoluteString)! var queryString = "" urlWebSocket.path = socketPath @@ -245,15 +238,15 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo urlWebSocket.percentEncodedQuery = "transport=websocket" + queryString urlPolling.percentEncodedQuery = "transport=polling&b64=1" + queryString - - return (urlPolling.URL!, urlWebSocket.URL!) + + return (urlPolling.url!, urlWebSocket.url!) } private func createWebsocketAndConnect() { - ws = WebSocket(url: urlWebSocketWithSid) - + ws = WebSocket(url: urlWebSocketWithSid as URL) + if cookies != nil { - let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!) + let headers = HTTPCookie.requestHeaderFields(with: cookies!) for (key, value) in headers { ws?.headers[key] = value } @@ -265,46 +258,46 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo } } - ws?.queue = handleQueue + ws?.callbackQueue = handleQueue ws?.voipEnabled = voipEnabled ws?.delegate = self - ws?.selfSignedSSL = selfSigned + ws?.disableSSLCertValidation = selfSigned ws?.security = security ws?.connect() } - - public func didError(error: String) { - DefaultSocketLogger.Logger.error("%@", type: logType, args: error) - client?.engineDidError(error) - disconnect(error) + + public func didError(reason: String) { + DefaultSocketLogger.Logger.error("%@", type: logType, args: reason) + client?.engineDidError(reason: reason) + disconnect(reason: reason) } - + public func disconnect(reason: String) { - guard connected else { return closeOutEngine(reason) } - + guard connected else { return closeOutEngine(reason: reason) } + DefaultSocketLogger.Logger.log("Engine is being closed.", type: logType) - + if closed { - return closeOutEngine(reason) + return closeOutEngine(reason: reason) } - + if websocket { - sendWebSocketMessage("", withType: .Close, withData: []) - closeOutEngine(reason) + sendWebSocketMessage("", withType: .close, withData: []) + closeOutEngine(reason: reason) } else { - disconnectPolling(reason) + disconnectPolling(reason: reason) } } - + // We need to take special care when we're polling that we send it ASAP // Also make sure we're on the emitQueue since we're touching postWait private func disconnectPolling(reason: String) { - dispatch_sync(emitQueue) { - self.postWait.append(String(SocketEnginePacketType.Close.rawValue)) + emitQueue.sync { + self.postWait.append(String(SocketEnginePacketType.close.rawValue)) let req = self.createRequestForPostWithPostWait() - self.doRequest(req) {_, _, _ in } - self.closeOutEngine(reason) + self.doRequest(for: req) {_, _, _ in } + self.closeOutEngine(reason: reason) } } @@ -314,7 +307,7 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo "we'll probably disconnect soon. You should report this.", type: logType) } - sendWebSocketMessage("", withType: .Upgrade, withData: []) + sendWebSocketMessage("", withType: .upgrade, withData: []) websocket = true polling = false fastUpgrade = false @@ -325,131 +318,138 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo private func flushProbeWait() { DefaultSocketLogger.Logger.log("Flushing probe wait", type: logType) - dispatch_async(emitQueue) { + emitQueue.async { for waiter in self.probeWait { self.write(waiter.msg, withType: waiter.type, withData: waiter.data) } - - self.probeWait.removeAll(keepCapacity: false) - + + self.probeWait.removeAll(keepingCapacity: false) + if self.postWait.count != 0 { self.flushWaitingForPostToWebSocket() } } } - + // We had packets waiting for send when we upgraded // Send them raw public func flushWaitingForPostToWebSocket() { guard let ws = self.ws else { return } - + for msg in postWait { - ws.writeString(msg) + ws.write(string: msg) } - - postWait.removeAll(keepCapacity: true) + + postWait.removeAll(keepingCapacity: false) } - private func handleClose(reason: String) { - client?.engineDidClose(reason) + private func handleClose(_ reason: String) { + client?.engineDidClose(reason: reason) } - private func handleMessage(message: String) { + private func handleMessage(_ message: String) { client?.parseEngineMessage(message) } private func handleNOOP() { doPoll() } - + private func handleOpen(openData: String) { - do { - let json = try openData.toNSDictionary() + guard let json = try? openData.toNSDictionary() else { + didError(reason: "Error parsing open packet") - if let sid = json["sid"] as? String { - let upgradeWs: Bool - - self.sid = sid - connected = true - - if let upgrades = json["upgrades"] as? [String] { - upgradeWs = upgrades.contains("websocket") - } else { - upgradeWs = false - } - - if let pingInterval = json["pingInterval"] as? Double, pingTimeout = json["pingTimeout"] as? Double { - self.pingInterval = pingInterval / 1000.0 - self.pingTimeout = pingTimeout / 1000.0 - } - - if !forcePolling && !forceWebsockets && upgradeWs { - createWebsocketAndConnect() - } - - sendPing() - - if !forceWebsockets { - doPoll() - } - - client?.engineDidOpen("Connect") - } - } catch { - didError("Error parsing open packet") + return + } + + guard let sid = json["sid"] as? String else { + didError(reason: "Open packet contained no sid") + + return + } + + let upgradeWs: Bool + + self.sid = sid + connected = true + + if let upgrades = json["upgrades"] as? [String] { + upgradeWs = upgrades.contains("websocket") + } else { + upgradeWs = false + } + + if let pingInterval = json["pingInterval"] as? Double, let pingTimeout = json["pingTimeout"] as? Double { + self.pingInterval = pingInterval / 1000.0 + self.pingTimeout = pingTimeout / 1000.0 } + + if !forcePolling && !forceWebsockets && upgradeWs { + createWebsocketAndConnect() + } + + sendPing() + + if !forceWebsockets { + doPoll() + } + + client?.engineDidOpen(reason: "Connect") } - private func handlePong(pongMessage: String) { + private func handlePong(with message: String) { pongsMissed = 0 // We should upgrade - if pongMessage == "3probe" { + if message == "3probe" { upgradeTransport() } } - - public func parseEngineData(data: NSData) { + + public func parseEngineData(_ data: Data) { DefaultSocketLogger.Logger.log("Got binary data: %@", type: "SocketEngine", args: data) - client?.parseEngineBinaryData(data.subdataWithRange(NSMakeRange(1, data.length - 1))) + + client?.parseEngineBinaryData(data.subdata(in: 1.. pongsMissedMax { - client?.engineDidClose("Ping timeout") + client?.engineDidClose(reason: "Ping timeout") + return } + + guard let pingInterval = pingInterval else { return } - if let pingInterval = pingInterval { - pongsMissed += 1 - write("", withType: .Ping, withData: []) - - let time = dispatch_time(DISPATCH_TIME_NOW, Int64(pingInterval * Double(NSEC_PER_SEC))) - dispatch_after(time, dispatch_get_main_queue()) {[weak self] in - self?.sendPing() - } - } + pongsMissed += 1 + write("", withType: .ping, withData: []) + + let time = DispatchTime.now() + Double(Int64(pingInterval * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC) + DispatchQueue.main.asyncAfter(deadline: time) {[weak self] in self?.sendPing() } } - + // Moves from long-polling to websockets private func upgradeTransport() { if ws?.isConnected ?? false { DefaultSocketLogger.Logger.log("Upgrading transport to WebSockets", type: logType) fastUpgrade = true - sendPollMessage("", withType: .Noop, withData: []) + sendPollMessage("", withType: .noop, withData: []) // After this point, we should not send anymore polling messages } } /// Write a message, independent of transport. - public func write(msg: String, withType type: SocketEnginePacketType, withData data: [NSData]) { - dispatch_async(emitQueue) { + public func write(_ msg: String, withType type: SocketEnginePacketType, withData data: [Data]) { + emitQueue.async { guard self.connected else { return } - + if self.websocket { DefaultSocketLogger.Logger.log("Writing ws: %@ has data: %@", type: self.logType, args: msg, data.count != 0) @@ -518,7 +513,7 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo } } } - + // Delegate methods public func websocketDidConnect(socket: WebSocket) { if !forceWebsockets { @@ -530,23 +525,24 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo polling = false } } - + public func websocketDidDisconnect(socket: WebSocket, error: NSError?) { probing = false - + if closed { - client?.engineDidClose("Disconnect") + client?.engineDidClose(reason: "Disconnect") + return } - + if websocket { connected = false websocket = false - + if let reason = error?.localizedDescription { - didError(reason) + didError(reason: reason) } else { - client?.engineDidClose("Socket Disconnected") + client?.engineDidClose(reason: "Socket Disconnected") } } else { flushProbeWait() @@ -555,9 +551,9 @@ public final class SocketEngine : NSObject, NSURLSessionDelegate, SocketEnginePo } extension SocketEngine { - public func URLSession(session: NSURLSession, didBecomeInvalidWithError error: NSError?) { + public func URLSession(session: URLSession, didBecomeInvalidWithError error: NSError?) { DefaultSocketLogger.Logger.error("Engine URLSession became invalid", type: "SocketEngine") - didError("Engine URLSession became invalid") + didError(reason: "Engine URLSession became invalid") } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketEngineClient.swift b/Pods/Socket.IO-Client-Swift/Source/SocketEngineClient.swift index e3aecc6..49cac7c 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketEngineClient.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketEngineClient.swift @@ -29,6 +29,6 @@ import Foundation func engineDidError(reason: String) func engineDidClose(reason: String) func engineDidOpen(reason: String) - func parseEngineMessage(msg: String) - func parseEngineBinaryData(data: NSData) + func parseEngineMessage(_ msg: String) + func parseEngineBinaryData(_ data: Data) } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketEnginePacketType.swift b/Pods/Socket.IO-Client-Swift/Source/SocketEnginePacketType.swift index 592d79b..763335e 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketEnginePacketType.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketEnginePacketType.swift @@ -26,5 +26,5 @@ import Foundation @objc public enum SocketEnginePacketType : Int { - case Open, Close, Ping, Pong, Message, Upgrade, Noop + case open, close, ping, pong, message, upgrade, noop } \ No newline at end of file diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketEnginePollable.swift b/Pods/Socket.IO-Client-Swift/Source/SocketEnginePollable.swift index b4c5f57..b050975 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketEnginePollable.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketEnginePollable.swift @@ -30,7 +30,7 @@ public protocol SocketEnginePollable : SocketEngineSpec { /// Holds strings waiting to be sent over polling. /// You shouldn't need to mess with this. var postWait: [String] { get set } - var session: NSURLSession? { get } + var session: URLSession? { get } /// Because socket.io doesn't let you send two polling request at the same time /// we have to keep track if there's an outstanding poll var waitingForPoll: Bool { get set } @@ -39,15 +39,17 @@ public protocol SocketEnginePollable : SocketEngineSpec { var waitingForPost: Bool { get set } func doPoll() - func sendPollMessage(message: String, withType type: SocketEnginePacketType, withData datas: [NSData]) + func sendPollMessage(_ message: String, withType type: SocketEnginePacketType, withData datas: [Data]) func stopPolling() } // Default polling methods extension SocketEnginePollable { - private func addHeaders(req: NSMutableURLRequest) { + private func addHeaders(for req: URLRequest) -> URLRequest { + var req = req + if cookies != nil { - let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!) + let headers = HTTPCookie.requestHeaderFields(with: cookies!) req.allHTTPHeaderFields = headers } @@ -56,10 +58,12 @@ extension SocketEnginePollable { req.setValue(value, forHTTPHeaderField: headerName) } } + + return req } - func createRequestForPostWithPostWait() -> NSURLRequest { - defer { postWait.removeAll(keepCapacity: true) } + func createRequestForPostWithPostWait() -> URLRequest { + defer { postWait.removeAll(keepingCapacity: true) } var postStr = "" @@ -71,49 +75,52 @@ extension SocketEnginePollable { DefaultSocketLogger.Logger.log("Created POST string: %@", type: "SocketEnginePolling", args: postStr) - let req = NSMutableURLRequest(URL: urlPollingWithSid) - let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)! + var req = URLRequest(url: urlPollingWithSid) + let postData = postStr.data(using: .utf8, allowLossyConversion: false)! - addHeaders(req) + req = addHeaders(for: req) - req.HTTPMethod = "POST" + req.httpMethod = "POST" req.setValue("text/plain; charset=UTF-8", forHTTPHeaderField: "Content-Type") - req.HTTPBody = postData - req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length") + + req.httpBody = postData + req.setValue(String(postData.count), forHTTPHeaderField: "Content-Length") - return req + return req as URLRequest } public func doPoll() { - if websocket || waitingForPoll || !connected || closed { return } + if websocket || waitingForPoll || !connected || closed { + return + } waitingForPoll = true - let req = NSMutableURLRequest(URL: urlPollingWithSid) + var req = URLRequest(url: urlPollingWithSid) - addHeaders(req) - doLongPoll(req) + req = addHeaders(for: req) + doLongPoll(for: req ) } - func doRequest(req: NSURLRequest, withCallback callback: (NSData?, NSURLResponse?, NSError?) -> Void) { + func doRequest(for req: URLRequest, callbackWith callback: @escaping (Data?, URLResponse?, Error?) -> Void) { if !polling || closed || invalidated || fastUpgrade { return } DefaultSocketLogger.Logger.log("Doing polling request", type: "SocketEnginePolling") - session?.dataTaskWithRequest(req, completionHandler: callback).resume() + session?.dataTask(with: req, completionHandler: callback).resume() } - func doLongPoll(req: NSURLRequest) { - doRequest(req) {[weak self] data, res, err in - guard let this = self where this.polling else { return } + func doLongPoll(for req: URLRequest) { + doRequest(for: req) {[weak self] data, res, err in + guard let this = self, this.polling else { return } if err != nil || data == nil { DefaultSocketLogger.Logger.error(err?.localizedDescription ?? "Error", type: "SocketEnginePolling") if this.polling { - this.didError(err?.localizedDescription ?? "Error") + this.didError(reason: err?.localizedDescription ?? "Error") } return @@ -121,8 +128,8 @@ extension SocketEnginePollable { DefaultSocketLogger.Logger.log("Got polling response", type: "SocketEnginePolling") - if let str = String(data: data!, encoding: NSUTF8StringEncoding) { - dispatch_async(this.parseQueue) { + if let str = String(data: data!, encoding: String.Encoding.utf8) { + this.parseQueue.async { this.parsePollingMessage(str) } } @@ -151,14 +158,14 @@ extension SocketEnginePollable { DefaultSocketLogger.Logger.log("POSTing", type: "SocketEnginePolling") - doRequest(req) {[weak self] data, res, err in + doRequest(for: req) {[weak self] data, res, err in guard let this = self else { return } if err != nil { DefaultSocketLogger.Logger.error(err?.localizedDescription ?? "Error", type: "SocketEnginePolling") if this.polling { - this.didError(err?.localizedDescription ?? "Error") + this.didError(reason: err?.localizedDescription ?? "Error") } return @@ -166,7 +173,7 @@ extension SocketEnginePollable { this.waitingForPost = false - dispatch_async(this.emitQueue) { + this.emitQueue.async { if !this.fastUpgrade { this.flushWaitingForPost() this.doPoll() @@ -175,22 +182,18 @@ extension SocketEnginePollable { } } - func parsePollingMessage(str: String) { + func parsePollingMessage(_ str: String) { guard str.characters.count != 1 else { return } var reader = SocketStringReader(message: str) while reader.hasNext { - if let n = Int(reader.readUntilStringOccurence(":")) { - let str = reader.read(n) + if let n = Int(reader.readUntilOccurence(of: ":")) { + let str = reader.read(count: n) - dispatch_async(handleQueue) { - self.parseEngineMessage(str, fromPolling: true) - } + handleQueue.async { self.parseEngineMessage(str, fromPolling: true) } } else { - dispatch_async(handleQueue) { - self.parseEngineMessage(str, fromPolling: true) - } + handleQueue.async { self.parseEngineMessage(str, fromPolling: true) } break } } @@ -198,7 +201,7 @@ extension SocketEnginePollable { /// Send polling message. /// Only call on emitQueue - public func sendPollMessage(message: String, withType type: SocketEnginePacketType, withData datas: [NSData]) { + public func sendPollMessage(_ message: String, withType type: SocketEnginePacketType, withData datas: [Data]) { DefaultSocketLogger.Logger.log("Sending poll: %@ as type: %@", type: "SocketEnginePolling", args: message, type.rawValue) let fixedMessage: String @@ -211,7 +214,7 @@ extension SocketEnginePollable { postWait.append(String(type.rawValue) + fixedMessage) for data in datas { - if case let .Right(bin) = createBinaryDataForSend(data) { + if case let .right(bin) = createBinaryDataForSend(using: data) { postWait.append(bin) } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketEngineSpec.swift b/Pods/Socket.IO-Client-Swift/Source/SocketEngineSpec.swift index 7fdd779..f862889 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketEngineSpec.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketEngineSpec.swift @@ -29,79 +29,79 @@ import Foundation weak var client: SocketEngineClient? { get set } var closed: Bool { get } var connected: Bool { get } - var connectParams: [String: AnyObject]? { get set } + var connectParams: [String: Any]? { get set } var doubleEncodeUTF8: Bool { get } - var cookies: [NSHTTPCookie]? { get } + var cookies: [HTTPCookie]? { get } var extraHeaders: [String: String]? { get } var fastUpgrade: Bool { get } var forcePolling: Bool { get } var forceWebsockets: Bool { get } - var parseQueue: dispatch_queue_t! { get } + var parseQueue: DispatchQueue { get } var polling: Bool { get } var probing: Bool { get } - var emitQueue: dispatch_queue_t! { get } - var handleQueue: dispatch_queue_t! { get } + var emitQueue: DispatchQueue { get } + var handleQueue: DispatchQueue { get } var sid: String { get } var socketPath: String { get } - var urlPolling: NSURL { get } - var urlWebSocket: NSURL { get } + var urlPolling: URL { get } + var urlWebSocket: URL { get } var websocket: Bool { get } var ws: WebSocket? { get } - init(client: SocketEngineClient, url: NSURL, options: NSDictionary?) + init(client: SocketEngineClient, url: URL, options: NSDictionary?) func connect() - func didError(error: String) + func didError(reason: String) func disconnect(reason: String) func doFastUpgrade() func flushWaitingForPostToWebSocket() - func parseEngineData(data: NSData) - func parseEngineMessage(message: String, fromPolling: Bool) - func write(msg: String, withType type: SocketEnginePacketType, withData data: [NSData]) + func parseEngineData(_ data: Data) + func parseEngineMessage(_ message: String, fromPolling: Bool) + func write(_ msg: String, withType type: SocketEnginePacketType, withData data: [Data]) } extension SocketEngineSpec { - var urlPollingWithSid: NSURL { - let com = NSURLComponents(URL: urlPolling, resolvingAgainstBaseURL: false)! + var urlPollingWithSid: URL { + var com = URLComponents(url: urlPolling, resolvingAgainstBaseURL: false)! com.percentEncodedQuery = com.percentEncodedQuery! + "&sid=\(sid.urlEncode()!)" - return com.URL! + return com.url! } - var urlWebSocketWithSid: NSURL { - let com = NSURLComponents(URL: urlWebSocket, resolvingAgainstBaseURL: false)! + var urlWebSocketWithSid: URL { + var com = URLComponents(url: urlWebSocket, resolvingAgainstBaseURL: false)! com.percentEncodedQuery = com.percentEncodedQuery! + (sid == "" ? "" : "&sid=\(sid.urlEncode()!)") - return com.URL! + return com.url! } - func createBinaryDataForSend(data: NSData) -> Either { + func createBinaryDataForSend(using data: Data) -> Either { if websocket { - var byteArray = [UInt8](count: 1, repeatedValue: 0x4) + var byteArray = [UInt8](repeating: 0x4, count: 1) let mutData = NSMutableData(bytes: &byteArray, length: 1) - mutData.appendData(data) + mutData.append(data) - return .Left(mutData) + return .left(mutData as Data) } else { - let str = "b4" + data.base64EncodedStringWithOptions(NSDataBase64EncodingOptions(rawValue: 0)) + let str = "b4" + data.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)) - return .Right(str) + return .right(str) } } - func doubleEncodeUTF8(string: String) -> String { - if let latin1 = string.dataUsingEncoding(NSUTF8StringEncoding), - utf8 = NSString(data: latin1, encoding: NSISOLatin1StringEncoding) { + func doubleEncodeUTF8(_ string: String) -> String { + if let latin1 = string.data(using: String.Encoding.utf8), + let utf8 = NSString(data: latin1, encoding: String.Encoding.isoLatin1.rawValue) { return utf8 as String } else { return string } } - func fixDoubleUTF8(string: String) -> String { - if let utf8 = string.dataUsingEncoding(NSISOLatin1StringEncoding), - latin1 = NSString(data: utf8, encoding: NSUTF8StringEncoding) { + func fixDoubleUTF8(_ string: String) -> String { + if let utf8 = string.data(using: String.Encoding.isoLatin1), + let latin1 = NSString(data: utf8, encoding: String.Encoding.utf8.rawValue) { return latin1 as String } else { return string @@ -109,7 +109,7 @@ extension SocketEngineSpec { } /// Send an engine message (4) - func send(msg: String, withData datas: [NSData]) { - write(msg, withType: .Message, withData: datas) + func send(_ msg: String, withData datas: [Data]) { + write(msg, withType: .message, withData: datas) } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketEngineWebsocket.swift b/Pods/Socket.IO-Client-Swift/Source/SocketEngineWebsocket.swift index e1b0ba8..3c37b2b 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketEngineWebsocket.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketEngineWebsocket.swift @@ -27,36 +27,36 @@ import Foundation /// Protocol that is used to implement socket.io WebSocket support public protocol SocketEngineWebsocket : SocketEngineSpec, WebSocketDelegate { - func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType, withData datas: [NSData]) + func sendWebSocketMessage(_ str: String, withType type: SocketEnginePacketType, withData datas: [Data]) } // WebSocket methods extension SocketEngineWebsocket { func probeWebSocket() { if ws?.isConnected ?? false { - sendWebSocketMessage("probe", withType: .Ping, withData: []) + sendWebSocketMessage("probe", withType: .ping, withData: []) } } /// Send message on WebSockets /// Only call on emitQueue - public func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType, withData datas: [NSData]) { - DefaultSocketLogger.Logger.log("Sending ws: %@ as type: %@", type: "SocketEngine", args: str, type.rawValue) - - ws?.writeString("\(type.rawValue)\(str)") - - for data in datas { - if case let .Left(bin) = createBinaryDataForSend(data) { - ws?.writeData(bin) - } + public func sendWebSocketMessage(_ str: String, withType type: SocketEnginePacketType, withData datas: [Data]) { + DefaultSocketLogger.Logger.log("Sending ws: %@ as type: %@", type: "SocketEngine", args: str, type.rawValue) + + ws?.write(string: "\(type.rawValue)\(str)") + + for data in datas { + if case let .left(bin) = createBinaryDataForSend(using: data) { + ws?.write(data: bin) } + } } public func websocketDidReceiveMessage(socket: WebSocket, text: String) { parseEngineMessage(text, fromPolling: false) } - public func websocketDidReceiveData(socket: WebSocket, data: NSData) { + public func websocketDidReceiveData(socket: WebSocket, data: Data) { parseEngineData(data) } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketEventHandler.swift b/Pods/Socket.IO-Client-Swift/Source/SocketEventHandler.swift index 41774a9..5497f7f 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketEventHandler.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketEventHandler.swift @@ -26,10 +26,10 @@ import Foundation struct SocketEventHandler { let event: String - let id: NSUUID + let id: UUID let callback: NormalCallback - func executeCallback(items: [AnyObject], withAck ack: Int, withSocket socket: SocketIOClient) { + func executeCallback(with items: [Any], withAck ack: Int, withSocket socket: SocketIOClient) { callback(items, SocketAckEmitter(socket: socket, ackNum: ack)) } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketExtensions.swift b/Pods/Socket.IO-Client-Swift/Source/SocketExtensions.swift index 74f032b..bf5280a 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketExtensions.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketExtensions.swift @@ -24,27 +24,88 @@ import Foundation -enum JSONError : ErrorType { +enum JSONError : Error { case notArray case notNSDictionary } -extension Array where Element: AnyObject { - func toJSON() throws -> NSData { - return try NSJSONSerialization.dataWithJSONObject(self as NSArray, options: NSJSONWritingOptions(rawValue: 0)) +extension Array { + func toJSON() throws -> Data { + return try JSONSerialization.data(withJSONObject: self, options: JSONSerialization.WritingOptions(rawValue: 0)) } } -extension NSCharacterSet { - class var allowedURLCharacterSet: NSCharacterSet { - return NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet +extension CharacterSet { + static var allowedURLCharacterSet: CharacterSet { + return CharacterSet(charactersIn: "!*'();:@&=+$,/?%#[]\" {}").inverted + } +} + +extension NSDictionary { + private static func keyValueToSocketIOClientOption(key: String, value: Any) -> SocketIOClientOption? { + switch (key, value) { + case let ("connectParams", params as [String: Any]): + return .connectParams(params) + case let ("cookies", cookies as [HTTPCookie]): + return .cookies(cookies) + case let ("doubleEncodeUTF8", encode as Bool): + return .doubleEncodeUTF8(encode) + case let ("extraHeaders", headers as [String: String]): + return .extraHeaders(headers) + case let ("forceNew", force as Bool): + return .forceNew(force) + case let ("forcePolling", force as Bool): + return .forcePolling(force) + case let ("forceWebsockets", force as Bool): + return .forceWebsockets(force) + case let ("handleQueue", queue as DispatchQueue): + return .handleQueue(queue) + case let ("log", log as Bool): + return .log(log) + case let ("logger", logger as SocketLogger): + return .logger(logger) + case let ("nsp", nsp as String): + return .nsp(nsp) + case let ("path", path as String): + return .path(path) + case let ("reconnects", reconnects as Bool): + return .reconnects(reconnects) + case let ("reconnectAttempts", attempts as Int): + return .reconnectAttempts(attempts) + case let ("reconnectWait", wait as Int): + return .reconnectWait(wait) + case let ("secure", secure as Bool): + return .secure(secure) + case let ("security", security as SSLSecurity): + return .security(security) + case let ("selfSigned", selfSigned as Bool): + return .selfSigned(selfSigned) + case let ("sessionDelegate", delegate as URLSessionDelegate): + return .sessionDelegate(delegate) + case let ("voipEnabled", enable as Bool): + return .voipEnabled(enable) + default: + return nil + } + } + + func toSocketConfiguration() -> SocketIOClientConfiguration { + var options = [] as SocketIOClientConfiguration + + for (rawKey, value) in self { + if let key = rawKey as? String, let opt = NSDictionary.keyValueToSocketIOClientOption(key: key, value: value) { + options.insert(opt) + } + } + + return options } } extension String { - func toArray() throws -> [AnyObject] { - guard let stringData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) else { return [] } - guard let array = try NSJSONSerialization.JSONObjectWithData(stringData, options: .MutableContainers) as? [AnyObject] else { + func toArray() throws -> [Any] { + guard let stringData = data(using: .utf8, allowLossyConversion: false) else { return [] } + guard let array = try JSONSerialization.jsonObject(with: stringData, options: .mutableContainers) as? [Any] else { throw JSONError.notArray } @@ -52,8 +113,8 @@ extension String { } func toNSDictionary() throws -> NSDictionary { - guard let binData = dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) else { return [:] } - guard let json = try NSJSONSerialization.JSONObjectWithData(binData, options: .AllowFragments) as? NSDictionary else { + guard let binData = data(using: .utf8, allowLossyConversion: false) else { return [:] } + guard let json = try JSONSerialization.jsonObject(with: binData, options: .allowFragments) as? NSDictionary else { throw JSONError.notNSDictionary } @@ -61,6 +122,6 @@ extension String { } func urlEncode() -> String? { - return stringByAddingPercentEncodingWithAllowedCharacters(.allowedURLCharacterSet) + return addingPercentEncoding(withAllowedCharacters: .allowedURLCharacterSet) } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketIOClient.swift b/Pods/Socket.IO-Client-Swift/Source/SocketIOClient.swift index ca7fe19..0a51bd0 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketIOClient.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketIOClient.swift @@ -25,13 +25,13 @@ import Foundation public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable { - public let socketURL: NSURL + public let socketURL: URL public private(set) var engine: SocketEngineSpec? - public private(set) var status = SocketIOClientStatus.NotConnected { + public private(set) var status = SocketIOClientStatus.notConnected { didSet { switch status { - case .Connected: + case .connected: reconnecting = false currentReconnectAttempt = 0 default: @@ -42,17 +42,14 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable public var forceNew = false public var nsp = "/" - public var options: Set + public var config: SocketIOClientConfiguration public var reconnects = true public var reconnectWait = 10 - public var sid: String? { - return nsp + "#" + (engine?.sid ?? "") - } - private let ackQueue = dispatch_queue_create("com.socketio.ackQueue", DISPATCH_QUEUE_SERIAL) - private let emitQueue = dispatch_queue_create("com.socketio.emitQueue", DISPATCH_QUEUE_SERIAL) + private let ackQueue = DispatchQueue(label: "com.socketio.ackQueue", attributes: []) + private let emitQueue = DispatchQueue(label: "com.socketio.emitQueue", attributes: []) private let logType = "SocketIOClient" - private let parseQueue = dispatch_queue_create("com.socketio.parseQueue", DISPATCH_QUEUE_SERIAL) + private let parseQueue = DispatchQueue(label: "com.socketio.parseQueue", attributes: []) private var anyHandler: ((SocketAnyEvent) -> Void)? private var currentReconnectAttempt = 0 @@ -61,82 +58,87 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable private var reconnecting = false private(set) var currentAck = -1 - private(set) var handleQueue = dispatch_get_main_queue() + private(set) var handleQueue = DispatchQueue.main private(set) var reconnectAttempts = -1 var waitingPackets = [SocketPacket]() + public var sid: String? { + return nsp + "#" + (engine?.sid ?? "") + } + /// Type safe way to create a new SocketIOClient. opts can be omitted - public init(socketURL: NSURL, options: Set = []) { - self.options = options + public init(socketURL: URL, config: SocketIOClientConfiguration = []) { + self.config = config self.socketURL = socketURL if socketURL.absoluteString.hasPrefix("https://") { - self.options.insertIgnore(.Secure(true)) + self.config.insert(.secure(true)) } - for option in options { + for option in config { switch option { - case let .Reconnects(reconnects): + case let .reconnects(reconnects): self.reconnects = reconnects - case let .ReconnectAttempts(attempts): + case let .reconnectAttempts(attempts): reconnectAttempts = attempts - case let .ReconnectWait(wait): + case let .reconnectWait(wait): reconnectWait = abs(wait) - case let .Nsp(nsp): + case let .nsp(nsp): self.nsp = nsp - case let .Log(log): + case let .log(log): DefaultSocketLogger.Logger.log = log - case let .Logger(logger): + case let .logger(logger): DefaultSocketLogger.Logger = logger - case let .HandleQueue(queue): + case let .handleQueue(queue): handleQueue = queue - case let .ForceNew(force): + case let .forceNew(force): forceNew = force default: continue } } - - self.options.insertIgnore(.Path("/socket.io/")) + + self.config.insert(.path("/socket.io/"), replacing: false) super.init() } /// Not so type safe way to create a SocketIOClient, meant for Objective-C compatiblity. /// If using Swift it's recommended to use `init(socketURL: NSURL, options: Set)` - public convenience init(socketURL: NSURL, options: NSDictionary?) { - self.init(socketURL: socketURL, options: options?.toSocketOptionsSet() ?? []) + public convenience init(socketURL: NSURL, config: NSDictionary?) { + self.init(socketURL: socketURL as URL, config: config?.toSocketConfiguration() ?? []) } deinit { DefaultSocketLogger.Logger.log("Client is being released", type: logType) - engine?.disconnect("Client Deinit") + engine?.disconnect(reason: "Client Deinit") } private func addEngine() -> SocketEngineSpec { - DefaultSocketLogger.Logger.log("Adding engine", type: logType) + DefaultSocketLogger.Logger.log("Adding engine", type: logType, args: "") - engine = SocketEngine(client: self, url: socketURL, options: options) + engine = SocketEngine(client: self, url: socketURL, config: config) return engine! } /// Connect to the server. public func connect() { - connect(timeoutAfter: 0, withTimeoutHandler: nil) + connect(timeoutAfter: 0, withHandler: nil) } - /// Connect to the server. If we aren't connected after timeoutAfter, call handler - public func connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?) { + /// Connect to the server. If we aren't connected after timeoutAfter, call withHandler + /// 0 Never times out + public func connect(timeoutAfter: Int, withHandler handler: (() -> Void)?) { assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)") - guard status != .Connected else { + guard status != .connected else { DefaultSocketLogger.Logger.log("Tried connecting on an already connected socket", type: logType) return } - status = .Connecting + status = .connecting if engine == nil || forceNew { addEngine().connect() @@ -146,36 +148,36 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable guard timeoutAfter != 0 else { return } - let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC)) - - dispatch_after(time, handleQueue) {[weak self] in - if let this = self where this.status != .Connected && this.status != .Disconnected { - this.status = .Disconnected - this.engine?.disconnect("Connect timeout") + let time = DispatchTime.now() + Double(Int64(timeoutAfter) * Int64(NSEC_PER_SEC)) / Double(NSEC_PER_SEC) - handler?() - } + handleQueue.asyncAfter(deadline: time) {[weak self] in + guard let this = self, this.status != .connected && this.status != .disconnected else { return } + + this.status = .disconnected + this.engine?.disconnect(reason: "Connect timeout") + + handler?() } } - private func createOnAck(items: [AnyObject]) -> OnAckCallback { + private func createOnAck(_ items: [Any]) -> OnAckCallback { currentAck += 1 - + return {[weak self, ack = currentAck] timeout, callback in - if let this = self { - dispatch_sync(this.ackQueue) { - this.ackHandlers.addAck(ack, callback: callback) - } + guard let this = self else { return } + this.ackQueue.sync() { + this.ackHandlers.addAck(ack, callback: callback) + } + + + this._emit(items, ack: ack) + + if timeout != 0 { + let time = DispatchTime.now() + Double(Int64(timeout * NSEC_PER_SEC)) / Double(NSEC_PER_SEC) - this._emit(items, ack: ack) - - if timeout != 0 { - let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC)) - - dispatch_after(time, this.ackQueue) { - this.ackHandlers.timeoutAck(ack, onQueue: this.handleQueue) - } + this.handleQueue.asyncAfter(deadline: time) { + this.ackHandlers.timeoutAck(ack, onQueue: this.handleQueue) } } } @@ -183,7 +185,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable func didConnect() { DefaultSocketLogger.Logger.log("Socket connected", type: logType) - status = .Connected + status = .connected // Don't handle as internal because something crazy could happen where // we disconnect before it's handled @@ -191,34 +193,33 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable } func didDisconnect(reason: String) { - guard status != .Disconnected else { return } + guard status != .disconnected else { return } DefaultSocketLogger.Logger.log("Disconnected: %@", type: logType, args: reason) - status = .Disconnected + reconnecting = false + status = .disconnected // Make sure the engine is actually dead. - engine?.disconnect(reason) + engine?.disconnect(reason: reason) handleEvent("disconnect", data: [reason], isInternalMessage: true) } /// Disconnects the socket. public func disconnect() { - assert(status != .NotConnected, "Tried closing a NotConnected client") - DefaultSocketLogger.Logger.log("Closing socket", type: logType) - didDisconnect("Disconnect") + didDisconnect(reason: "Disconnect") } /// Send a message to the server - public func emit(event: String, _ items: AnyObject...) { - emit(event, withItems: items) + public func emit(_ event: String, _ items: SocketData...) { + emit(event, with: items) } /// Same as emit, but meant for Objective-C - public func emit(event: String, withItems items: [AnyObject]) { - guard status == .Connected else { + public func emit(_ event: String, with items: [Any]) { + guard status == .connected else { handleEvent("error", data: ["Tried emitting \(event) when not connected"], isInternalMessage: true) return } @@ -228,18 +229,18 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable /// Sends a message to the server, requesting an ack. Use the onAck method of SocketAckHandler to add /// an ack. - public func emitWithAck(event: String, _ items: AnyObject...) -> OnAckCallback { - return emitWithAck(event, withItems: items) + public func emitWithAck(_ event: String, _ items: SocketData...) -> OnAckCallback { + return emitWithAck(event, with: items) } /// Same as emitWithAck, but for Objective-C - public func emitWithAck(event: String, withItems items: [AnyObject]) -> OnAckCallback { + public func emitWithAck(_ event: String, with items: [Any]) -> OnAckCallback { return createOnAck([event] + items) } - private func _emit(data: [AnyObject], ack: Int? = nil) { - dispatch_async(emitQueue) { - guard self.status == .Connected else { + private func _emit(_ data: [Any], ack: Int? = nil) { + emitQueue.async { + guard self.status == .connected else { self.handleEvent("error", data: ["Tried emitting when not connected"], isInternalMessage: true) return } @@ -254,31 +255,31 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable } // If the server wants to know that the client received data - func emitAck(ack: Int, withItems items: [AnyObject]) { - dispatch_async(emitQueue) { - if self.status == .Connected { - let packet = SocketPacket.packetFromEmit(items, id: ack ?? -1, nsp: self.nsp, ack: true) - let str = packet.packetString - - DefaultSocketLogger.Logger.log("Emitting Ack: %@", type: self.logType, args: str) - - self.engine?.send(str, withData: packet.binary) - } + func emitAck(_ ack: Int, with items: [Any]) { + emitQueue.async { + guard self.status == .connected else { return } + + let packet = SocketPacket.packetFromEmit(items, id: ack, nsp: self.nsp, ack: true) + let str = packet.packetString + + DefaultSocketLogger.Logger.log("Emitting Ack: %@", type: self.logType, args: str) + + self.engine?.send(str, withData: packet.binary) } } public func engineDidClose(reason: String) { waitingPackets.removeAll() - if status != .Disconnected { - status = .NotConnected + if status != .disconnected { + status = .notConnected } - if status == .Disconnected || !reconnects { - didDisconnect(reason) + if status == .disconnected || !reconnects { + didDisconnect(reason: reason) } else if !reconnecting { reconnecting = true - tryReconnectWithReason(reason) + tryReconnect(reason: reason) } } @@ -294,27 +295,27 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable } // Called when the socket gets an ack for something it sent - func handleAck(ack: Int, data: [AnyObject]) { - guard status == .Connected else { return } + func handleAck(_ ack: Int, data: [Any]) { + guard status == .connected else { return } - DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "") + DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data) - dispatch_async(ackQueue) { - self.ackHandlers.executeAck(ack, items: data, onQueue: self.handleQueue) + handleQueue.async() { + self.ackHandlers.executeAck(ack, with: data, onQueue: self.handleQueue) } } /// Causes an event to be handled. Only use if you know what you're doing. - public func handleEvent(event: String, data: [AnyObject], isInternalMessage: Bool, withAck ack: Int = -1) { - guard status == .Connected || isInternalMessage else { return } + public func handleEvent(_ event: String, data: [Any], isInternalMessage: Bool, withAck ack: Int = -1) { + guard status == .connected || isInternalMessage else { return } - DefaultSocketLogger.Logger.log("Handling event: %@ with data: %@", type: logType, args: event, data ?? "") + DefaultSocketLogger.Logger.log("Handling event: %@ with data: %@", type: logType, args: event, data) - dispatch_async(handleQueue) { + handleQueue.async { self.anyHandler?(SocketAnyEvent(event: event, items: data)) for handler in self.handlers where handler.event == event { - handler.executeCallback(data, withAck: ack, withSocket: self) + handler.executeCallback(with: data, withAck: ack, withSocket: self) } } } @@ -328,7 +329,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable } /// Joins namespace - public func joinNamespace(namespace: String) { + public func joinNamespace(_ namespace: String) { nsp = namespace if nsp != "/" { @@ -338,14 +339,14 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable } /// Removes handler(s) based on name - public func off(event: String) { + public func off(_ event: String) { DefaultSocketLogger.Logger.log("Removing handler for event: %@", type: logType, args: event) handlers = handlers.filter({ $0.event != event }) } /// Removes a handler with the specified UUID gotten from an `on` or `once` - public func off(id id: NSUUID) { + public func off(id: UUID) { DefaultSocketLogger.Logger.log("Removing handler with id: %@", type: logType, args: id) handlers = handlers.filter({ $0.id != id }) @@ -353,10 +354,11 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable /// Adds a handler for an event. /// Returns: A unique id for the handler - public func on(event: String, callback: NormalCallback) -> NSUUID { + @discardableResult + public func on(_ event: String, callback: @escaping NormalCallback) -> UUID { DefaultSocketLogger.Logger.log("Adding handler for event: %@", type: logType, args: event) - let handler = SocketEventHandler(event: event, id: NSUUID(), callback: callback) + let handler = SocketEventHandler(event: event, id: UUID(), callback: callback) handlers.append(handler) return handler.id @@ -364,10 +366,11 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable /// Adds a single-use handler for an event. /// Returns: A unique id for the handler - public func once(event: String, callback: NormalCallback) -> NSUUID { + @discardableResult + public func once(_ event: String, callback: @escaping NormalCallback) -> UUID { DefaultSocketLogger.Logger.log("Adding once handler for event: %@", type: logType, args: event) - let id = NSUUID() + let id = UUID() let handler = SocketEventHandler(event: event, id: id) {[weak self] data, ack in guard let this = self else { return } @@ -381,83 +384,75 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable } /// Adds a handler that will be called on every event. - public func onAny(handler: (SocketAnyEvent) -> Void) { + public func onAny(_ handler: @escaping (SocketAnyEvent) -> Void) { anyHandler = handler } - public func parseEngineMessage(msg: String) { + public func parseEngineMessage(_ msg: String) { DefaultSocketLogger.Logger.log("Should parse message: %@", type: "SocketIOClient", args: msg) - dispatch_async(parseQueue) { - self.parseSocketMessage(msg) - } + parseQueue.async { self.parseSocketMessage(msg) } } - public func parseEngineBinaryData(data: NSData) { - dispatch_async(parseQueue) { - self.parseBinaryData(data) - } + public func parseEngineBinaryData(_ data: Data) { + parseQueue.async { self.parseBinaryData(data) } } /// Tries to reconnect to the server. public func reconnect() { guard !reconnecting else { return } - engine?.disconnect("manual reconnect") + engine?.disconnect(reason: "manual reconnect") } /// Removes all handlers. /// Can be used after disconnecting to break any potential remaining retain cycles. public func removeAllHandlers() { - handlers.removeAll(keepCapacity: false) + handlers.removeAll(keepingCapacity: false) } - private func tryReconnectWithReason(reason: String) { - if reconnecting { - DefaultSocketLogger.Logger.log("Starting reconnect", type: logType) - handleEvent("reconnect", data: [reason], isInternalMessage: true) - - _tryReconnect() - } + private func tryReconnect(reason: String) { + guard reconnecting else { return } + + DefaultSocketLogger.Logger.log("Starting reconnect", type: logType) + handleEvent("reconnect", data: [reason], isInternalMessage: true) + + _tryReconnect() } private func _tryReconnect() { - if !reconnecting { - return - } + guard reconnecting else { return } if reconnectAttempts != -1 && currentReconnectAttempt + 1 > reconnectAttempts || !reconnects { - return didDisconnect("Reconnect Failed") + return didDisconnect(reason: "Reconnect Failed") } DefaultSocketLogger.Logger.log("Trying to reconnect", type: logType) - handleEvent("reconnectAttempt", data: [reconnectAttempts - currentReconnectAttempt], - isInternalMessage: true) + handleEvent("reconnectAttempt", data: [(reconnectAttempts - currentReconnectAttempt)], isInternalMessage: true) currentReconnectAttempt += 1 connect() - let dispatchAfter = dispatch_time(DISPATCH_TIME_NOW, Int64(UInt64(reconnectWait) * NSEC_PER_SEC)) + let deadline = DispatchTime.now() + Double(Int64(UInt64(reconnectWait) * NSEC_PER_SEC)) / Double(NSEC_PER_SEC) - dispatch_after(dispatchAfter, dispatch_get_main_queue(), _tryReconnect) + DispatchQueue.main.asyncAfter(deadline: deadline, execute: _tryReconnect) } -} - -// Test extensions -extension SocketIOClient { + + // Test properties + var testHandlers: [SocketEventHandler] { return handlers } - + func setTestable() { - status = .Connected + status = .connected } - - func setTestEngine(engine: SocketEngineSpec?) { + + func setTestEngine(_ engine: SocketEngineSpec?) { self.engine = engine } - - func emitTest(event: String, _ data: AnyObject...) { - self._emit([event] + data) + + func emitTest(event: String, _ data: Any...) { + _emit([event] + data) } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketIOClientConfiguration.swift b/Pods/Socket.IO-Client-Swift/Source/SocketIOClientConfiguration.swift new file mode 100644 index 0000000..07aba15 --- /dev/null +++ b/Pods/Socket.IO-Client-Swift/Source/SocketIOClientConfiguration.swift @@ -0,0 +1,108 @@ +// +// SocketIOClientConfiguration.swift +// Socket.IO-Client-Swift +// +// Created by Erik Little on 8/13/16. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +public struct SocketIOClientConfiguration : ExpressibleByArrayLiteral, Collection, MutableCollection { + public typealias Element = SocketIOClientOption + public typealias Index = Array.Index + public typealias Generator = Array.Generator + public typealias SubSequence = Array.SubSequence + + private var backingArray = [SocketIOClientOption]() + + public var startIndex: Index { + return backingArray.startIndex + } + + public var endIndex: Index { + return backingArray.endIndex + } + + public var isEmpty: Bool { + return backingArray.isEmpty + } + + public var count: Index.Stride { + return backingArray.count + } + + public var first: Generator.Element? { + return backingArray.first + } + + public subscript(position: Index) -> Generator.Element { + get { + return backingArray[position] + } + + set { + backingArray[position] = newValue + } + } + + public subscript(bounds: Range) -> SubSequence { + get { + return backingArray[bounds] + } + + set { + backingArray[bounds] = newValue + } + } + + public init(arrayLiteral elements: Element...) { + backingArray = elements + } + + public func generate() -> Generator { + return backingArray.makeIterator() + } + + public func index(after i: Index) -> Index { + return backingArray.index(after: i) + } + + public mutating func insert(_ element: Element, replacing replace: Bool = true) { + for i in 0.. SubSequence { + return backingArray.prefix(upTo: end) + } + + public func prefix(through position: Index) -> SubSequence { + return backingArray.prefix(through: position) + } + + public func suffix(from start: Index) -> SubSequence { + return backingArray.suffix(from: start) + } +} diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketIOClientOption.swift b/Pods/Socket.IO-Client-Swift/Source/SocketIOClientOption.swift index d7a0d8d..dd723f4 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketIOClientOption.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketIOClientOption.swift @@ -24,128 +24,124 @@ import Foundation -protocol ClientOption : CustomStringConvertible, Hashable { - func getSocketIOOptionValue() -> AnyObject +protocol ClientOption : CustomStringConvertible, Equatable { + func getSocketIOOptionValue() -> Any } public enum SocketIOClientOption : ClientOption { - case ConnectParams([String: AnyObject]) - case Cookies([NSHTTPCookie]) - case DoubleEncodeUTF8(Bool) - case ExtraHeaders([String: String]) - case ForceNew(Bool) - case ForcePolling(Bool) - case ForceWebsockets(Bool) - case HandleQueue(dispatch_queue_t) - case Log(Bool) - case Logger(SocketLogger) - case Nsp(String) - case Path(String) - case Reconnects(Bool) - case ReconnectAttempts(Int) - case ReconnectWait(Int) - case Secure(Bool) - case Security(SSLSecurity) - case SelfSigned(Bool) - case SessionDelegate(NSURLSessionDelegate) - case VoipEnabled(Bool) + case connectParams([String: Any]) + case cookies([HTTPCookie]) + case doubleEncodeUTF8(Bool) + case extraHeaders([String: String]) + case forceNew(Bool) + case forcePolling(Bool) + case forceWebsockets(Bool) + case handleQueue(DispatchQueue) + case log(Bool) + case logger(SocketLogger) + case nsp(String) + case path(String) + case reconnects(Bool) + case reconnectAttempts(Int) + case reconnectWait(Int) + case secure(Bool) + case security(SSLSecurity) + case selfSigned(Bool) + case sessionDelegate(URLSessionDelegate) + case voipEnabled(Bool) public var description: String { let description: String switch self { - case .ConnectParams: + case .connectParams: description = "connectParams" - case .Cookies: + case .cookies: description = "cookies" - case .DoubleEncodeUTF8: + case .doubleEncodeUTF8: description = "doubleEncodeUTF8" - case .ExtraHeaders: + case .extraHeaders: description = "extraHeaders" - case .ForceNew: + case .forceNew: description = "forceNew" - case .ForcePolling: + case .forcePolling: description = "forcePolling" - case .ForceWebsockets: + case .forceWebsockets: description = "forceWebsockets" - case .HandleQueue: + case .handleQueue: description = "handleQueue" - case .Log: + case .log: description = "log" - case .Logger: + case .logger: description = "logger" - case .Nsp: + case .nsp: description = "nsp" - case .Path: + case .path: description = "path" - case .Reconnects: + case .reconnects: description = "reconnects" - case .ReconnectAttempts: + case .reconnectAttempts: description = "reconnectAttempts" - case .ReconnectWait: + case .reconnectWait: description = "reconnectWait" - case .Secure: + case .secure: description = "secure" - case .Security: - description = "security" - case .SelfSigned: + case .selfSigned: description = "selfSigned" - case .SessionDelegate: + case .security: + description = "security" + case .sessionDelegate: description = "sessionDelegate" - case .VoipEnabled: + case .voipEnabled: description = "voipEnabled" } return description } - public var hashValue: Int { - return description.hashValue - } - - func getSocketIOOptionValue() -> AnyObject { - let value: AnyObject + func getSocketIOOptionValue() -> Any { + let value: Any switch self { - case let .ConnectParams(params): + case let .connectParams(params): value = params - case let .Cookies(cookies): + case let .cookies(cookies): value = cookies - case let .DoubleEncodeUTF8(encode): + case let .doubleEncodeUTF8(encode): value = encode - case let .ExtraHeaders(headers): + case let .extraHeaders(headers): value = headers - case let .ForceNew(force): + case let .forceNew(force): value = force - case let .ForcePolling(force): + case let .forcePolling(force): value = force - case let .ForceWebsockets(force): + case let .forceWebsockets(force): value = force - case let .HandleQueue(queue): + case let .handleQueue(queue): value = queue - case let .Log(log): + case let .log(log): value = log - case let .Logger(logger): + case let .logger(logger): value = logger - case let .Nsp(nsp): + case let .nsp(nsp): value = nsp - case let .Path(path): + case let .path(path): value = path - case let .Reconnects(reconnects): + case let .reconnects(reconnects): value = reconnects - case let .ReconnectAttempts(attempts): + case let .reconnectAttempts(attempts): value = attempts - case let .ReconnectWait(wait): + case let .reconnectWait(wait): value = wait - case let .Secure(secure): + case let .secure(secure): value = secure - case let .Security(security): + case let .security(security): value = security - case let .SelfSigned(signed): + case let .selfSigned(signed): value = signed - case let .SessionDelegate(delegate): + case let .sessionDelegate(delegate): value = delegate - case let .VoipEnabled(enabled): + case let .voipEnabled(enabled): value = enabled } @@ -156,72 +152,3 @@ public enum SocketIOClientOption : ClientOption { public func ==(lhs: SocketIOClientOption, rhs: SocketIOClientOption) -> Bool { return lhs.description == rhs.description } - -extension Set where Element : ClientOption { - mutating func insertIgnore(element: Element) { - if !contains(element) { - insert(element) - } - } -} - -extension NSDictionary { - private static func keyValueToSocketIOClientOption(key: String, value: AnyObject) -> SocketIOClientOption? { - switch (key, value) { - case let ("connectParams", params as [String: AnyObject]): - return .ConnectParams(params) - case let ("cookies", cookies as [NSHTTPCookie]): - return .Cookies(cookies) - case let ("doubleEncodeUTF8", encode as Bool): - return .DoubleEncodeUTF8(encode) - case let ("extraHeaders", headers as [String: String]): - return .ExtraHeaders(headers) - case let ("forceNew", force as Bool): - return .ForceNew(force) - case let ("forcePolling", force as Bool): - return .ForcePolling(force) - case let ("forceWebsockets", force as Bool): - return .ForceWebsockets(force) - case let ("handleQueue", queue as dispatch_queue_t): - return .HandleQueue(queue) - case let ("log", log as Bool): - return .Log(log) - case let ("logger", logger as SocketLogger): - return .Logger(logger) - case let ("nsp", nsp as String): - return .Nsp(nsp) - case let ("path", path as String): - return .Path(path) - case let ("reconnects", reconnects as Bool): - return .Reconnects(reconnects) - case let ("reconnectAttempts", attempts as Int): - return .ReconnectAttempts(attempts) - case let ("reconnectWait", wait as Int): - return .ReconnectWait(wait) - case let ("secure", secure as Bool): - return .Secure(secure) - case let ("security", security as SSLSecurity): - return .Security(security) - case let ("selfSigned", selfSigned as Bool): - return .SelfSigned(selfSigned) - case let ("sessionDelegate", delegate as NSURLSessionDelegate): - return .SessionDelegate(delegate) - case let ("voipEnabled", enable as Bool): - return .VoipEnabled(enable) - default: - return nil - } - } - - func toSocketOptionsSet() -> Set { - var options = Set() - - for (rawKey, value) in self { - if let key = rawKey as? String, opt = NSDictionary.keyValueToSocketIOClientOption(key, value: value) { - options.insertIgnore(opt) - } - } - - return options - } -} diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketIOClientSpec.swift b/Pods/Socket.IO-Client-Swift/Source/SocketIOClientSpec.swift index 8b33cf9..e91c840 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketIOClientSpec.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketIOClientSpec.swift @@ -29,9 +29,9 @@ protocol SocketIOClientSpec : class { func didConnect() func didDisconnect(reason: String) func didError(reason: String) - func handleAck(ack: Int, data: [AnyObject]) - func handleEvent(event: String, data: [AnyObject], isInternalMessage: Bool, withAck ack: Int) - func joinNamespace(namespace: String) + func handleAck(_ ack: Int, data: [Any]) + func handleEvent(_ event: String, data: [Any], isInternalMessage: Bool, withAck ack: Int) + func joinNamespace(_ namespace: String) } extension SocketIOClientSpec { diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketIOClientStatus.swift b/Pods/Socket.IO-Client-Swift/Source/SocketIOClientStatus.swift index 0a34c2f..27574e6 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketIOClientStatus.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketIOClientStatus.swift @@ -28,5 +28,5 @@ import Foundation /// /// **Disconnected**: connected before @objc public enum SocketIOClientStatus : Int { - case NotConnected, Disconnected, Connecting, Connected + case notConnected, disconnected, connecting, connected } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketLogger.swift b/Pods/Socket.IO-Client-Swift/Source/SocketLogger.swift index bff9d4e..640d344 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketLogger.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketLogger.swift @@ -29,28 +29,28 @@ public protocol SocketLogger : class { var log: Bool { get set } /// Normal log messages - func log(message: String, type: String, args: AnyObject...) + func log(_ message: String, type: String, args: Any...) /// Error Messages - func error(message: String, type: String, args: AnyObject...) + func error(_ message: String, type: String, args: Any...) } public extension SocketLogger { - func log(message: String, type: String, args: AnyObject...) { + func log(_ message: String, type: String, args: Any...) { abstractLog("LOG", message: message, type: type, args: args) } - func error(message: String, type: String, args: AnyObject...) { + func error(_ message: String, type: String, args: Any...) { abstractLog("ERROR", message: message, type: type, args: args) } - private func abstractLog(logType: String, message: String, type: String, args: [AnyObject]) { + private func abstractLog(_ logType: String, message: String, type: String, args: [Any]) { guard log else { return } - let newArgs = args.map({arg -> CVarArgType in String(arg)}) - let replaced = String(format: message, arguments: newArgs) + let newArgs = args.map({arg -> CVarArg in String(describing: arg)}) + let messageFormat = String(format: message, arguments: newArgs) - NSLog("%@ %@: %@", logType, type, replaced) + NSLog("\(logType) \(type): %@", messageFormat) } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketPacket.swift b/Pods/Socket.IO-Client-Swift/Source/SocketPacket.swift index 6326453..95b3218 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketPacket.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketPacket.swift @@ -26,6 +26,10 @@ import Foundation struct SocketPacket { + enum PacketType: Int { + case connect, disconnect, event, ack, error, binaryEvent, binaryAck + } + private let placeholders: Int private static let logType = "SocketPacket" @@ -34,35 +38,31 @@ struct SocketPacket { let id: Int let type: PacketType - enum PacketType: Int { - case Connect, Disconnect, Event, Ack, Error, BinaryEvent, BinaryAck - } - - var args: [AnyObject] { - if type == .Event || type == .BinaryEvent && data.count != 0 { + var binary: [Data] + var data: [Any] + var args: [Any] { + if type == .event || type == .binaryEvent && data.count != 0 { return Array(data.dropFirst()) } else { return data } } - var binary: [NSData] - var data: [AnyObject] var description: String { return "SocketPacket {type: \(String(type.rawValue)); data: " + - "\(String(data)); id: \(id); placeholders: \(placeholders); nsp: \(nsp)}" + "\(String(describing: data)); id: \(id); placeholders: \(placeholders); nsp: \(nsp)}" } var event: String { - return String(data[0]) + return String(describing: data[0]) } var packetString: String { return createPacketString() } - init(type: PacketType, data: [AnyObject] = [AnyObject](), id: Int = -1, - nsp: String, placeholders: Int = 0, binary: [NSData] = [NSData]()) { + init(type: PacketType, data: [Any] = [Any](), id: Int = -1, nsp: String, placeholders: Int = 0, + binary: [Data] = [Data]()) { self.data = data self.id = id self.nsp = nsp @@ -71,7 +71,7 @@ struct SocketPacket { self.binary = binary } - mutating func addData(data: NSData) -> Bool { + mutating func addData(_ data: Data) -> Bool { if placeholders == binary.count { return true } @@ -86,7 +86,7 @@ struct SocketPacket { } } - private func completeMessage(message: String) -> String { + private func completeMessage(_ message: String) -> String { let restOfMessage: String if data.count == 0 { @@ -95,7 +95,7 @@ struct SocketPacket { do { let jsonSend = try data.toJSON() - guard let jsonString = String(data: jsonSend, encoding: NSUTF8StringEncoding) else { return message + "[]" } + guard let jsonString = String(data: jsonSend, encoding: .utf8) else { return message + "[]" } restOfMessage = jsonString } catch { @@ -110,27 +110,12 @@ struct SocketPacket { private func createPacketString() -> String { let typeString = String(type.rawValue) - let binaryCountString: String - let nspString: String - let idString: String - - if type == .BinaryEvent || type == .BinaryAck { - binaryCountString = typeString + String(binary.count) + "-" - } else { - binaryCountString = typeString - } - - if nsp != "/" { - nspString = binaryCountString + nsp + "," - } else { - nspString = binaryCountString - } - - if id != -1 { - idString = nspString + String(id) - } else { - idString = nspString - } + // Binary count? + let binaryCountString = typeString + (type == .binaryEvent || type == .binaryAck ? "\(String(binary.count))-" : "") + // Namespace? + let nspString = binaryCountString + (nsp != "/" ? "\(nsp)," : "") + // Ack number? + let idString = nspString + (id != -1 ? String(id) : "") return completeMessage(idString) } @@ -146,18 +131,21 @@ struct SocketPacket { // If object is a collection it will recurse // Returns the object if it is not a placeholder or the corresponding // binary data - private func _fillInPlaceholders(object: AnyObject) -> AnyObject { + private func _fillInPlaceholders(_ object: Any) -> Any { switch object { - case let dict as NSDictionary: + case let dict as [String: Any]: if dict["_placeholder"] as? Bool ?? false { return binary[dict["num"] as! Int] } else { - return dict.reduce(NSMutableDictionary(), combine: {cur, keyValue in - cur[keyValue.0 as! NSCopying] = _fillInPlaceholders(keyValue.1) + return dict.reduce([String: Any](), {cur, keyValue in + var cur = cur + + cur[keyValue.0] = _fillInPlaceholders(keyValue.1) + return cur }) } - case let arr as [AnyObject]: + case let arr as [Any]: return arr.map(_fillInPlaceholders) default: return object @@ -166,22 +154,22 @@ struct SocketPacket { } extension SocketPacket { - private static func findType(binCount: Int, ack: Bool) -> PacketType { + private static func findType(_ binCount: Int, ack: Bool) -> PacketType { switch binCount { case 0 where !ack: - return .Event + return .event case 0 where ack: - return .Ack + return .ack case _ where !ack: - return .BinaryEvent + return .binaryEvent case _ where ack: - return .BinaryAck + return .binaryAck default: - return .Error + return .error } } - static func packetFromEmit(items: [AnyObject], id: Int, nsp: String, ack: Bool) -> SocketPacket { + static func packetFromEmit(_ items: [Any], id: Int, nsp: String, ack: Bool) -> SocketPacket { let (parsedData, binary) = deconstructData(items) let packet = SocketPacket(type: findType(binary.count, ack: ack), data: parsedData, id: id, nsp: nsp, binary: binary) @@ -192,19 +180,23 @@ extension SocketPacket { private extension SocketPacket { // Recursive function that looks for NSData in collections - static func shred(data: AnyObject, inout binary: [NSData]) -> AnyObject { - let placeholder = ["_placeholder": true, "num": binary.count] + static func shred(_ data: Any, binary: inout [Data]) -> Any { + let placeholder = ["_placeholder": true, "num": binary.count] as [String : Any] switch data { - case let bin as NSData: + case let bin as Data: binary.append(bin) + return placeholder - case let arr as [AnyObject]: + case let arr as [Any]: return arr.map({shred($0, binary: &binary)}) - case let dict as NSDictionary: - return dict.reduce(NSMutableDictionary(), combine: {cur, keyValue in - cur[keyValue.0 as! NSCopying] = shred(keyValue.1, binary: &binary) - return cur + case let dict as [String: Any]: + return dict.reduce([String: Any](), {cur, keyValue in + var mutCur = cur + + mutCur[keyValue.0] = shred(keyValue.1, binary: &binary) + + return mutCur }) default: return data @@ -213,8 +205,8 @@ private extension SocketPacket { // Removes binary data from emit data // Returns a type containing the de-binaryed data and the binary - static func deconstructData(data: [AnyObject]) -> ([AnyObject], [NSData]) { - var binary = [NSData]() + static func deconstructData(_ data: [Any]) -> ([Any], [Data]) { + var binary = [Data]() return (data.map({shred($0, binary: &binary)}), binary) } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketParsable.swift b/Pods/Socket.IO-Client-Swift/Source/SocketParsable.swift index d5a1b9d..7c9ce21 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketParsable.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketParsable.swift @@ -23,38 +23,38 @@ import Foundation protocol SocketParsable : SocketIOClientSpec { - func parseBinaryData(data: NSData) - func parseSocketMessage(message: String) + func parseBinaryData(_ data: Data) + func parseSocketMessage(_ message: String) } extension SocketParsable { - private func isCorrectNamespace(nsp: String) -> Bool { + private func isCorrectNamespace(_ nsp: String) -> Bool { return nsp == self.nsp } - private func handleConnect(p: SocketPacket) { - if p.nsp == "/" && nsp != "/" { + private func handleConnect(_ packetNamespace: String) { + if packetNamespace == "/" && nsp != "/" { joinNamespace(nsp) } else { didConnect() } } - private func handlePacket(pack: SocketPacket) { + private func handlePacket(_ pack: SocketPacket) { switch pack.type { - case .Event where isCorrectNamespace(pack.nsp): + case .event where isCorrectNamespace(pack.nsp): handleEvent(pack.event, data: pack.args, isInternalMessage: false, withAck: pack.id) - case .Ack where isCorrectNamespace(pack.nsp): + case .ack where isCorrectNamespace(pack.nsp): handleAck(pack.id, data: pack.data) - case .BinaryEvent where isCorrectNamespace(pack.nsp): + case .binaryEvent where isCorrectNamespace(pack.nsp): waitingPackets.append(pack) - case .BinaryAck where isCorrectNamespace(pack.nsp): + case .binaryAck where isCorrectNamespace(pack.nsp): waitingPackets.append(pack) - case .Connect: - handleConnect(pack) - case .Disconnect: - didDisconnect("Got Disconnect") - case .Error: + case .connect: + handleConnect(pack.nsp) + case .disconnect: + didDisconnect(reason: "Got Disconnect") + case .error: handleEvent("error", data: pack.data, isInternalMessage: true, withAck: pack.id) default: DefaultSocketLogger.Logger.log("Got invalid packet: %@", type: "SocketParser", args: pack.description) @@ -62,93 +62,93 @@ extension SocketParsable { } /// Parses a messsage from the engine. Returning either a string error or a complete SocketPacket - func parseString(message: String) -> Either { + func parseString(_ message: String) -> Either { var reader = SocketStringReader(message: message) - guard let type = SocketPacket.PacketType(rawValue: Int(reader.read(1)) ?? -1) else { - return .Left("Invalid packet type") + guard let type = Int(reader.read(count: 1)).flatMap({ SocketPacket.PacketType(rawValue: $0) }) else { + return .left("Invalid packet type") } if !reader.hasNext { - return .Right(SocketPacket(type: type, nsp: "/")) + return .right(SocketPacket(type: type, nsp: "/")) } var namespace = "/" var placeholders = -1 - if type == .BinaryEvent || type == .BinaryAck { - if let holders = Int(reader.readUntilStringOccurence("-")) { + if type == .binaryEvent || type == .binaryAck { + if let holders = Int(reader.readUntilOccurence(of: "-")) { placeholders = holders } else { - return .Left("Invalid packet") + return .left("Invalid packet") } } if reader.currentCharacter == "/" { - namespace = reader.readUntilStringOccurence(",") ?? reader.readUntilEnd() + namespace = reader.readUntilOccurence(of: ",") } if !reader.hasNext { - return .Right(SocketPacket(type: type, nsp: namespace, placeholders: placeholders)) + return .right(SocketPacket(type: type, nsp: namespace, placeholders: placeholders)) } var idString = "" - if type == .Error { - reader.advanceIndexBy(-1) + if type == .error { + reader.advance(by: -1) } else { while reader.hasNext { - if let int = Int(reader.read(1)) { + if let int = Int(reader.read(count: 1)) { idString += String(int) } else { - reader.advanceIndexBy(-2) + reader.advance(by: -2) break } } } - let d = message[reader.currentIndex.advancedBy(1).. Either { + private func parseData(_ data: String) -> Either { do { - return .Right(try data.toArray()) + return .right(try data.toArray()) } catch { - return .Left("Error parsing data for packet") + return .left("Error parsing data for packet") } } // Parses messages recieved - func parseSocketMessage(message: String) { + func parseSocketMessage(_ message: String) { guard !message.isEmpty else { return } DefaultSocketLogger.Logger.log("Parsing %@", type: "SocketParser", args: message) switch parseString(message) { - case let .Left(err): + case let .left(err): DefaultSocketLogger.Logger.error("\(err): %@", type: "SocketParser", args: message) - case let .Right(pack): + case let .right(pack): DefaultSocketLogger.Logger.log("Decoded packet as: %@", type: "SocketParser", args: pack.description) handlePacket(pack) } } - func parseBinaryData(data: NSData) { + func parseBinaryData(_ data: Data) { guard !waitingPackets.isEmpty else { DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser") return @@ -159,9 +159,8 @@ extension SocketParsable { let packet = waitingPackets.removeLast() - if packet.type != .BinaryAck { - handleEvent(packet.event, data: packet.args ?? [], - isInternalMessage: false, withAck: packet.id) + if packet.type != .binaryAck { + handleEvent(packet.event, data: packet.args, isInternalMessage: false, withAck: packet.id) } else { handleAck(packet.id, data: packet.args) } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketStringReader.swift b/Pods/Socket.IO-Client-Swift/Source/SocketStringReader.swift index d1e2b59..8bdb4d4 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketStringReader.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketStringReader.swift @@ -38,31 +38,36 @@ struct SocketStringReader { currentIndex = message.startIndex } - mutating func advanceIndexBy(n: Int) { - currentIndex = currentIndex.advancedBy(n) + @discardableResult + mutating func advance(by: Int) -> String.Index { + currentIndex = message.characters.index(currentIndex, offsetBy: by) + + return currentIndex } - mutating func read(readLength: Int) -> String { - let readString = message[currentIndex.. String { + let readString = message[currentIndex.. String { + mutating func readUntilOccurence(of string: String) -> String { let substring = message[currentIndex.. String { - return read(currentIndex.distanceTo(message.endIndex)) + return read(count: message.characters.distance(from: currentIndex, to: message.endIndex)) } } diff --git a/Pods/Socket.IO-Client-Swift/Source/SocketTypes.swift b/Pods/Socket.IO-Client-Swift/Source/SocketTypes.swift index 7f27c42..42bf329 100644 --- a/Pods/Socket.IO-Client-Swift/Source/SocketTypes.swift +++ b/Pods/Socket.IO-Client-Swift/Source/SocketTypes.swift @@ -24,14 +24,29 @@ import Foundation -public typealias AckCallback = ([AnyObject]) -> Void -public typealias NormalCallback = ([AnyObject], SocketAckEmitter) -> Void -public typealias OnAckCallback = (timeoutAfter: UInt64, callback: AckCallback) -> Void +public protocol SocketData {} -typealias Probe = (msg: String, type: SocketEnginePacketType, data: [NSData]) +extension Array : SocketData {} +extension Bool : SocketData {} +extension Dictionary : SocketData {} +extension Double : SocketData {} +extension Int : SocketData {} +extension NSArray : SocketData {} +extension Data : SocketData {} +extension NSData : SocketData {} +extension NSDictionary : SocketData {} +extension NSString : SocketData {} +extension NSNull : SocketData {} +extension String : SocketData {} + +public typealias AckCallback = ([Any]) -> Void +public typealias NormalCallback = ([Any], SocketAckEmitter) -> Void +public typealias OnAckCallback = (_ timeoutAfter: UInt64, _ callback: @escaping AckCallback) -> Void + +typealias Probe = (msg: String, type: SocketEnginePacketType, data: [Data]) typealias ProbeWaitQueue = [Probe] enum Either { - case Left(E) - case Right(V) + case left(E) + case right(V) } diff --git a/Pods/Socket.IO-Client-Swift/Source/WebSocket.swift b/Pods/Socket.IO-Client-Swift/Source/WebSocket.swift index 1204a78..95982ae 100644 --- a/Pods/Socket.IO-Client-Swift/Source/WebSocket.swift +++ b/Pods/Socket.IO-Client-Swift/Source/WebSocket.swift @@ -31,51 +31,53 @@ public protocol WebSocketDelegate: class { func websocketDidConnect(socket: WebSocket) func websocketDidDisconnect(socket: WebSocket, error: NSError?) func websocketDidReceiveMessage(socket: WebSocket, text: String) - func websocketDidReceiveData(socket: WebSocket, data: NSData) + func websocketDidReceiveData(socket: WebSocket, data: Data) } public protocol WebSocketPongDelegate: class { - func websocketDidReceivePong(socket: WebSocket) + func websocketDidReceivePong(socket: WebSocket, data: Data?) } -public class WebSocket : NSObject, NSStreamDelegate { +public class WebSocket : NSObject, StreamDelegate { 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. + 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 enum CloseCode : UInt16 { - case Normal = 1000 - case GoingAway = 1001 - case ProtocolError = 1002 - case ProtocolUnhandledType = 1003 + case normal = 1000 + case goingAway = 1001 + case protocolError = 1002 + case protocolUnhandledType = 1003 // 1004 reserved. - case NoStatusReceived = 1005 + case noStatusReceived = 1005 //1006 reserved. - case Encoding = 1007 - case PolicyViolated = 1008 - case MessageTooBig = 1009 + case encoding = 1007 + case policyViolated = 1008 + case messageTooBig = 1009 } public static let ErrorDomain = "WebSocket" - enum InternalErrorCode : UInt16 { + enum InternalErrorCode: UInt16 { // 0-999 WebSocket status codes not used - case OutputStreamWriteError = 1 + case outputStreamWriteError = 1 } - //Where the callback is executed. It defaults to the main UI thread queue. - public var queue = dispatch_get_main_queue() + // Where the callback is executed. It defaults to the main UI thread queue. + public var callbackQueue = DispatchQueue.main + + var optionalProtocols: [String]? + + // MARK: - Constants - var optionalProtocols : [String]? - //Constant Values. let headerWSUpgradeName = "Upgrade" let headerWSUpgradeValue = "websocket" let headerWSHostName = "Host" @@ -94,140 +96,162 @@ public class WebSocket : NSObject, NSStreamDelegate { let MaskMask: UInt8 = 0x80 let PayloadLenMask: UInt8 = 0x7F let MaxFrameSize: Int = 32 + let httpSwitchProtocolCode = 101 + let supportedSSLSchemes = ["wss", "https"] class WSResponse { var isFin = false - var code: OpCode = .ContinueFrame + var code: OpCode = .continueFrame var bytesLeft = 0 var frameCount = 0 var buffer: NSMutableData? } + // MARK: - Delegates + + /// Responds to callback about new messages coming in over the WebSocket + /// and also connection/disconnect messages. public weak var delegate: WebSocketDelegate? + + /// Receives a callback for each pong message recived. public weak var pongDelegate: WebSocketPongDelegate? + + + // MARK: - Block based API. + public var onConnect: ((Void) -> Void)? public var onDisconnect: ((NSError?) -> Void)? public var onText: ((String) -> Void)? - public var onData: ((NSData) -> Void)? - public var onPong: ((Void) -> Void)? + public var onData: ((Data) -> Void)? + public var onPong: ((Data?) -> Void)? + public var headers = [String: String]() public var voipEnabled = false - public var selfSignedSSL = false + public var disableSSLCertValidation = false public var security: SSLSecurity? public var enabledSSLCipherSuites: [SSLCipherSuite]? public var origin: String? public var timeout = 5 - public var isConnected :Bool { + public var isConnected: Bool { return connected } - public var currentURL: NSURL {return url} - private var url: NSURL - private var inputStream: NSInputStream? - private var outputStream: NSOutputStream? + + public var currentURL: URL { return url } + + // MARK: - Private + + private var url: URL + private var inputStream: InputStream? + private var outputStream: OutputStream? private var connected = false - private var isCreated = false - private var writeQueue = NSOperationQueue() + private var isConnecting = false + private var writeQueue = OperationQueue() private var readStack = [WSResponse]() - private var inputQueue = [NSData]() - private var fragBuffer: NSData? + private var inputQueue = [Data]() + private var fragBuffer: Data? private var certValidated = false private var didDisconnect = false private var readyToWrite = false private let mutex = NSLock() - private let notificationCenter = NSNotificationCenter.defaultCenter() + private let notificationCenter = NotificationCenter.default private var canDispatch: Bool { mutex.lock() let canWork = readyToWrite mutex.unlock() return canWork } - //the shared processing queue used for all websocket - private static let sharedWorkQueue = dispatch_queue_create("com.vluxe.starscream.websocket", DISPATCH_QUEUE_SERIAL) + /// The shared processing queue used for all WebSocket. + private static let sharedWorkQueue = DispatchQueue(label: "com.vluxe.starscream.websocket", attributes: []) - //used for setting protocols. - public init(url: NSURL, protocols: [String]? = nil) { + /// Used for setting protocols. + public init(url: URL, protocols: [String]? = nil) { self.url = url self.origin = url.absoluteString writeQueue.maxConcurrentOperationCount = 1 optionalProtocols = protocols } - ///Connect to the websocket server on a background thread + // 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. + */ public func connect() { - guard !isCreated else { return } + guard !isConnecting else { return } didDisconnect = false - isCreated = true + isConnecting = true createHTTPRequest() - isCreated = false + isConnecting = false } /** 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. */ - public func disconnect(forceTimeout forceTimeout: NSTimeInterval? = nil) { + public func disconnect(forceTimeout: TimeInterval? = nil, closeCode: UInt16 = CloseCode.normal.rawValue) { switch forceTimeout { - case .Some(let seconds) where seconds > 0: - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(seconds * Double(NSEC_PER_SEC))), queue) { [weak self] in + case .some(let seconds) where seconds > 0: + callbackQueue.asyncAfter(deadline: DispatchTime.now() + Double(Int64(seconds * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)) { [weak self] in self?.disconnectStream(nil) } fallthrough - case .None: - writeError(CloseCode.Normal.rawValue) - + case .none: + writeError(closeCode) default: - self.disconnectStream(nil) + 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 str: The string to write. - parameter completion: The (optional) completion handler. */ - public func writeString(str: String, completion: (() -> ())? = nil) { + public func write(string: String, completion: (() -> ())? = nil) { guard isConnected else { return } - dequeueWrite(str.dataUsingEncoding(NSUTF8StringEncoding)!, code: .TextFrame, writeCompletion: completion) + 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. */ - public func writeData(data: NSData, completion: (() -> ())? = nil) { + public func write(data: Data, completion: (() -> ())? = nil) { guard isConnected else { return } - dequeueWrite(data, code: .BinaryFrame, writeCompletion: completion) + 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 - public func writePing(data: NSData, completion: (() -> ())? = nil) { + /** + Write a ping to the websocket. This sends it as a control frame. + Yodel a sound to the planet. This sends it as an astroid. http://youtu.be/Eu5ZJELRiJ8?t=42s + */ + public func write(ping: Data, completion: (() -> ())? = nil) { guard isConnected else { return } - dequeueWrite(data, code: .Ping, writeCompletion: completion) + dequeueWrite(ping, code: .ping, writeCompletion: completion) } - //private method that starts the connection + /** + Private method that starts the connection. + */ private func createHTTPRequest() { - let urlRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault, "GET", - url, kCFHTTPVersion1_1).takeRetainedValue() + let urlRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault, "GET" as CFString, + url as CFURL, kCFHTTPVersion1_1).takeRetainedValue() var port = url.port if port == nil { - if ["wss", "https"].contains(url.scheme) { + if supportedSSLSchemes.contains(url.scheme!) { port = 443 } else { port = 80 @@ -236,7 +260,7 @@ public class WebSocket : NSObject, NSStreamDelegate { addHeader(urlRequest, key: headerWSUpgradeName, val: headerWSUpgradeValue) addHeader(urlRequest, key: headerWSConnectionName, val: headerWSConnectionValue) if let protocols = optionalProtocols { - addHeader(urlRequest, key: headerWSProtocolName, val: protocols.joinWithSeparator(",")) + addHeader(urlRequest, key: headerWSProtocolName, val: protocols.joined(separator: ",")) } addHeader(urlRequest, key: headerWSVersionName, val: headerWSVersionValue) addHeader(urlRequest, key: headerWSKeyName, val: generateWebSocketKey()) @@ -244,65 +268,71 @@ public class WebSocket : NSObject, NSStreamDelegate { addHeader(urlRequest, key: headerOriginName, val: origin) } addHeader(urlRequest, key: headerWSHostName, val: "\(url.host!):\(port!)") - for (key,value) in headers { + for (key, value) in headers { addHeader(urlRequest, key: key, val: value) } if let cfHTTPMessage = CFHTTPMessageCopySerializedMessage(urlRequest) { let serializedRequest = cfHTTPMessage.takeRetainedValue() - initStreamsWithData(serializedRequest, Int(port!)) + initStreamsWithData(serializedRequest as Data, Int(port!)) } } - //Add a header to the CFHTTPMessage by using the NSString bridges to CFString - private func addHeader(urlRequest: CFHTTPMessage, key: NSString, val: NSString) { - CFHTTPMessageSetHeaderFieldValue(urlRequest, key, val) + /** + Add a header to the CFHTTPMessage by using the NSString bridges to CFString + */ + private func addHeader(_ urlRequest: CFHTTPMessage, key: String, val: String) { + CFHTTPMessageSetHeaderFieldValue(urlRequest, key as CFString, val as CFString) } - //generate a websocket key as needed in rfc + /** + Generate a WebSocket key as needed in RFC. + */ private func generateWebSocketKey() -> String { var key = "" let seed = 16 for _ in 0..? var writeStream: Unmanaged? - let h: NSString = url.host! + let h = url.host! as NSString CFStreamCreatePairWithSocketToHost(nil, h, UInt32(port), &readStream, &writeStream) inputStream = readStream!.takeRetainedValue() outputStream = writeStream!.takeRetainedValue() guard let inStream = inputStream, let outStream = outputStream else { return } inStream.delegate = self outStream.delegate = self - if ["wss", "https"].contains(url.scheme) { - inStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey) - outStream.setProperty(NSStreamSocketSecurityLevelNegotiatedSSL, forKey: NSStreamSocketSecurityLevelKey) + if supportedSSLSchemes.contains(url.scheme!) { + inStream.setProperty(StreamSocketSecurityLevel.negotiatedSSL as AnyObject, forKey: Stream.PropertyKey.socketSecurityLevelKey) + outStream.setProperty(StreamSocketSecurityLevel.negotiatedSSL as AnyObject, forKey: Stream.PropertyKey.socketSecurityLevelKey) } else { certValidated = true //not a https session, so no need to check SSL pinning } if voipEnabled { - inStream.setProperty(NSStreamNetworkServiceTypeVoIP, forKey: NSStreamNetworkServiceType) - outStream.setProperty(NSStreamNetworkServiceTypeVoIP, forKey: NSStreamNetworkServiceType) + inStream.setProperty(StreamNetworkServiceTypeValue.voIP as AnyObject, forKey: Stream.PropertyKey.networkServiceType) + outStream.setProperty(StreamNetworkServiceTypeValue.voIP as AnyObject, forKey: Stream.PropertyKey.networkServiceType) } - if selfSignedSSL { - let settings: [NSObject: NSObject] = [kCFStreamSSLValidatesCertificateChain: NSNumber(bool:false), kCFStreamSSLPeerName: kCFNull] - inStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String) - outStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as String) + if disableSSLCertValidation { + let settings: [NSObject: NSObject] = [kCFStreamSSLValidatesCertificateChain: NSNumber(value: false), kCFStreamSSLPeerName: kCFNull] + inStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as Stream.PropertyKey) + outStream.setProperty(settings, forKey: kCFStreamPropertySSLSettings as Stream.PropertyKey) } if let cipherSuites = self.enabledSSLCipherSuites { - if let sslContextIn = CFReadStreamCopyProperty(inputStream, kCFStreamPropertySSLContext) as! SSLContextRef?, - sslContextOut = CFWriteStreamCopyProperty(outputStream, kCFStreamPropertySSLContext) as! SSLContextRef? { + 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 { @@ -317,6 +347,7 @@ public class WebSocket : NSObject, NSStreamDelegate { } } } + CFReadStreamSetDispatchQueue(inStream, WebSocket.sharedWorkQueue) CFWriteStreamSetDispatchQueue(outStream, WebSocket.sharedWorkQueue) inStream.open() @@ -326,51 +357,54 @@ public class WebSocket : NSObject, NSStreamDelegate { self.readyToWrite = true self.mutex.unlock() - let bytes = UnsafePointer(data.bytes) - var out = timeout * 1000000 //wait 5 seconds before giving up - writeQueue.addOperationWithBlock { [weak self] in + let bytes = UnsafeRawPointer((data as NSData).bytes).assumingMemoryBound(to: UInt8.self) + var out = timeout * 1000000 // wait 5 seconds before giving up + writeQueue.addOperation { [weak self] in while !outStream.hasSpaceAvailable { - usleep(100) //wait until the socket is ready + usleep(100) // wait until the socket is ready out -= 100 if out < 0 { self?.cleanupStream() self?.doDisconnect(self?.errorWithDetail("write wait timed out", code: 2)) return } else if outStream.streamError != nil { - return //disconnectStream will be called. + return // disconnectStream will be called. } } - outStream.write(bytes, maxLength: data.length) + outStream.write(bytes, maxLength: data.count) } } - //delegate for the stream methods. Processes incoming bytes - public func stream(aStream: NSStream, handleEvent eventCode: NSStreamEvent) { - - if let sec = security where !certValidated && [.HasBytesAvailable, .HasSpaceAvailable].contains(eventCode) { - let possibleTrust: AnyObject? = aStream.propertyForKey(kCFStreamPropertySSLPeerTrust as String) - if let trust: AnyObject = possibleTrust { - let domain: AnyObject? = aStream.propertyForKey(kCFStreamSSLPeerName as String) - if sec.isValid(trust as! SecTrustRef, domain: domain as! String?) { - certValidated = true - } else { - let error = errorWithDetail("Invalid SSL certificate", code: 1) - disconnectStream(error) - return - } + + /** + Delegate for the stream methods. Processes incoming bytes + */ + public func stream(_ aStream: Stream, handle eventCode: Stream.Event) { + if let sec = security, !certValidated && [.hasBytesAvailable, .hasSpaceAvailable].contains(eventCode) { + let trust = aStream.property(forKey: kCFStreamPropertySSLPeerTrust as Stream.PropertyKey) as AnyObject + let domain = aStream.property(forKey: kCFStreamSSLPeerName as Stream.PropertyKey) as? String + if sec.isValid(trust as! SecTrust, domain: domain) { + certValidated = true + } else { + let error = errorWithDetail("Invalid SSL certificate", code: 1) + disconnectStream(error) + return } } - if eventCode == .HasBytesAvailable { + if eventCode == .hasBytesAvailable { if aStream == inputStream { processInputStream() } - } else if eventCode == .ErrorOccurred { - disconnectStream(aStream.streamError) - } else if eventCode == .EndEncountered { + } else if eventCode == .errorOccurred { + disconnectStream(aStream.streamError as NSError?) + } else if eventCode == .endEncountered { disconnectStream(nil) } } - //disconnect the stream object - private func disconnectStream(error: NSError?) { + + /** + Disconnect the stream object and notifies the delegate. + */ + private func disconnectStream(_ error: NSError?) { if error == nil { writeQueue.waitUntilAllOperationsAreFinished() } else { @@ -380,6 +414,9 @@ public class WebSocket : NSObject, NSStreamDelegate { doDisconnect(error) } + /** + cleanup the streams. + */ private func cleanupStream() { outputStream?.delegate = nil inputStream?.delegate = nil @@ -395,10 +432,12 @@ public class WebSocket : NSObject, NSStreamDelegate { inputStream = nil } - ///handles the incoming bytes and sending them to the proper processing method + /** + Handles the incoming bytes and sending them to the proper processing method. + */ private func processInputStream() { let buf = NSMutableData(capacity: BUFFER_MAX) - let buffer = UnsafeMutablePointer(buf!.bytes) + let buffer = UnsafeMutableRawPointer(mutating: buf!.bytes).assumingMemoryBound(to: UInt8.self) let length = inputStream!.read(buffer, maxLength: BUFFER_MAX) guard length > 0 else { return } @@ -406,55 +445,63 @@ public class WebSocket : NSObject, NSStreamDelegate { if inputQueue.count == 0 { process = true } - inputQueue.append(NSData(bytes: buffer, length: length)) + inputQueue.append(Data(bytes: buffer, count: length)) if process { dequeueInput() } } - ///dequeue the incoming input so it is processed in order + + /** + Dequeue the incoming input so it is processed in order. + */ private func dequeueInput() { while !inputQueue.isEmpty { let data = inputQueue[0] var work = data if let fragBuffer = fragBuffer { - let combine = NSMutableData(data: fragBuffer) - combine.appendData(data) + var combine = NSData(data: fragBuffer) as Data + combine.append(data) work = combine self.fragBuffer = nil } - let buffer = UnsafePointer(work.bytes) - let length = work.length + let buffer = UnsafeRawPointer((work as NSData).bytes).assumingMemoryBound(to: UInt8.self) + let length = work.count if !connected { processTCPHandshake(buffer, bufferLen: length) } else { processRawMessagesInBuffer(buffer, bufferLen: length) } - inputQueue = inputQueue.filter{$0 != data} + inputQueue = inputQueue.filter{ $0 != data } } } - //handle checking the inital connection status - private func processTCPHandshake(buffer: UnsafePointer, bufferLen: Int) { + /** + Handle checking the inital connection status + */ + private func processTCPHandshake(_ buffer: UnsafePointer, bufferLen: Int) { let code = processHTTP(buffer, bufferLen: bufferLen) switch code { case 0: connected = true guard canDispatch else {return} - dispatch_async(queue) { [weak self] in + callbackQueue.async { [weak self] in guard let s = self else { return } s.onConnect?() - s.delegate?.websocketDidConnect(s) - s.notificationCenter.postNotificationName(WebsocketDidConnectNotification, object: self) + s.delegate?.websocketDidConnect(socket: s) + s.notificationCenter.post(name: NSNotification.Name(WebsocketDidConnectNotification), object: self) } case -1: - fragBuffer = NSData(bytes: buffer, length: bufferLen) - break //do nothing, we are going to collect more data + fragBuffer = Data(bytes: buffer, count: bufferLen) + break // do nothing, we are going to collect more data default: doDisconnect(errorWithDetail("Invalid HTTP upgrade", code: UInt16(code))) } } - ///Finds the HTTP Packet in the TCP stream, by looking for the CRLF. - private func processHTTP(buffer: UnsafePointer, bufferLen: Int) -> Int { + + /** + 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 @@ -481,20 +528,22 @@ public class WebSocket : NSObject, NSStreamDelegate { } return 0 //success } - return -1 //was unable to find the full TCP header + return -1 // Was unable to find the full TCP header. } - ///validates the HTTP is a 101 as per the RFC spec - private func validateResponse(buffer: UnsafePointer, bufferLen: Int) -> Int { + /** + Validates the HTTP is a 101 as per the RFC spec. + */ + private func validateResponse(_ buffer: UnsafePointer, bufferLen: Int) -> Int { let response = CFHTTPMessageCreateEmpty(kCFAllocatorDefault, false).takeRetainedValue() CFHTTPMessageAppendBytes(response, buffer, bufferLen) let code = CFHTTPMessageGetResponseStatusCode(response) - if code != 101 { + if code != httpSwitchProtocolCode { return code } if let cfHeaders = CFHTTPMessageCopyAllHeaderFields(response) { let headers = cfHeaders.takeRetainedValue() as NSDictionary - if let acceptKey = headers[headerWSAcceptName] as? NSString { + if let acceptKey = headers[headerWSAcceptName as NSString] as? NSString { if acceptKey.length > 0 { return 0 } @@ -503,13 +552,17 @@ public class WebSocket : NSObject, NSStreamDelegate { return -1 } - ///read a 16 bit big endian value from a buffer - private static func readUint16(buffer: UnsafePointer, offset: Int) -> UInt16 { + /** + 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 { + /** + 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]) @@ -517,30 +570,35 @@ public class WebSocket : NSObject, NSStreamDelegate { return value } - ///write a 16 bit big endian value to a buffer - private static func writeUint16(buffer: UnsafeMutablePointer, offset: Int, value: UInt16) { + /** + 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) { + /** + 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. - @warn_unused_result + /** + 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 - let baseAddress = buffer.baseAddress + guard let baseAddress = buffer.baseAddress else {return emptyBuffer} let bufferLen = buffer.count - if response != nil && bufferLen < 2 { - fragBuffer = NSData(buffer: buffer) + if response != nil && bufferLen < 2 { + fragBuffer = Data(buffer: buffer) return emptyBuffer } - if let response = response where response.bytesLeft > 0 { + if let response = response, response.bytesLeft > 0 { var len = response.bytesLeft var extra = bufferLen - response.bytesLeft if response.bytesLeft > bufferLen { @@ -548,8 +606,8 @@ public class WebSocket : NSObject, NSStreamDelegate { extra = 0 } response.bytesLeft -= len - response.buffer?.appendData(NSData(bytes: baseAddress, length: len)) - processResponse(response) + response.buffer?.append(Data(bytes: baseAddress, count: len)) + _ = processResponse(response) return buffer.fromOffset(bufferLen - extra) } else { let isFin = (FinMask & baseAddress[0]) @@ -557,104 +615,107 @@ public class WebSocket : NSObject, NSStreamDelegate { let isMasked = (MaskMask & baseAddress[1]) let payloadLen = (PayloadLenMask & baseAddress[1]) var offset = 2 - if (isMasked > 0 || (RSVMask & baseAddress[0]) > 0) && receivedOpcode != .Pong { - let errCode = CloseCode.ProtocolError.rawValue + if (isMasked > 0 || (RSVMask & baseAddress[0]) > 0) && receivedOpcode != .pong { + let errCode = CloseCode.protocolError.rawValue doDisconnect(errorWithDetail("masked and rsv data is not currently supported", code: 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 + let isControlFrame = (receivedOpcode == .connectionClose || receivedOpcode == .ping) + if !isControlFrame && (receivedOpcode != .binaryFrame && receivedOpcode != .continueFrame && + receivedOpcode != .textFrame && receivedOpcode != .pong) { + let errCode = CloseCode.protocolError.rawValue doDisconnect(errorWithDetail("unknown opcode: \(receivedOpcode)", code: errCode)) writeError(errCode) return emptyBuffer } if isControlFrame && isFin == 0 { - let errCode = CloseCode.ProtocolError.rawValue + let errCode = CloseCode.protocolError.rawValue doDisconnect(errorWithDetail("control frames can't be fragmented", code: errCode)) writeError(errCode) return emptyBuffer } - if receivedOpcode == .ConnectionClose { - var code = CloseCode.Normal.rawValue + if receivedOpcode == .connectionClose { + var code = CloseCode.normal.rawValue if payloadLen == 1 { - code = CloseCode.ProtocolError.rawValue + code = CloseCode.protocolError.rawValue } else if payloadLen > 1 { code = WebSocket.readUint16(baseAddress, offset: offset) if code < 1000 || (code > 1003 && code < 1007) || (code > 1011 && code < 3000) { - code = CloseCode.ProtocolError.rawValue + code = CloseCode.protocolError.rawValue } offset += 2 } + var closeReason = "connection closed by server" if payloadLen > 2 { - let len = Int(payloadLen-2) + let len = Int(payloadLen - 2) if len > 0 { let bytes = baseAddress + offset - let str: NSString? = NSString(data: NSData(bytes: bytes, length: len), encoding: NSUTF8StringEncoding) - if str == nil { - code = CloseCode.ProtocolError.rawValue + if let customCloseReason = String(data: Data(bytes: bytes, count: len), encoding: .utf8) { + closeReason = customCloseReason + } else { + code = CloseCode.protocolError.rawValue } } } - doDisconnect(errorWithDetail("connection closed by server", code: code)) + doDisconnect(errorWithDetail(closeReason, code: code)) writeError(code) return emptyBuffer } if isControlFrame && payloadLen > 125 { - writeError(CloseCode.ProtocolError.rawValue) + writeError(CloseCode.protocolError.rawValue) return emptyBuffer } var dataLength = UInt64(payloadLen) if dataLength == 127 { dataLength = WebSocket.readUint64(baseAddress, offset: offset) - offset += sizeof(UInt64) + offset += MemoryLayout.size } else if dataLength == 126 { dataLength = UInt64(WebSocket.readUint16(baseAddress, offset: offset)) - offset += sizeof(UInt16) + offset += MemoryLayout.size } if bufferLen < offset || UInt64(bufferLen - offset) < dataLength { - fragBuffer = NSData(bytes: baseAddress, length: bufferLen) + fragBuffer = Data(bytes: baseAddress, count: bufferLen) return emptyBuffer } var len = dataLength if dataLength > UInt64(bufferLen) { len = UInt64(bufferLen-offset) } - let data: NSData + let data: Data if len < 0 { len = 0 - data = NSData() + data = Data() } else { - data = NSData(bytes: baseAddress+offset, length: Int(len)) + data = Data(bytes: baseAddress+offset, count: Int(len)) } - if receivedOpcode == .Pong { + if receivedOpcode == .pong { if canDispatch { - dispatch_async(queue) { [weak self] in + callbackQueue.async { [weak self] in guard let s = self else { return } - s.onPong?() - s.pongDelegate?.websocketDidReceivePong(s) + let pongData: Data? = data.count > 0 ? data : nil + s.onPong?(pongData) + s.pongDelegate?.websocketDidReceivePong(socket: s, data: pongData) } } return buffer.fromOffset(offset + Int(len)) } var response = readStack.last if isControlFrame { - response = nil //don't append pings + response = nil // Don't append pings. } - if isFin == 0 && receivedOpcode == .ContinueFrame && response == nil { - let errCode = CloseCode.ProtocolError.rawValue + if isFin == 0 && receivedOpcode == .continueFrame && response == nil { + let errCode = CloseCode.protocolError.rawValue doDisconnect(errorWithDetail("continue frame before a binary or text frame", code: errCode)) writeError(errCode) return emptyBuffer } var isNew = false if response == nil { - if receivedOpcode == .ContinueFrame { - let errCode = CloseCode.ProtocolError.rawValue + if receivedOpcode == .continueFrame { + let errCode = CloseCode.protocolError.rawValue doDisconnect(errorWithDetail("first frame can't be a continue frame", - code: errCode)) + code: errCode)) writeError(errCode) return emptyBuffer } @@ -664,16 +725,16 @@ public class WebSocket : NSObject, NSStreamDelegate { response!.bytesLeft = Int(dataLength) response!.buffer = NSMutableData(data: data) } else { - if receivedOpcode == .ContinueFrame { + if receivedOpcode == .continueFrame { response!.bytesLeft = Int(dataLength) } else { - let errCode = CloseCode.ProtocolError.rawValue + let errCode = CloseCode.protocolError.rawValue doDisconnect(errorWithDetail("second and beyond of fragment message must be a continue frame", - code: errCode)) + code: errCode)) writeError(errCode) return emptyBuffer } - response!.buffer!.appendData(data) + response!.buffer!.append(data) } if let response = response { response.bytesLeft -= Int(len) @@ -682,51 +743,55 @@ public class WebSocket : NSObject, NSStreamDelegate { if isNew { readStack.append(response) } - processResponse(response) + _ = processResponse(response) } - let step = Int(offset+numericCast(len)) + 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) { + /** + 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 = NSData(buffer: buffer) + fragBuffer = Data(buffer: buffer) } } - ///process the finished response of a buffer - private func processResponse(response: WSResponse) -> Bool { + /** + Process the finished response of a buffer. + */ + private func processResponse(_ response: WSResponse) -> Bool { if response.isFin && response.bytesLeft <= 0 { - if response.code == .Ping { - let data = response.buffer! //local copy so it is perverse for writing - dequeueWrite(data, code: OpCode.Pong) - } else if response.code == .TextFrame { - let str: NSString? = NSString(data: response.buffer!, encoding: NSUTF8StringEncoding) + if response.code == .ping { + let data = response.buffer! // local copy so it is perverse for writing + dequeueWrite(data as Data, code: .pong) + } else if response.code == .textFrame { + let str: NSString? = NSString(data: response.buffer! as Data, encoding: String.Encoding.utf8.rawValue) if str == nil { - writeError(CloseCode.Encoding.rawValue) + writeError(CloseCode.encoding.rawValue) return false } if canDispatch { - dispatch_async(queue) { [weak self] in + callbackQueue.async { [weak self] in guard let s = self else { return } s.onText?(str! as String) - s.delegate?.websocketDidReceiveMessage(s, text: str! as String) + s.delegate?.websocketDidReceiveMessage(socket: s, text: str! as String) } } - } else if response.code == .BinaryFrame { + } else if response.code == .binaryFrame { if canDispatch { - let data = response.buffer! //local copy so it is perverse for writing - dispatch_async(queue) { [weak self] in + let data = response.buffer! // local copy so it is perverse for writing + callbackQueue.async { [weak self] in guard let s = self else { return } - s.onData?(data) - s.delegate?.websocketDidReceiveData(s, data: data) + s.onData?(data as Data) + s.delegate?.websocketDidReceiveData(socket: s, data: data as Data) } } } @@ -736,72 +801,78 @@ public class WebSocket : NSObject, NSStreamDelegate { return false } - ///Create an error - private func errorWithDetail(detail: String, code: UInt16) -> NSError { + /** + Create an error + */ + private func errorWithDetail(_ detail: String, code: UInt16) -> NSError { var details = [String: String]() details[NSLocalizedDescriptionKey] = detail return NSError(domain: WebSocket.ErrorDomain, code: Int(code), userInfo: details) } - ///write a an error to the socket - private func writeError(code: UInt16) { - let buf = NSMutableData(capacity: sizeof(UInt16)) - let buffer = UnsafeMutablePointer(buf!.bytes) + /** + 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(NSData(bytes: buffer, length: sizeof(UInt16)), code: .ConnectionClose) + dequeueWrite(Data(bytes: buffer, count: MemoryLayout.size), code: .connectionClose) } - ///used to write things to the stream - private func dequeueWrite(data: NSData, code: OpCode, writeCompletion: (() -> ())? = nil) { - writeQueue.addOperationWithBlock { [weak self] in + + /** + Used to write things to the stream + */ + private func dequeueWrite(_ data: Data, code: OpCode, writeCompletion: (() -> ())? = nil) { + writeQueue.addOperation { [weak self] in //stream isn't ready, let's wait guard let s = self else { return } var offset = 2 - let bytes = UnsafeMutablePointer(data.bytes) - let dataLength = data.length + let dataLength = data.count let frame = NSMutableData(capacity: dataLength + s.MaxFrameSize) - let buffer = UnsafeMutablePointer(frame!.mutableBytes) + let buffer = UnsafeMutableRawPointer(frame!.mutableBytes).assumingMemoryBound(to: UInt8.self) buffer[0] = s.FinMask | code.rawValue 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 += sizeof(UInt16) + offset += MemoryLayout.size } else { buffer[1] = 127 WebSocket.writeUint64(buffer, offset: offset, value: UInt64(dataLength)) - offset += sizeof(UInt64) + offset += MemoryLayout.size } buffer[1] |= s.MaskMask let maskKey = UnsafeMutablePointer(buffer + offset) - SecRandomCopyBytes(kSecRandomDefault, Int(sizeof(UInt32)), maskKey) - offset += sizeof(UInt32) + _ = SecRandomCopyBytes(kSecRandomDefault, Int(MemoryLayout.size), maskKey) + offset += MemoryLayout.size for i in 0...size] offset += 1 } var total = 0 while true { guard let outStream = s.outputStream else { break } - let writeBuffer = UnsafePointer(frame!.bytes+total) + let writeBuffer = UnsafeRawPointer(frame!.bytes+total).assumingMemoryBound(to: UInt8.self) let len = outStream.write(writeBuffer, maxLength: offset-total) if len < 0 { - var error: NSError? + var error: Error? if let streamError = outStream.streamError { error = streamError } else { - let errCode = InternalErrorCode.OutputStreamWriteError.rawValue + let errCode = InternalErrorCode.outputStreamWriteError.rawValue error = s.errorWithDetail("output stream error during write", code: errCode) } - s.doDisconnect(error) + s.doDisconnect(error as NSError?) break } else { total += len } if total >= offset { - if let queue = self?.queue, callback = writeCompletion { - dispatch_async(queue) { + if let queue = self?.callbackQueue, let callback = writeCompletion { + queue.async { callback() } } @@ -813,21 +884,25 @@ public class WebSocket : NSObject, NSStreamDelegate { } } - ///used to preform the disconnect delegate - private func doDisconnect(error: NSError?) { + /** + Used to preform the disconnect delegate + */ + private func doDisconnect(_ error: NSError?) { guard !didDisconnect else { return } didDisconnect = true connected = false guard canDispatch else {return} - dispatch_async(queue) { [weak self] in + callbackQueue.async { [weak self] in guard let s = self else { return } s.onDisconnect?(error) - s.delegate?.websocketDidDisconnect(s, error: error) - let userInfo = error.map({ [WebsocketDisconnectionErrorKeyName: $0] }) - s.notificationCenter.postNotificationName(WebsocketDidDisconnectNotification, object: self, userInfo: userInfo) + s.delegate?.websocketDidDisconnect(socket: s, error: error) + let userInfo = error.map{ [WebsocketDisconnectionErrorKeyName: $0] } + s.notificationCenter.post(name: NSNotification.Name(WebsocketDidDisconnectNotification), object: self, userInfo: userInfo) } } + // MARK: - Deinit + deinit { mutex.lock() readyToWrite = false @@ -837,18 +912,18 @@ public class WebSocket : NSObject, NSStreamDelegate { } -private extension NSData { +private extension Data { - convenience init(buffer: UnsafeBufferPointer) { - self.init(bytes: buffer.baseAddress, length: buffer.count) + init(buffer: UnsafeBufferPointer) { + self.init(bytes: buffer.baseAddress!, count: buffer.count) } } private extension UnsafeBufferPointer { - func fromOffset(offset: Int) -> UnsafeBufferPointer { - return UnsafeBufferPointer(start: baseAddress.advancedBy(offset), count: count - offset) + func fromOffset(_ offset: Int) -> UnsafeBufferPointer { + return UnsafeBufferPointer(start: baseAddress?.advanced(by: offset), count: count - offset) } } diff --git a/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol-frameworks.sh b/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol-frameworks.sh index a7ab1c7..026730f 100755 --- a/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol-frameworks.sh +++ b/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol-frameworks.sh @@ -84,8 +84,8 @@ strip_invalid_archs() { if [[ "$CONFIGURATION" == "Debug" ]]; then - install_framework "$BUILT_PRODUCTS_DIR/Socket.IO-Client-Swift/SocketIOClientSwift.framework" + install_framework "$BUILT_PRODUCTS_DIR/Socket.IO-Client-Swift/SocketIO.framework" fi if [[ "$CONFIGURATION" == "Release" ]]; then - install_framework "$BUILT_PRODUCTS_DIR/Socket.IO-Client-Swift/SocketIOClientSwift.framework" + install_framework "$BUILT_PRODUCTS_DIR/Socket.IO-Client-Swift/SocketIO.framework" fi diff --git a/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol.debug.xcconfig b/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol.debug.xcconfig index c320fda..d1cbd95 100644 --- a/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol.debug.xcconfig +++ b/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol.debug.xcconfig @@ -2,8 +2,8 @@ EMBEDDED_CONTENT_CONTAINS_SWIFT = YES FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Socket.IO-Client-Swift" 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/Socket.IO-Client-Swift/SocketIOClientSwift.framework/Headers" -OTHER_LDFLAGS = $(inherited) -framework "SocketIOClientSwift" +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Socket.IO-Client-Swift/SocketIO.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "SocketIO" OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" PODS_BUILD_DIR = $BUILD_DIR PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) diff --git a/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol.release.xcconfig b/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol.release.xcconfig index c320fda..d1cbd95 100644 --- a/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol.release.xcconfig +++ b/Pods/Target Support Files/Pods-Arcohol/Pods-Arcohol.release.xcconfig @@ -2,8 +2,8 @@ EMBEDDED_CONTENT_CONTAINS_SWIFT = YES FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Socket.IO-Client-Swift" 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/Socket.IO-Client-Swift/SocketIOClientSwift.framework/Headers" -OTHER_LDFLAGS = $(inherited) -framework "SocketIOClientSwift" +OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Socket.IO-Client-Swift/SocketIO.framework/Headers" +OTHER_LDFLAGS = $(inherited) -framework "SocketIO" OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" PODS_BUILD_DIR = $BUILD_DIR PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) diff --git a/Pods/Target Support Files/Socket.IO-Client-Swift/Info.plist b/Pods/Target Support Files/Socket.IO-Client-Swift/Info.plist index 626dc56..17b8536 100644 --- a/Pods/Target Support Files/Socket.IO-Client-Swift/Info.plist +++ b/Pods/Target Support Files/Socket.IO-Client-Swift/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 6.1.6 + 8.0.1 CFBundleSignature ???? CFBundleVersion diff --git a/Pods/Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift-umbrella.h b/Pods/Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift-umbrella.h index 4ad77f3..c1679a4 100644 --- a/Pods/Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift-umbrella.h +++ b/Pods/Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift-umbrella.h @@ -1,6 +1,6 @@ #import -FOUNDATION_EXPORT double SocketIOClientSwiftVersionNumber; -FOUNDATION_EXPORT const unsigned char SocketIOClientSwiftVersionString[]; +FOUNDATION_EXPORT double SocketIOVersionNumber; +FOUNDATION_EXPORT const unsigned char SocketIOVersionString[]; diff --git a/Pods/Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift.modulemap b/Pods/Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift.modulemap index 65311f6..f91c479 100644 --- a/Pods/Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift.modulemap +++ b/Pods/Target Support Files/Socket.IO-Client-Swift/Socket.IO-Client-Swift.modulemap @@ -1,4 +1,4 @@ -framework module SocketIOClientSwift { +framework module SocketIO { umbrella header "Socket.IO-Client-Swift-umbrella.h" export * diff --git a/podfile b/podfile index 610b0a4..9e8061d 100644 --- a/podfile +++ b/podfile @@ -4,5 +4,5 @@ source 'https://github.com/CocoaPods/Specs' use_frameworks! target 'Arcohol' do - pod 'Socket.IO-Client-Swift', '~> 6.1.6' # Or latest version + pod 'Socket.IO-Client-Swift', '~> 8.0.1' end