commit
c237197b8c
@ -77,7 +77,7 @@ import PackageDescription
|
|||||||
let package = Package(
|
let package = Package(
|
||||||
name: "YourSocketIOProject",
|
name: "YourSocketIOProject",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 5)
|
.Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 6)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
@ -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.0 # Or latest version
|
github "socketio/socket.io-client-swift" ~> 6.1.1 # 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.0' # Or latest version
|
pod 'Socket.IO-Client-Swift', '~> 6.1.1' # 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.0", :files => "Source/*.swift" # Or latest version
|
github "socketio/socket.io-client-swift", "v6.1.1", :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.0"
|
s.version = "6.1.1"
|
||||||
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.0' }
|
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.1' }
|
||||||
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
|
||||||
|
|||||||
@ -119,15 +119,21 @@
|
|||||||
742D150C1CA5794B00BD987D /* SocketObjectiveCTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 742D150B1CA5794B00BD987D /* SocketObjectiveCTest.m */; };
|
742D150C1CA5794B00BD987D /* SocketObjectiveCTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 742D150B1CA5794B00BD987D /* SocketObjectiveCTest.m */; };
|
||||||
74321DCB1C2D939A00CF6F43 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74321DC91C2D939A00CF6F43 /* SocketAckManagerTest.swift */; };
|
74321DCB1C2D939A00CF6F43 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74321DC91C2D939A00CF6F43 /* SocketAckManagerTest.swift */; };
|
||||||
74321DCC1C2D939A00CF6F43 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */; };
|
74321DCC1C2D939A00CF6F43 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */; };
|
||||||
7471CCEA1C39926300364B59 /* SocketClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketClientSpec.swift */; };
|
7471CCEA1C39926300364B59 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */; };
|
||||||
7471CCEB1C39926C00364B59 /* SocketClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketClientSpec.swift */; };
|
7471CCEB1C39926C00364B59 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */; };
|
||||||
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
|
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
|
||||||
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
|
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
|
||||||
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
||||||
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
||||||
74ABF7771C3991C10078C657 /* SocketClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketClientSpec.swift */; };
|
74ABF7771C3991C10078C657 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */; };
|
||||||
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
||||||
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
|
||||||
|
CEBA56961CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; };
|
||||||
|
CEBA56971CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; };
|
||||||
|
CEBA56981CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; };
|
||||||
|
CEBA569A1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; };
|
||||||
|
CEBA569B1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; };
|
||||||
|
CEBA569C1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -193,8 +199,10 @@
|
|||||||
74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketParserTest.swift; sourceTree = "<group>"; };
|
74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketParserTest.swift; sourceTree = "<group>"; };
|
||||||
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespacePacketTest.swift; sourceTree = "<group>"; };
|
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespacePacketTest.swift; sourceTree = "<group>"; };
|
||||||
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketSideEffectTest.swift; sourceTree = "<group>"; };
|
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketSideEffectTest.swift; sourceTree = "<group>"; };
|
||||||
74ABF7761C3991C10078C657 /* SocketClientSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketClientSpec.swift; path = Source/SocketClientSpec.swift; sourceTree = "<group>"; };
|
74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientSpec.swift; path = Source/SocketIOClientSpec.swift; sourceTree = "<group>"; };
|
||||||
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = "<group>"; };
|
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = "<group>"; };
|
||||||
|
CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NSCharacterSet.swift; path = Source/NSCharacterSet.swift; sourceTree = "<group>"; };
|
||||||
|
CEBA56991CDA0B8200BA0389 /* String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = String.swift; path = Source/String.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -347,10 +355,10 @@
|
|||||||
5764DF7B1B51F24A004FF46E /* Source */ = {
|
5764DF7B1B51F24A004FF46E /* Source */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
CEBA569E1CDA0C0C00BA0389 /* utils */,
|
||||||
74171E501C10CD240062D398 /* SocketAckEmitter.swift */,
|
74171E501C10CD240062D398 /* SocketAckEmitter.swift */,
|
||||||
74171E511C10CD240062D398 /* SocketAckManager.swift */,
|
74171E511C10CD240062D398 /* SocketAckManager.swift */,
|
||||||
74171E521C10CD240062D398 /* SocketAnyEvent.swift */,
|
74171E521C10CD240062D398 /* SocketAnyEvent.swift */,
|
||||||
74ABF7761C3991C10078C657 /* SocketClientSpec.swift */,
|
|
||||||
74171E531C10CD240062D398 /* SocketEngine.swift */,
|
74171E531C10CD240062D398 /* SocketEngine.swift */,
|
||||||
74171E541C10CD240062D398 /* SocketEngineClient.swift */,
|
74171E541C10CD240062D398 /* SocketEngineClient.swift */,
|
||||||
74171E551C10CD240062D398 /* SocketEnginePacketType.swift */,
|
74171E551C10CD240062D398 /* SocketEnginePacketType.swift */,
|
||||||
@ -360,6 +368,7 @@
|
|||||||
74171E571C10CD240062D398 /* SocketEventHandler.swift */,
|
74171E571C10CD240062D398 /* SocketEventHandler.swift */,
|
||||||
74171E591C10CD240062D398 /* SocketIOClient.swift */,
|
74171E591C10CD240062D398 /* SocketIOClient.swift */,
|
||||||
74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */,
|
74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */,
|
||||||
|
74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */,
|
||||||
74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */,
|
74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */,
|
||||||
74171E5C1C10CD240062D398 /* SocketLogger.swift */,
|
74171E5C1C10CD240062D398 /* SocketLogger.swift */,
|
||||||
74171E5D1C10CD240062D398 /* SocketPacket.swift */,
|
74171E5D1C10CD240062D398 /* SocketPacket.swift */,
|
||||||
@ -372,6 +381,15 @@
|
|||||||
name = Source;
|
name = Source;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
CEBA569E1CDA0C0C00BA0389 /* utils */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */,
|
||||||
|
CEBA56991CDA0B8200BA0389 /* String.swift */,
|
||||||
|
);
|
||||||
|
name = utils;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
/* End PBXGroup section */
|
/* End PBXGroup section */
|
||||||
|
|
||||||
/* Begin PBXHeadersBuildPhase section */
|
/* Begin PBXHeadersBuildPhase section */
|
||||||
@ -607,10 +625,12 @@
|
|||||||
files = (
|
files = (
|
||||||
740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
||||||
74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||||
|
CEBA569A1CDA0B8200BA0389 /* String.swift in Sources */,
|
||||||
74171E751C10CD240062D398 /* SocketEngine.swift in Sources */,
|
74171E751C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||||
74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||||
7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
||||||
74ABF7771C3991C10078C657 /* SocketClientSpec.swift in Sources */,
|
CEBA56961CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */,
|
||||||
|
74ABF7771C3991C10078C657 /* SocketIOClientSpec.swift in Sources */,
|
||||||
74171E871C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
74171E871C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||||
74171E631C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
74171E631C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||||
74171EBD1C10CD240062D398 /* SocketStringReader.swift in Sources */,
|
74171EBD1C10CD240062D398 /* SocketStringReader.swift in Sources */,
|
||||||
@ -663,10 +683,12 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
||||||
7471CCEA1C39926300364B59 /* SocketClientSpec.swift in Sources */,
|
7471CCEA1C39926300364B59 /* SocketIOClientSpec.swift in Sources */,
|
||||||
|
CEBA569B1CDA0B8200BA0389 /* String.swift in Sources */,
|
||||||
74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||||
74171E771C10CD240062D398 /* SocketEngine.swift in Sources */,
|
74171E771C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||||
7420CB7A1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
7420CB7A1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
||||||
|
CEBA56971CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */,
|
||||||
74171E6B1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
74171E6B1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||||
74171E891C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
74171E891C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||||
74171E651C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
74171E651C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||||
@ -706,10 +728,12 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */,
|
||||||
7471CCEB1C39926C00364B59 /* SocketClientSpec.swift in Sources */,
|
7471CCEB1C39926C00364B59 /* SocketIOClientSpec.swift in Sources */,
|
||||||
|
CEBA569C1CDA0B8200BA0389 /* String.swift in Sources */,
|
||||||
74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
|
||||||
74171E791C10CD240062D398 /* SocketEngine.swift in Sources */,
|
74171E791C10CD240062D398 /* SocketEngine.swift in Sources */,
|
||||||
7420CB7B1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
7420CB7B1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
|
||||||
|
CEBA56981CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */,
|
||||||
74171E6D1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
74171E6D1C10CD240062D398 /* SocketAckManager.swift in Sources */,
|
||||||
74171E8B1C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
74171E8B1C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
|
||||||
74171E671C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
74171E671C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
|
||||||
|
|||||||
@ -86,4 +86,20 @@ class SocketEngineTest: XCTestCase {
|
|||||||
engine.parsePollingMessage("41:42[\"stringTest\",\"lïne one\\nlīne \\rtwo\"]")
|
engine.parsePollingMessage("41:42[\"stringTest\",\"lïne one\\nlīne \\rtwo\"]")
|
||||||
waitForExpectationsWithTimeout(3, handler: nil)
|
waitForExpectationsWithTimeout(3, handler: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testEncodeURLProperly() {
|
||||||
|
engine.connectParams = [
|
||||||
|
"created": "2016-05-04T18:31:15+0200"
|
||||||
|
]
|
||||||
|
|
||||||
|
XCTAssertEqual(engine.urlPolling.query, "transport=polling&b64=1&created=2016-05-04T18%3A31%3A15%2B0200")
|
||||||
|
XCTAssertEqual(engine.urlWebSocket.query, "transport=websocket&created=2016-05-04T18%3A31%3A15%2B0200")
|
||||||
|
|
||||||
|
engine.connectParams = [
|
||||||
|
"forbidden": "!*'();:@&=+$,/?%#[]\" {}"
|
||||||
|
]
|
||||||
|
|
||||||
|
XCTAssertEqual(engine.urlPolling.query, "transport=polling&b64=1&forbidden=%21%2A%27%28%29%3B%3A%40%26%3D%2B%24%2C%2F%3F%25%23%5B%5D%22%20%7B%7D")
|
||||||
|
XCTAssertEqual(engine.urlWebSocket.query, "transport=websocket&forbidden=%21%2A%27%28%29%3B%3A%40%26%3D%2B%24%2C%2F%3F%25%23%5B%5D%22%20%7B%7D")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void)testEmitWithAckSyntax {
|
- (void)testEmitWithAckSyntax {
|
||||||
[self.socket emitWithAck:@"testAckEmit" withItems:@[@YES]];
|
[self.socket emitWithAck:@"testAckEmit" withItems:@[@YES]](0, ^(NSArray* data) {
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testOffSyntax {
|
- (void)testOffSyntax {
|
||||||
|
|||||||
31
Source/NSCharacterSet.swift
Normal file
31
Source/NSCharacterSet.swift
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// NSCharacterSet.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Yannick Loriot on 5/4/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.
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
extension NSCharacterSet {
|
||||||
|
class var allowedURLCharacterSet: NSCharacterSet {
|
||||||
|
return NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -34,6 +34,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
(urlPolling, urlWebSocket) = createURLs()
|
(urlPolling, urlWebSocket) = createURLs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public var postWait = [String]()
|
public var postWait = [String]()
|
||||||
public var waitingForPoll = false
|
public var waitingForPoll = false
|
||||||
public var waitingForPost = false
|
public var waitingForPost = false
|
||||||
@ -133,23 +134,16 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
allowLossyConversion: false) else { return }
|
allowLossyConversion: false) else { return }
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if let dict = try NSJSONSerialization.JSONObjectWithData(stringData,
|
if let dict = try NSJSONSerialization.JSONObjectWithData(stringData, options: .MutableContainers) as? NSDictionary {
|
||||||
options: NSJSONReadingOptions.MutableContainers) as? NSDictionary {
|
|
||||||
guard let code = dict["code"] as? Int else { return }
|
|
||||||
guard let error = dict["message"] as? String else { return }
|
guard let error = dict["message"] as? String else { return }
|
||||||
|
|
||||||
switch code {
|
/*
|
||||||
case 0: // Unknown transport
|
0: Unknown transport
|
||||||
|
1: Unknown sid
|
||||||
|
2: Bad handshake request
|
||||||
|
3: Bad request
|
||||||
|
*/
|
||||||
didError(error)
|
didError(error)
|
||||||
case 1: // Unknown sid.
|
|
||||||
didError(error)
|
|
||||||
case 2: // Bad handshake request
|
|
||||||
didError(error)
|
|
||||||
case 3: // Bad request
|
|
||||||
didError(error)
|
|
||||||
default:
|
|
||||||
didError(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
didError("Got unknown error from server \(msg)")
|
didError("Got unknown error from server \(msg)")
|
||||||
@ -204,7 +198,9 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doLongPoll(reqPolling)
|
dispatch_async(emitQueue) {
|
||||||
|
self.doLongPoll(reqPolling)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createURLs() -> (NSURL, NSURL) {
|
private func createURLs() -> (NSURL, NSURL) {
|
||||||
@ -218,8 +214,6 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
|
|
||||||
urlWebSocket.path = socketPath
|
urlWebSocket.path = socketPath
|
||||||
urlPolling.path = socketPath
|
urlPolling.path = socketPath
|
||||||
urlWebSocket.query = "transport=websocket"
|
|
||||||
urlPolling.query = "transport=polling&b64=1"
|
|
||||||
|
|
||||||
if secure {
|
if secure {
|
||||||
urlPolling.scheme = "https"
|
urlPolling.scheme = "https"
|
||||||
@ -231,12 +225,15 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
|
|
||||||
if connectParams != nil {
|
if connectParams != nil {
|
||||||
for (key, value) in connectParams! {
|
for (key, value) in connectParams! {
|
||||||
queryString += "&\(key)=\(value)"
|
let keyEsc = key.urlEncode()!
|
||||||
|
let valueEsc = "\(value)".urlEncode()!
|
||||||
|
|
||||||
|
queryString += "&\(keyEsc)=\(valueEsc)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
urlWebSocket.query = urlWebSocket.query! + queryString
|
urlWebSocket.percentEncodedQuery = "transport=websocket" + queryString
|
||||||
urlPolling.query = urlPolling.query! + queryString
|
urlPolling.percentEncodedQuery = "transport=polling&b64=1" + queryString
|
||||||
|
|
||||||
return (urlPolling.URL!, urlWebSocket.URL!)
|
return (urlPolling.URL!, urlWebSocket.URL!)
|
||||||
}
|
}
|
||||||
@ -286,7 +283,8 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
DefaultSocketLogger.Logger.log("Engine is being closed.", type: logType)
|
DefaultSocketLogger.Logger.log("Engine is being closed.", type: logType)
|
||||||
|
|
||||||
if closed {
|
if closed {
|
||||||
return postSendClose(nil, nil, nil)
|
client?.engineDidClose(reason)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if websocket {
|
if websocket {
|
||||||
@ -393,7 +391,6 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
|
|||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
didError("Error parsing open packet")
|
didError("Error parsing open packet")
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -181,9 +181,7 @@ extension SocketEnginePollable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func parsePollingMessage(str: String) {
|
func parsePollingMessage(str: String) {
|
||||||
guard str.characters.count != 1 else {
|
guard str.characters.count != 1 else { return }
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var reader = SocketStringReader(message: str)
|
var reader = SocketStringReader(message: str)
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,7 @@ import Foundation
|
|||||||
var urlPolling: NSURL { get }
|
var urlPolling: NSURL { get }
|
||||||
var urlWebSocket: NSURL { get }
|
var urlWebSocket: NSURL { get }
|
||||||
var websocket: Bool { get }
|
var websocket: Bool { get }
|
||||||
|
var ws: WebSocket? { get }
|
||||||
|
|
||||||
init(client: SocketEngineClient, url: NSURL, options: NSDictionary?)
|
init(client: SocketEngineClient, url: NSURL, options: NSDictionary?)
|
||||||
|
|
||||||
@ -62,14 +63,14 @@ import Foundation
|
|||||||
extension SocketEngineSpec {
|
extension SocketEngineSpec {
|
||||||
var urlPollingWithSid: NSURL {
|
var urlPollingWithSid: NSURL {
|
||||||
let com = NSURLComponents(URL: urlPolling, resolvingAgainstBaseURL: false)!
|
let com = NSURLComponents(URL: urlPolling, resolvingAgainstBaseURL: false)!
|
||||||
com.query = com.query! + "&sid=\(sid)"
|
com.percentEncodedQuery = com.percentEncodedQuery! + "&sid=\(sid.urlEncode()!)"
|
||||||
|
|
||||||
return com.URL!
|
return com.URL!
|
||||||
}
|
}
|
||||||
|
|
||||||
var urlWebSocketWithSid: NSURL {
|
var urlWebSocketWithSid: NSURL {
|
||||||
let com = NSURLComponents(URL: urlWebSocket, resolvingAgainstBaseURL: false)!
|
let com = NSURLComponents(URL: urlWebSocket, resolvingAgainstBaseURL: false)!
|
||||||
com.query = com.query! + (sid == "" ? "" : "&sid=\(sid)")
|
com.percentEncodedQuery = com.percentEncodedQuery! + (sid == "" ? "" : "&sid=\(sid.urlEncode()!)")
|
||||||
|
|
||||||
return com.URL!
|
return com.URL!
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,8 +27,6 @@ import Foundation
|
|||||||
|
|
||||||
/// Protocol that is used to implement socket.io WebSocket support
|
/// Protocol that is used to implement socket.io WebSocket support
|
||||||
public protocol SocketEngineWebsocket : SocketEngineSpec, WebSocketDelegate {
|
public protocol SocketEngineWebsocket : SocketEngineSpec, WebSocketDelegate {
|
||||||
var ws: WebSocket? { get }
|
|
||||||
|
|
||||||
func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType, withData datas: [NSData])
|
func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType, withData datas: [NSData])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -131,8 +131,7 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
|||||||
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
|
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
|
||||||
|
|
||||||
guard status != .Connected else {
|
guard status != .Connected else {
|
||||||
DefaultSocketLogger.Logger.log("Tried connecting on an already connected socket",
|
DefaultSocketLogger.Logger.log("Tried connecting on an already connected socket", type: logType)
|
||||||
type: logType)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,8 +148,8 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
|||||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
|
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
|
||||||
|
|
||||||
dispatch_after(time, handleQueue) {[weak self] in
|
dispatch_after(time, handleQueue) {[weak self] in
|
||||||
if let this = self where this.status != .Connected && this.status != .Closed {
|
if let this = self where this.status != .Connected && this.status != .Disconnected {
|
||||||
this.status = .Closed
|
this.status = .Disconnected
|
||||||
this.engine?.disconnect("Connect timeout")
|
this.engine?.disconnect("Connect timeout")
|
||||||
|
|
||||||
handler?()
|
handler?()
|
||||||
@ -187,11 +186,11 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
|||||||
}
|
}
|
||||||
|
|
||||||
func didDisconnect(reason: String) {
|
func didDisconnect(reason: String) {
|
||||||
guard status != .Closed else { return }
|
guard status != .Disconnected else { return }
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Disconnected: %@", type: logType, args: reason)
|
DefaultSocketLogger.Logger.log("Disconnected: %@", type: logType, args: reason)
|
||||||
|
|
||||||
status = .Closed
|
status = .Disconnected
|
||||||
reconnects = false
|
reconnects = false
|
||||||
|
|
||||||
// Make sure the engine is actually dead.
|
// Make sure the engine is actually dead.
|
||||||
@ -202,6 +201,8 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
|||||||
/// Disconnects the socket. Only reconnect the same socket if you know what you're doing.
|
/// Disconnects the socket. Only reconnect the same socket if you know what you're doing.
|
||||||
/// Will turn off automatic reconnects.
|
/// Will turn off automatic reconnects.
|
||||||
public func disconnect() {
|
public func disconnect() {
|
||||||
|
assert(status != .NotConnected, "Tried closing a NotConnected client")
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Closing socket", type: logType)
|
DefaultSocketLogger.Logger.log("Closing socket", type: logType)
|
||||||
|
|
||||||
reconnects = false
|
reconnects = false
|
||||||
@ -267,11 +268,11 @@ public final class SocketIOClient : NSObject, SocketEngineClient, SocketParsable
|
|||||||
public func engineDidClose(reason: String) {
|
public func engineDidClose(reason: String) {
|
||||||
waitingPackets.removeAll()
|
waitingPackets.removeAll()
|
||||||
|
|
||||||
if status != .Closed {
|
if status != .Disconnected {
|
||||||
status = .NotConnected
|
status = .NotConnected
|
||||||
}
|
}
|
||||||
|
|
||||||
if status == .Closed || !reconnects {
|
if status == .Disconnected || !reconnects {
|
||||||
didDisconnect(reason)
|
didDisconnect(reason)
|
||||||
} else if !reconnecting {
|
} else if !reconnecting {
|
||||||
reconnecting = true
|
reconnecting = true
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SocketClientSpec.swift
|
// SocketIOClientSpec.swift
|
||||||
// Socket.IO-Client-Swift
|
// Socket.IO-Client-Swift
|
||||||
//
|
//
|
||||||
// Created by Erik Little on 1/3/16.
|
// Created by Erik Little on 1/3/16.
|
||||||
@ -22,7 +22,7 @@
|
|||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
|
||||||
protocol SocketClientSpec : class {
|
protocol SocketIOClientSpec : class {
|
||||||
var nsp: String { get set }
|
var nsp: String { get set }
|
||||||
var waitingPackets: [SocketPacket] { get set }
|
var waitingPackets: [SocketPacket] { get set }
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ protocol SocketClientSpec : class {
|
|||||||
func joinNamespace(namespace: String)
|
func joinNamespace(namespace: String)
|
||||||
}
|
}
|
||||||
|
|
||||||
extension SocketClientSpec {
|
extension SocketIOClientSpec {
|
||||||
func didError(reason: String) {
|
func didError(reason: String) {
|
||||||
DefaultSocketLogger.Logger.error("%@", type: "SocketIOClient", args: reason)
|
DefaultSocketLogger.Logger.error("%@", type: "SocketIOClient", args: reason)
|
||||||
|
|
||||||
@ -24,19 +24,9 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@objc public enum SocketIOClientStatus : Int, CustomStringConvertible {
|
/// **NotConnected**: initial state
|
||||||
case NotConnected, Closed, Connecting, Connected
|
///
|
||||||
|
/// **Disconnected**: connected before
|
||||||
public var description: String {
|
@objc public enum SocketIOClientStatus : Int {
|
||||||
switch self {
|
case NotConnected, Disconnected, Connecting, Connected
|
||||||
case NotConnected:
|
|
||||||
return "Not Connected"
|
|
||||||
case Closed:
|
|
||||||
return "Closed"
|
|
||||||
case Connecting:
|
|
||||||
return "Connecting"
|
|
||||||
case Connected:
|
|
||||||
return "Connected"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -26,7 +26,7 @@ import Foundation
|
|||||||
|
|
||||||
public protocol SocketLogger : class {
|
public protocol SocketLogger : class {
|
||||||
/// Whether to log or not
|
/// Whether to log or not
|
||||||
var log: Bool {get set}
|
var log: Bool { get set }
|
||||||
|
|
||||||
/// Normal log messages
|
/// Normal log messages
|
||||||
func log(message: String, type: String, args: AnyObject...)
|
func log(message: String, type: String, args: AnyObject...)
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
protocol SocketParsable : SocketClientSpec {
|
protocol SocketParsable : SocketIOClientSpec {
|
||||||
func parseBinaryData(data: NSData)
|
func parseBinaryData(data: NSData)
|
||||||
func parseSocketMessage(message: String)
|
func parseSocketMessage(message: String)
|
||||||
}
|
}
|
||||||
@ -45,8 +45,7 @@ extension SocketParsable {
|
|||||||
private func handlePacket(pack: SocketPacket) {
|
private func handlePacket(pack: SocketPacket) {
|
||||||
switch pack.type {
|
switch pack.type {
|
||||||
case .Event where isCorrectNamespace(pack.nsp):
|
case .Event where isCorrectNamespace(pack.nsp):
|
||||||
handleEvent(pack.event, data: pack.args,
|
handleEvent(pack.event, data: pack.args, isInternalMessage: false, withAck: pack.id)
|
||||||
isInternalMessage: false, withAck: pack.id)
|
|
||||||
case .Ack where isCorrectNamespace(pack.nsp):
|
case .Ack where isCorrectNamespace(pack.nsp):
|
||||||
handleAck(pack.id, data: pack.data)
|
handleAck(pack.id, data: pack.data)
|
||||||
case .BinaryEvent where isCorrectNamespace(pack.nsp):
|
case .BinaryEvent where isCorrectNamespace(pack.nsp):
|
||||||
|
|||||||
31
Source/String.swift
Normal file
31
Source/String.swift
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// String.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Yannick Loriot on 5/4/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.
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
extension String {
|
||||||
|
func urlEncode() -> String? {
|
||||||
|
return stringByAddingPercentEncodingWithAllowedCharacters(.allowedURLCharacterSet)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user