Merge development
This commit is contained in:
commit
aae61f3b2e
@ -88,7 +88,7 @@ Carthage
|
|||||||
-----------------
|
-----------------
|
||||||
Add this line to your `Cartfile`:
|
Add this line to your `Cartfile`:
|
||||||
```
|
```
|
||||||
github "socketio/socket.io-client-swift" ~> 6.1.1 # Or latest version
|
github "socketio/socket.io-client-swift" ~> 6.1.2 # Or latest version
|
||||||
```
|
```
|
||||||
|
|
||||||
Run `carthage update --platform ios,macosx`.
|
Run `carthage update --platform ios,macosx`.
|
||||||
@ -102,7 +102,7 @@ source 'https://github.com/CocoaPods/Specs.git'
|
|||||||
platform :ios, '8.0'
|
platform :ios, '8.0'
|
||||||
use_frameworks!
|
use_frameworks!
|
||||||
|
|
||||||
pod 'Socket.IO-Client-Swift', '~> 6.1.1' # Or latest version
|
pod 'Socket.IO-Client-Swift', '~> 6.1.2' # Or latest version
|
||||||
```
|
```
|
||||||
|
|
||||||
Install pods:
|
Install pods:
|
||||||
@ -130,7 +130,7 @@ CocoaSeeds
|
|||||||
Add this line to your `Seedfile`:
|
Add this line to your `Seedfile`:
|
||||||
|
|
||||||
```
|
```
|
||||||
github "socketio/socket.io-client-swift", "v6.1.1", :files => "Source/*.swift" # Or latest version
|
github "socketio/socket.io-client-swift", "v6.1.2", :files => "Source/*.swift" # Or latest version
|
||||||
```
|
```
|
||||||
|
|
||||||
Run `seed install`.
|
Run `seed install`.
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "Socket.IO-Client-Swift"
|
s.name = "Socket.IO-Client-Swift"
|
||||||
s.module_name = "SocketIOClientSwift"
|
s.module_name = "SocketIOClientSwift"
|
||||||
s.version = "6.1.1"
|
s.version = "6.1.2"
|
||||||
s.summary = "Socket.IO-client for iOS and OS X"
|
s.summary = "Socket.IO-client for iOS and OS X"
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
Socket.IO-client for iOS and OS X.
|
Socket.IO-client for iOS and OS X.
|
||||||
@ -14,7 +14,7 @@ Pod::Spec.new do |s|
|
|||||||
s.ios.deployment_target = '8.0'
|
s.ios.deployment_target = '8.0'
|
||||||
s.osx.deployment_target = '10.10'
|
s.osx.deployment_target = '10.10'
|
||||||
s.tvos.deployment_target = '9.0'
|
s.tvos.deployment_target = '9.0'
|
||||||
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.1' }
|
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.2' }
|
||||||
s.source_files = "Source/**/*.swift"
|
s.source_files = "Source/**/*.swift"
|
||||||
s.requires_arc = true
|
s.requires_arc = true
|
||||||
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
|
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files
|
||||||
|
|||||||
@ -160,7 +160,6 @@
|
|||||||
572EF21D1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
572EF21D1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = "<group>"; };
|
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = "<group>"; };
|
||||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
572EF22A1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
|
||||||
572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-Mac.h"; sourceTree = "<group>"; };
|
572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-Mac.h"; sourceTree = "<group>"; };
|
||||||
@ -253,7 +252,6 @@
|
|||||||
children = (
|
children = (
|
||||||
5764DF7B1B51F24A004FF46E /* Source */,
|
5764DF7B1B51F24A004FF46E /* Source */,
|
||||||
572EF21B1B51F16C00EEBB58 /* SocketIO-iOS */,
|
572EF21B1B51F16C00EEBB58 /* SocketIO-iOS */,
|
||||||
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */,
|
|
||||||
572EF2391B51F18A00EEBB58 /* SocketIO-Mac */,
|
572EF2391B51F18A00EEBB58 /* SocketIO-Mac */,
|
||||||
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */,
|
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */,
|
||||||
572EF21A1B51F16C00EEBB58 /* Products */,
|
572EF21A1B51F16C00EEBB58 /* Products */,
|
||||||
@ -290,22 +288,6 @@
|
|||||||
name = "Supporting Files";
|
name = "Supporting Files";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
572EF2291B51F16C00EEBB58 /* Supporting Files */,
|
|
||||||
);
|
|
||||||
path = "SocketIO-iOSTests";
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
572EF2291B51F16C00EEBB58 /* Supporting Files */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
572EF22A1B51F16C00EEBB58 /* Info.plist */,
|
|
||||||
);
|
|
||||||
name = "Supporting Files";
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
572EF2391B51F18A00EEBB58 /* SocketIO-Mac */ = {
|
572EF2391B51F18A00EEBB58 /* SocketIO-Mac */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
||||||
<plist version="1.0">
|
|
||||||
<dict>
|
|
||||||
<key>CFBundleDevelopmentRegion</key>
|
|
||||||
<string>en</string>
|
|
||||||
<key>CFBundleExecutable</key>
|
|
||||||
<string>$(EXECUTABLE_NAME)</string>
|
|
||||||
<key>CFBundleIdentifier</key>
|
|
||||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
|
||||||
<key>CFBundleInfoDictionaryVersion</key>
|
|
||||||
<string>6.0</string>
|
|
||||||
<key>CFBundleName</key>
|
|
||||||
<string>$(PRODUCT_NAME)</string>
|
|
||||||
<key>CFBundlePackageType</key>
|
|
||||||
<string>BNDL</string>
|
|
||||||
<key>CFBundleShortVersionString</key>
|
|
||||||
<string>1.0</string>
|
|
||||||
<key>CFBundleSignature</key>
|
|
||||||
<string>????</string>
|
|
||||||
<key>CFBundleVersion</key>
|
|
||||||
<string>1</string>
|
|
||||||
</dict>
|
|
||||||
</plist>
|
|
||||||
@ -153,9 +153,8 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
// binary in base64 string
|
// binary in base64 string
|
||||||
let noPrefix = message[message.characters.index(message.startIndex, offsetBy: 2)..<message.endIndex]
|
let noPrefix = message[message.characters.index(message.startIndex, offsetBy: 2)..<message.endIndex]
|
||||||
|
|
||||||
if let data = NSData(base64Encoded: noPrefix,
|
if let data = NSData(base64Encoded: noPrefix, options: .ignoreUnknownCharacters) {
|
||||||
options: .ignoreUnknownCharacters) {
|
client?.parseEngineBinaryData(data)
|
||||||
client?.parseEngineBinaryData(data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
@ -261,7 +260,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func didError(error: String) {
|
public func didError(error: String) {
|
||||||
DefaultSocketLogger.Logger.error(error, type: logType)
|
DefaultSocketLogger.Logger.error("%@", type: logType, args: error)
|
||||||
client?.engineDidError(reason: error)
|
client?.engineDidError(reason: error)
|
||||||
disconnect(reason: error)
|
disconnect(reason: error)
|
||||||
}
|
}
|
||||||
@ -537,13 +536,11 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
connected = false
|
connected = false
|
||||||
websocket = false
|
websocket = false
|
||||||
|
|
||||||
let reason = error?.localizedDescription ?? "Socket Disconnected"
|
if let reason = error?.localizedDescription {
|
||||||
|
|
||||||
if error != nil {
|
|
||||||
didError(error: reason)
|
didError(error: reason)
|
||||||
|
} else {
|
||||||
|
client?.engineDidClose(reason: "Socket Disconnected")
|
||||||
}
|
}
|
||||||
|
|
||||||
client?.engineDidClose(reason: reason)
|
|
||||||
} else {
|
} else {
|
||||||
flushProbeWait()
|
flushProbeWait()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -213,9 +213,7 @@ extension SocketEnginePollable {
|
|||||||
fixedMessage = message
|
fixedMessage = message
|
||||||
}
|
}
|
||||||
|
|
||||||
let strMsg = "\(type.rawValue)\(fixedMessage)"
|
postWait.append(String(type.rawValue) + fixedMessage)
|
||||||
|
|
||||||
postWait.append(strMsg)
|
|
||||||
|
|
||||||
for data in datas {
|
for data in datas {
|
||||||
if case let .Right(bin) = createBinaryDataForSend(using: data) {
|
if case let .Right(bin) = createBinaryDataForSend(using: data) {
|
||||||
|
|||||||
@ -197,8 +197,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
|||||||
handleEvent("disconnect", data: [reason as AnyObject], isInternalMessage: true)
|
handleEvent("disconnect", data: [reason as AnyObject], isInternalMessage: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disconnects the socket. Only reconnect the same socket if you know what you're doing.
|
/// Disconnects the socket.
|
||||||
/// Will turn off automatic reconnects.
|
|
||||||
public func disconnect() {
|
public func disconnect() {
|
||||||
assert(status != .notConnected, "Tried closing a NotConnected client")
|
assert(status != .notConnected, "Tried closing a NotConnected client")
|
||||||
|
|
||||||
|
|||||||
@ -111,73 +111,31 @@ struct SocketPacket {
|
|||||||
return message + restOfMessage
|
return message + restOfMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createAck() -> String {
|
|
||||||
let message: String
|
|
||||||
|
|
||||||
if type == .Ack {
|
|
||||||
if nsp == "/" {
|
|
||||||
message = "3\(id)"
|
|
||||||
} else {
|
|
||||||
message = "3\(nsp),\(id)"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if nsp == "/" {
|
|
||||||
message = "6\(binary.count)-\(id)"
|
|
||||||
} else {
|
|
||||||
message = "6\(binary.count)-\(nsp),\(id)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return completeMessage(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private func createMessageForEvent() -> String {
|
|
||||||
let message: String
|
|
||||||
|
|
||||||
if type == .Event {
|
|
||||||
if nsp == "/" {
|
|
||||||
if id == -1 {
|
|
||||||
message = "2"
|
|
||||||
} else {
|
|
||||||
message = "2\(id)"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if id == -1 {
|
|
||||||
message = "2\(nsp),"
|
|
||||||
} else {
|
|
||||||
message = "2\(nsp),\(id)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if nsp == "/" {
|
|
||||||
if id == -1 {
|
|
||||||
message = "5\(binary.count)-"
|
|
||||||
} else {
|
|
||||||
message = "5\(binary.count)-\(id)"
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if id == -1 {
|
|
||||||
message = "5\(binary.count)-\(nsp),"
|
|
||||||
} else {
|
|
||||||
message = "5\(binary.count)-\(nsp),\(id)"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return completeMessage(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func createPacketString() -> String {
|
private func createPacketString() -> String {
|
||||||
let str: String
|
let typeString = String(type.rawValue)
|
||||||
|
let binaryCountString: String
|
||||||
|
let nspString: String
|
||||||
|
let idString: String
|
||||||
|
|
||||||
if type == .Event || type == .BinaryEvent {
|
if type == .BinaryEvent || type == .BinaryAck {
|
||||||
str = createMessageForEvent()
|
binaryCountString = typeString + String(binary.count) + "-"
|
||||||
} else {
|
} else {
|
||||||
str = createAck()
|
binaryCountString = typeString
|
||||||
}
|
}
|
||||||
|
|
||||||
return str
|
if nsp != "/" {
|
||||||
|
nspString = binaryCountString + nsp + ","
|
||||||
|
} else {
|
||||||
|
nspString = binaryCountString
|
||||||
|
}
|
||||||
|
|
||||||
|
if id != -1 {
|
||||||
|
idString = nspString + String(id)
|
||||||
|
} else {
|
||||||
|
idString = nspString
|
||||||
|
}
|
||||||
|
|
||||||
|
return completeMessage(idString)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when we have all the binary data for a packet
|
// Called when we have all the binary data for a packet
|
||||||
|
|||||||
@ -96,14 +96,14 @@ extension SocketParsable {
|
|||||||
|
|
||||||
if type == .Error {
|
if type == .Error {
|
||||||
parser.advance(by: -1)
|
parser.advance(by: -1)
|
||||||
}
|
} else {
|
||||||
|
while parser.hasNext {
|
||||||
while parser.hasNext && type != .Error {
|
if let int = Int(parser.read(length: 1)) {
|
||||||
if let int = Int(parser.read(length: 1)) {
|
idString += String(int)
|
||||||
idString += String(int)
|
} else {
|
||||||
} else {
|
parser.advance(by: -2)
|
||||||
parser.advance(by: -2)
|
break
|
||||||
break
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,9 +161,7 @@ extension SocketParsable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Should execute event?
|
// Should execute event?
|
||||||
guard waitingPackets[waitingPackets.count - 1].addData(data) else {
|
guard waitingPackets[waitingPackets.count - 1].addData(data) else { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let packet = waitingPackets.removeLast()
|
let packet = waitingPackets.removeLast()
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user