Skip to content

Commit c237197

Browse files
committed
Merge pull request socketio#362 from socketio/development
Development
2 parents 1b4b571 + 4ea3f40 commit c237197

16 files changed

+167
-79
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import PackageDescription
7777
let package = Package(
7878
name: "YourSocketIOProject",
7979
dependencies: [
80-
.Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 5)
80+
.Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 6)
8181
]
8282
)
8383
```
@@ -88,7 +88,7 @@ Carthage
8888
-----------------
8989
Add this line to your `Cartfile`:
9090
```
91-
github "socketio/socket.io-client-swift" ~> 6.1.0 # Or latest version
91+
github "socketio/socket.io-client-swift" ~> 6.1.1 # Or latest version
9292
```
9393

9494
Run `carthage update --platform ios,macosx`.
@@ -102,7 +102,7 @@ source 'https://github.com/CocoaPods/Specs.git'
102102
platform :ios, '8.0'
103103
use_frameworks!
104104

105-
pod 'Socket.IO-Client-Swift', '~> 6.1.0' # Or latest version
105+
pod 'Socket.IO-Client-Swift', '~> 6.1.1' # Or latest version
106106
```
107107

108108
Install pods:
@@ -130,7 +130,7 @@ CocoaSeeds
130130
Add this line to your `Seedfile`:
131131

132132
```
133-
github "socketio/socket.io-client-swift", "v6.1.0", :files => "Source/*.swift" # Or latest version
133+
github "socketio/socket.io-client-swift", "v6.1.1", :files => "Source/*.swift" # Or latest version
134134
```
135135

136136
Run `seed install`.

Socket.IO-Client-Swift.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Pod::Spec.new do |s|
22
s.name = "Socket.IO-Client-Swift"
33
s.module_name = "SocketIOClientSwift"
4-
s.version = "6.1.0"
4+
s.version = "6.1.1"
55
s.summary = "Socket.IO-client for iOS and OS X"
66
s.description = <<-DESC
77
Socket.IO-client for iOS and OS X.
@@ -14,7 +14,7 @@ Pod::Spec.new do |s|
1414
s.ios.deployment_target = '8.0'
1515
s.osx.deployment_target = '10.10'
1616
s.tvos.deployment_target = '9.0'
17-
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.0' }
17+
s.source = { :git => "https://github.com/socketio/socket.io-client-swift.git", :tag => 'v6.1.1' }
1818
s.source_files = "Source/**/*.swift"
1919
s.requires_arc = true
2020
# s.dependency 'Starscream', '~> 0.9' # currently this repo includes Starscream swift files

Socket.IO-Client-Swift.xcodeproj/project.pbxproj

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,21 @@
119119
742D150C1CA5794B00BD987D /* SocketObjectiveCTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 742D150B1CA5794B00BD987D /* SocketObjectiveCTest.m */; };
120120
74321DCB1C2D939A00CF6F43 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74321DC91C2D939A00CF6F43 /* SocketAckManagerTest.swift */; };
121121
74321DCC1C2D939A00CF6F43 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */; };
122-
7471CCEA1C39926300364B59 /* SocketClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketClientSpec.swift */; };
123-
7471CCEB1C39926C00364B59 /* SocketClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketClientSpec.swift */; };
122+
7471CCEA1C39926300364B59 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */; };
123+
7471CCEB1C39926C00364B59 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */; };
124124
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
125125
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; };
126126
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
127127
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
128-
74ABF7771C3991C10078C657 /* SocketClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketClientSpec.swift */; };
128+
74ABF7771C3991C10078C657 /* SocketIOClientSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */; };
129129
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
130130
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; };
131+
CEBA56961CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; };
132+
CEBA56971CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; };
133+
CEBA56981CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */; };
134+
CEBA569A1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; };
135+
CEBA569B1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; };
136+
CEBA569C1CDA0B8200BA0389 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = CEBA56991CDA0B8200BA0389 /* String.swift */; };
131137
/* End PBXBuildFile section */
132138

133139
/* Begin PBXContainerItemProxy section */
@@ -193,8 +199,10 @@
193199
74321DCA1C2D939A00CF6F43 /* SocketParserTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketParserTest.swift; sourceTree = "<group>"; };
194200
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespacePacketTest.swift; sourceTree = "<group>"; };
195201
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketSideEffectTest.swift; sourceTree = "<group>"; };
196-
74ABF7761C3991C10078C657 /* SocketClientSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketClientSpec.swift; path = Source/SocketClientSpec.swift; sourceTree = "<group>"; };
202+
74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientSpec.swift; path = Source/SocketIOClientSpec.swift; sourceTree = "<group>"; };
197203
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = "<group>"; };
204+
CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NSCharacterSet.swift; path = Source/NSCharacterSet.swift; sourceTree = "<group>"; };
205+
CEBA56991CDA0B8200BA0389 /* String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = String.swift; path = Source/String.swift; sourceTree = "<group>"; };
198206
/* End PBXFileReference section */
199207

200208
/* Begin PBXFrameworksBuildPhase section */
@@ -347,10 +355,10 @@
347355
5764DF7B1B51F24A004FF46E /* Source */ = {
348356
isa = PBXGroup;
349357
children = (
358+
CEBA569E1CDA0C0C00BA0389 /* utils */,
350359
74171E501C10CD240062D398 /* SocketAckEmitter.swift */,
351360
74171E511C10CD240062D398 /* SocketAckManager.swift */,
352361
74171E521C10CD240062D398 /* SocketAnyEvent.swift */,
353-
74ABF7761C3991C10078C657 /* SocketClientSpec.swift */,
354362
74171E531C10CD240062D398 /* SocketEngine.swift */,
355363
74171E541C10CD240062D398 /* SocketEngineClient.swift */,
356364
74171E551C10CD240062D398 /* SocketEnginePacketType.swift */,
@@ -360,6 +368,7 @@
360368
74171E571C10CD240062D398 /* SocketEventHandler.swift */,
361369
74171E591C10CD240062D398 /* SocketIOClient.swift */,
362370
74171E5A1C10CD240062D398 /* SocketIOClientOption.swift */,
371+
74ABF7761C3991C10078C657 /* SocketIOClientSpec.swift */,
363372
74171E5B1C10CD240062D398 /* SocketIOClientStatus.swift */,
364373
74171E5C1C10CD240062D398 /* SocketLogger.swift */,
365374
74171E5D1C10CD240062D398 /* SocketPacket.swift */,
@@ -372,6 +381,15 @@
372381
name = Source;
373382
sourceTree = "<group>";
374383
};
384+
CEBA569E1CDA0C0C00BA0389 /* utils */ = {
385+
isa = PBXGroup;
386+
children = (
387+
CEBA56951CDA0B7700BA0389 /* NSCharacterSet.swift */,
388+
CEBA56991CDA0B8200BA0389 /* String.swift */,
389+
);
390+
name = utils;
391+
sourceTree = "<group>";
392+
};
375393
/* End PBXGroup section */
376394

377395
/* Begin PBXHeadersBuildPhase section */
@@ -607,10 +625,12 @@
607625
files = (
608626
740CA1221C496EF700CB98F4 /* SocketEngineWebsocket.swift in Sources */,
609627
74171EA51C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
628+
CEBA569A1CDA0B8200BA0389 /* String.swift in Sources */,
610629
74171E751C10CD240062D398 /* SocketEngine.swift in Sources */,
611630
74171E691C10CD240062D398 /* SocketAckManager.swift in Sources */,
612631
7420CB791C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
613-
74ABF7771C3991C10078C657 /* SocketClientSpec.swift in Sources */,
632+
CEBA56961CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */,
633+
74ABF7771C3991C10078C657 /* SocketIOClientSpec.swift in Sources */,
614634
74171E871C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
615635
74171E631C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
616636
74171EBD1C10CD240062D398 /* SocketStringReader.swift in Sources */,
@@ -663,10 +683,12 @@
663683
buildActionMask = 2147483647;
664684
files = (
665685
740CA1211C496EF200CB98F4 /* SocketEngineWebsocket.swift in Sources */,
666-
7471CCEA1C39926300364B59 /* SocketClientSpec.swift in Sources */,
686+
7471CCEA1C39926300364B59 /* SocketIOClientSpec.swift in Sources */,
687+
CEBA569B1CDA0B8200BA0389 /* String.swift in Sources */,
667688
74171EA71C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
668689
74171E771C10CD240062D398 /* SocketEngine.swift in Sources */,
669690
7420CB7A1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
691+
CEBA56971CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */,
670692
74171E6B1C10CD240062D398 /* SocketAckManager.swift in Sources */,
671693
74171E891C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
672694
74171E651C10CD240062D398 /* SocketAckEmitter.swift in Sources */,
@@ -706,10 +728,12 @@
706728
buildActionMask = 2147483647;
707729
files = (
708730
740CA1201C496EEB00CB98F4 /* SocketEngineWebsocket.swift in Sources */,
709-
7471CCEB1C39926C00364B59 /* SocketClientSpec.swift in Sources */,
731+
7471CCEB1C39926C00364B59 /* SocketIOClientSpec.swift in Sources */,
732+
CEBA569C1CDA0B8200BA0389 /* String.swift in Sources */,
710733
74171EA91C10CD240062D398 /* SocketIOClientStatus.swift in Sources */,
711734
74171E791C10CD240062D398 /* SocketEngine.swift in Sources */,
712735
7420CB7B1C49629E00956AA4 /* SocketEnginePollable.swift in Sources */,
736+
CEBA56981CDA0B7700BA0389 /* NSCharacterSet.swift in Sources */,
713737
74171E6D1C10CD240062D398 /* SocketAckManager.swift in Sources */,
714738
74171E8B1C10CD240062D398 /* SocketEngineSpec.swift in Sources */,
715739
74171E671C10CD240062D398 /* SocketAckEmitter.swift in Sources */,

SocketIO-MacTests/SocketEngineTest.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,20 @@ class SocketEngineTest: XCTestCase {
8686
engine.parsePollingMessage("41:42[\"stringTest\",\"lïne one\\nlīne \\rtwo\"]")
8787
waitForExpectationsWithTimeout(3, handler: nil)
8888
}
89+
90+
func testEncodeURLProperly() {
91+
engine.connectParams = [
92+
"created": "2016-05-04T18:31:15+0200"
93+
]
94+
95+
XCTAssertEqual(engine.urlPolling.query, "transport=polling&b64=1&created=2016-05-04T18%3A31%3A15%2B0200")
96+
XCTAssertEqual(engine.urlWebSocket.query, "transport=websocket&created=2016-05-04T18%3A31%3A15%2B0200")
97+
98+
engine.connectParams = [
99+
"forbidden": "!*'();:@&=+$,/?%#[]\" {}"
100+
]
101+
102+
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")
103+
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")
104+
}
89105
}

SocketIO-MacTests/SocketObjectiveCTest.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ - (void)testEmitSyntax {
3535
}
3636

3737
- (void)testEmitWithAckSyntax {
38-
[self.socket emitWithAck:@"testAckEmit" withItems:@[@YES]];
38+
[self.socket emitWithAck:@"testAckEmit" withItems:@[@YES]](0, ^(NSArray* data) {
39+
40+
});
3941
}
4042

4143
- (void)testOffSyntax {

Source/NSCharacterSet.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//
2+
// NSCharacterSet.swift
3+
// Socket.IO-Client-Swift
4+
//
5+
// Created by Yannick Loriot on 5/4/16.
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be included in
15+
// all copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+
// THE SOFTWARE.
24+
25+
import Foundation
26+
27+
extension NSCharacterSet {
28+
class var allowedURLCharacterSet: NSCharacterSet {
29+
return NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
30+
}
31+
}

Source/SocketEngine.swift

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
3434
(urlPolling, urlWebSocket) = createURLs()
3535
}
3636
}
37+
3738
public var postWait = [String]()
3839
public var waitingForPoll = false
3940
public var waitingForPost = false
@@ -133,23 +134,16 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
133134
allowLossyConversion: false) else { return }
134135

135136
do {
136-
if let dict = try NSJSONSerialization.JSONObjectWithData(stringData,
137-
options: NSJSONReadingOptions.MutableContainers) as? NSDictionary {
138-
guard let code = dict["code"] as? Int else { return }
139-
guard let error = dict["message"] as? String else { return }
140-
141-
switch code {
142-
case 0: // Unknown transport
143-
didError(error)
144-
case 1: // Unknown sid.
145-
didError(error)
146-
case 2: // Bad handshake request
147-
didError(error)
148-
case 3: // Bad request
149-
didError(error)
150-
default:
151-
didError(error)
152-
}
137+
if let dict = try NSJSONSerialization.JSONObjectWithData(stringData, options: .MutableContainers) as? NSDictionary {
138+
guard let error = dict["message"] as? String else { return }
139+
140+
/*
141+
0: Unknown transport
142+
1: Unknown sid
143+
2: Bad handshake request
144+
3: Bad request
145+
*/
146+
didError(error)
153147
}
154148
} catch {
155149
didError("Got unknown error from server \(msg)")
@@ -204,7 +198,9 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
204198
}
205199
}
206200

207-
doLongPoll(reqPolling)
201+
dispatch_async(emitQueue) {
202+
self.doLongPoll(reqPolling)
203+
}
208204
}
209205

210206
private func createURLs() -> (NSURL, NSURL) {
@@ -218,8 +214,6 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
218214

219215
urlWebSocket.path = socketPath
220216
urlPolling.path = socketPath
221-
urlWebSocket.query = "transport=websocket"
222-
urlPolling.query = "transport=polling&b64=1"
223217

224218
if secure {
225219
urlPolling.scheme = "https"
@@ -231,12 +225,15 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
231225

232226
if connectParams != nil {
233227
for (key, value) in connectParams! {
234-
queryString += "&\(key)=\(value)"
228+
let keyEsc = key.urlEncode()!
229+
let valueEsc = "\(value)".urlEncode()!
230+
231+
queryString += "&\(keyEsc)=\(valueEsc)"
235232
}
236233
}
237234

238-
urlWebSocket.query = urlWebSocket.query! + queryString
239-
urlPolling.query = urlPolling.query! + queryString
235+
urlWebSocket.percentEncodedQuery = "transport=websocket" + queryString
236+
urlPolling.percentEncodedQuery = "transport=polling&b64=1" + queryString
240237

241238
return (urlPolling.URL!, urlWebSocket.URL!)
242239
}
@@ -286,7 +283,8 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
286283
DefaultSocketLogger.Logger.log("Engine is being closed.", type: logType)
287284

288285
if closed {
289-
return postSendClose(nil, nil, nil)
286+
client?.engineDidClose(reason)
287+
return
290288
}
291289

292290
if websocket {
@@ -393,7 +391,6 @@ public final class SocketEngine : NSObject, SocketEnginePollable, SocketEngineWe
393391
}
394392
} catch {
395393
didError("Error parsing open packet")
396-
return
397394
}
398395
}
399396

Source/SocketEnginePollable.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,7 @@ extension SocketEnginePollable {
181181
}
182182

183183
func parsePollingMessage(str: String) {
184-
guard str.characters.count != 1 else {
185-
return
186-
}
184+
guard str.characters.count != 1 else { return }
187185

188186
var reader = SocketStringReader(message: str)
189187

@@ -210,7 +208,7 @@ extension SocketEnginePollable {
210208
let fixedMessage: String
211209

212210
if doubleEncodeUTF8 {
213-
fixedMessage = doubleEncodeUTF8(message)
211+
fixedMessage = doubleEncodeUTF8(message)
214212
} else {
215213
fixedMessage = message
216214
}

Source/SocketEngineSpec.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import Foundation
4646
var urlPolling: NSURL { get }
4747
var urlWebSocket: NSURL { get }
4848
var websocket: Bool { get }
49+
var ws: WebSocket? { get }
4950

5051
init(client: SocketEngineClient, url: NSURL, options: NSDictionary?)
5152

@@ -62,14 +63,14 @@ import Foundation
6263
extension SocketEngineSpec {
6364
var urlPollingWithSid: NSURL {
6465
let com = NSURLComponents(URL: urlPolling, resolvingAgainstBaseURL: false)!
65-
com.query = com.query! + "&sid=\(sid)"
66+
com.percentEncodedQuery = com.percentEncodedQuery! + "&sid=\(sid.urlEncode()!)"
6667

6768
return com.URL!
6869
}
6970

7071
var urlWebSocketWithSid: NSURL {
7172
let com = NSURLComponents(URL: urlWebSocket, resolvingAgainstBaseURL: false)!
72-
com.query = com.query! + (sid == "" ? "" : "&sid=\(sid)")
73+
com.percentEncodedQuery = com.percentEncodedQuery! + (sid == "" ? "" : "&sid=\(sid.urlEncode()!)")
7374

7475
return com.URL!
7576
}

Source/SocketEngineWebsocket.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ import Foundation
2727

2828
/// Protocol that is used to implement socket.io WebSocket support
2929
public protocol SocketEngineWebsocket : SocketEngineSpec, WebSocketDelegate {
30-
var ws: WebSocket? { get }
31-
3230
func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType, withData datas: [NSData])
3331
}
3432

0 commit comments

Comments
 (0)