Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
* development:
  correct beta version in podspec
  beta version
  swift 5
  call closeOutEngine to clean up after a ping timeout
  • Loading branch information
nuclearace committed Mar 28, 2019
2 parents 19a1774 + bd74284 commit 6037b85
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: objective-c
xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder
xcode_scheme: SocketIO-Mac
osx_image: xcode10
osx_image: xcode10.2
branches:
only:
- master
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# v15.0.0

- Swift 5

# v14.0.0

- Minimum version of the client is now Swift 4.2.
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "daltoniam/Starscream" ~> 3.0
github "daltoniam/Starscream" ~> 3.1
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "daltoniam/Starscream" "3.0.6"
github "daltoniam/Starscream" "3.1.0"
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"repositoryURL": "https://github.com/daltoniam/Starscream",
"state": {
"branch": null,
"revision": "ebdc260ea64e68f7569c62e8744b5cd15d3a49d6",
"version": "3.0.6"
"revision": "9c03ef715d1bc9334b446c90df53586dd38cf849",
"version": "3.1.0"
}
}
]
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:4.2
// swift-tools-version:5.0

import PackageDescription

Expand All @@ -8,7 +8,7 @@ let package = Package(
.library(name: "SocketIO", targets: ["SocketIO"])
],
dependencies: [
.package(url: "https://github.com/daltoniam/Starscream", .upToNextMinor(from: "3.0.0")),
.package(url: "https://github.com/daltoniam/Starscream", .upToNextMinor(from: "3.1.0")),
],
targets: [
.target(name: "SocketIO", dependencies: ["Starscream"]),
Expand Down
10 changes: 5 additions & 5 deletions Socket.IO-Client-Swift.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "Socket.IO-Client-Swift"
s.module_name = "SocketIO"
s.version = "14.0.0"
s.version = "15.0.0-beta1"
s.summary = "Socket.IO-client for iOS and OS X"
s.description = <<-DESC
Socket.IO-client for iOS and OS X.
Expand All @@ -18,14 +18,14 @@ Pod::Spec.new do |s|
s.requires_arc = true
s.source = {
:git => "https://github.com/socketio/socket.io-client-swift.git",
:tag => 'v14.0.0',
:tag => 'v15.0.0-beta1',
:submodules => true
}

s.swift_version = "4.2"
s.swift_version = "5"
s.pod_target_xcconfig = {
'SWIFT_VERSION' => '4.2'
'SWIFT_VERSION' => '5.0'
}
s.source_files = "Source/SocketIO/**/*.swift", "Source/SocketIO/*.swift"
s.dependency "Starscream", "~> 3.0.6"
s.dependency "Starscream", "~> 3.1"
end
17 changes: 10 additions & 7 deletions Socket.IO-Client-Swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@
attributes = {
LastSwiftMigration = 0730;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1020;
TargetAttributes = {
572EF2371B51F18A00EEBB58 = {
CreatedOnToolsVersion = 6.4;
Expand All @@ -411,6 +411,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 572EF20D1B51F12F00EEBB58;
Expand Down Expand Up @@ -523,6 +524,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BITCODE_GENERATION_MODE = bitcode;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
Expand Down Expand Up @@ -587,7 +589,7 @@
PRODUCT_NAME = SocketIO;
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
VALID_ARCHS = "i386 x86_64 armv7 armv7s arm64 armv7k";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
Expand All @@ -598,6 +600,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BITCODE_GENERATION_MODE = bitcode;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
Expand Down Expand Up @@ -659,7 +662,7 @@
PRODUCT_NAME = SocketIO;
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
VALID_ARCHS = "i386 x86_64 armv7 armv7s arm64 armv7k";
WATCHOS_DEPLOYMENT_TARGET = 2.0;
Expand Down Expand Up @@ -727,7 +730,7 @@
SWIFT_INCLUDE_PATHS = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 10.0;
VALID_ARCHS = "$(inherited)";
Expand Down Expand Up @@ -790,7 +793,7 @@
SUPPORTED_PLATFORMS = "$(inherited)";
SWIFT_INCLUDE_PATHS = "";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TVOS_DEPLOYMENT_TARGET = 10.0;
VALID_ARCHS = "$(inherited)";
Expand Down Expand Up @@ -875,7 +878,7 @@
SUPPORTED_PLATFORMS = "$(inherited)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
VALID_ARCHS = "$(inherited)";
};
Expand Down Expand Up @@ -949,7 +952,7 @@
SDKROOT = macosx;
SUPPORTED_PLATFORMS = "$(inherited)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 10.0;
VALID_ARCHS = "$(inherited)";
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
7 changes: 4 additions & 3 deletions Source/SocketIO/Ack/SocketAckManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public enum SocketAckStatus : String {
private struct SocketAck : Hashable {
let ack: Int
var callback: AckCallback!
var hashValue: Int {
return ack.hashValue
}

init(ack: Int) {
self.ack = ack
Expand All @@ -49,6 +46,10 @@ private struct SocketAck : Hashable {
self.callback = callback
}

func hash(into hasher: inout Hasher) {
ack.hash(into: &hasher)
}

fileprivate static func <(lhs: SocketAck, rhs: SocketAck) -> Bool {
return lhs.ack < rhs.ack
}
Expand Down
2 changes: 1 addition & 1 deletion Source/SocketIO/Client/SocketIOClientSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public protocol SocketIOClientSpec : AnyObject {

public extension SocketIOClientSpec {
/// Default implementation.
public func didError(reason: String) {
func didError(reason: String) {
DefaultSocketLogger.Logger.error("\(reason)", type: "SocketIOClient")

handleClientEvent(.error, data: [reason])
Expand Down
3 changes: 1 addition & 2 deletions Source/SocketIO/Engine/SocketEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,7 @@ open class SocketEngine : NSObject, URLSessionDelegate, SocketEnginePollable, So

// Server is not responding
if pongsMissed > pongsMissedMax {
client?.engineDidClose(reason: "Ping timeout")

closeOutEngine(reason: "Ping timeout")
return
}

Expand Down
2 changes: 1 addition & 1 deletion Source/SocketIO/Engine/SocketEngineSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ extension SocketEngineSpec {
if polling {
return .right("b4" + data.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0)))
} else {
return .left(Data(bytes: [0x4]) + data)
return .left(Data([0x4]) + data)
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/SocketIO/Parse/SocketPacket.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public extension SocketPacket {
// MARK: PacketType enum

/// The type of packets.
public enum PacketType: Int {
enum PacketType: Int {
// MARK: Cases

/// Connect: 0
Expand Down
4 changes: 2 additions & 2 deletions Source/SocketIO/Parse/SocketParsable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public extension SocketParsable where Self: SocketManagerSpec & SocketDataBuffer
///
/// - parameter message: The string that needs parsing.
/// - returns: A completed socket packet or nil if the packet is invalid.
public func parseSocketMessage(_ message: String) -> SocketPacket? {
func parseSocketMessage(_ message: String) -> SocketPacket? {
guard !message.isEmpty else { return nil }

DefaultSocketLogger.Logger.log("Parsing \(message)", type: "SocketParser")
Expand All @@ -166,7 +166,7 @@ public extension SocketParsable where Self: SocketManagerSpec & SocketDataBuffer
///
/// - parameter data: The data that should be attached to a packet.
/// - returns: A completed socket packet if there is no more data left to collect.
public func parseBinaryData(_ data: Data) -> SocketPacket? {
func parseBinaryData(_ data: Data) -> SocketPacket? {
guard !waitingPackets.isEmpty else {
DefaultSocketLogger.Logger.error("Got data when not remaking packet", type: "SocketParser")

Expand Down
10 changes: 6 additions & 4 deletions Source/SocketIO/Util/SocketLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,19 @@ public protocol SocketLogger : AnyObject {
public extension SocketLogger {
/// Default implementation.
func log(_ message: @autoclosure () -> String, type: String) {
abstractLog("LOG", message: message, type: type)
guard log else { return }

abstractLog("LOG", message: message(), type: type)
}

/// Default implementation.
func error(_ message: @autoclosure () -> String, type: String) {
abstractLog("ERROR", message: message, type: type)
guard log else { return }

abstractLog("ERROR", message: message(), type: type)
}

private func abstractLog(_ logType: String, message: @autoclosure () -> String, type: String) {
guard log else { return }

NSLog("\(logType) \(type): %@", message())
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/SocketIO/Util/SocketStringReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct SocketStringReader {
mutating func readUntilOccurence(of string: String) -> String {
let substring = message.utf16[currentIndex...]

guard let foundIndex = substring.index(of: string.utf16.first!) else {
guard let foundIndex = substring.firstIndex(where: { $0 == string.utf16.first! }) else {
currentIndex = message.utf16.endIndex

return String(substring)!
Expand Down

0 comments on commit 6037b85

Please sign in to comment.