Skip to content

Commit 2910355

Browse files
committed
Merge branch 'development'
* development: update readme Renamed modules to make then consistent. rename engine init tweaks Add SocketIOClientConfiguration Rename variable refactor some reconnect code bump websocket version move extensions refactor out checking for base64
2 parents 6147cda + 5e1dc53 commit 2910355

19 files changed

+461
-318
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ Socket.IO-client for iOS/OS X.
55

66
##Example
77
```swift
8-
let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8080")!, options: [.Log(true), .ForcePolling(true)])
8+
import SocketIO
9+
10+
let socket = SocketIOClient(socketURL: NSURL(string: "http://localhost:8080")!, config: [.Log(true), .ForcePolling(true)])
911

1012
socket.on("connect") {data, ack in
1113
print("socket connected")
@@ -26,8 +28,9 @@ socket.connect()
2628

2729
##Objective-C Example
2830
```objective-c
31+
@import SocketIO;
2932
NSURL* url = [[NSURL alloc] initWithString:@"http://localhost:8080"];
30-
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url options:@{@"log": @YES, @"forcePolling": @YES}];
33+
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @YES, @"forcePolling": @YES}];
3134

3235
[socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
3336
NSLog(@"socket connected");
@@ -115,13 +118,13 @@ Import the module:
115118

116119
Swift:
117120
```swift
118-
import SocketIOClientSwift
121+
import SocketIO
119122
```
120123

121124
Objective-C:
122125

123126
```Objective-C
124-
@import SocketIOClientSwift;
127+
@import SocketIO;
125128
```
126129

127130
CocoaSeeds
@@ -139,7 +142,7 @@ Run `seed install`.
139142
##API
140143
Constructors
141144
-----------
142-
`init(var socketURL: NSURL, options: Set<SocketIOClientOption> = [])` - 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.
145+
`init(var socketURL: NSURL, config: SocketIOClientConfiguration = [])` - 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.
143146

144147
`convenience init(socketURL: NSURL, options: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys.
145148

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

Lines changed: 80 additions & 90 deletions
Large diffs are not rendered by default.

SocketIO-MacTests/SocketAckManagerTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import XCTest
10-
@testable import SocketIOClientSwift
10+
@testable import SocketIO
1111

1212
class SocketAckManagerTest: XCTestCase {
1313
var ackManager = SocketAckManager()

SocketIO-MacTests/SocketBasicPacketTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import XCTest
10-
@testable import SocketIOClientSwift
10+
@testable import SocketIO
1111

1212
class SocketBasicPacketTest: XCTestCase {
1313
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!

SocketIO-MacTests/SocketEngineTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import XCTest
10-
@testable import SocketIOClientSwift
10+
@testable import SocketIO
1111

1212
class SocketEngineTest: XCTestCase {
1313
var client: SocketIOClient!
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// TestSocketIOClientConfiguration.swift
3+
// Socket.IO-Client-Swift
4+
//
5+
// Created by Erik Little on 8/13/16.
6+
//
7+
//
8+
9+
import XCTest
10+
import SocketIO
11+
12+
class TestSocketIOClientConfiguration: XCTestCase {
13+
var config = [] as SocketIOClientConfiguration
14+
15+
override func setUp() {
16+
super.setUp()
17+
18+
config = [.Log(false), .ForceNew(true)]
19+
}
20+
21+
func testReplaceSameOption() {
22+
config.insert(.Log(true))
23+
24+
XCTAssertEqual(config.count, 2)
25+
26+
switch config[0] {
27+
case let .Log(log):
28+
XCTAssertTrue(log)
29+
default:
30+
XCTFail()
31+
}
32+
}
33+
34+
func testIgnoreIfExisting() {
35+
config.insert(.ForceNew(false), replacing: false)
36+
37+
XCTAssertEqual(config.count, 2)
38+
39+
switch config[1] {
40+
case let .ForceNew(new):
41+
XCTAssertTrue(new)
42+
default:
43+
XCTFail()
44+
}
45+
}
46+
}

SocketIO-MacTests/SocketNamespacePacketTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import XCTest
10-
@testable import SocketIOClientSwift
10+
@testable import SocketIO
1111

1212
class SocketNamespacePacketTest: XCTestCase {
1313
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!

SocketIO-MacTests/SocketObjectiveCTest.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//
99

1010
#import <XCTest/XCTest.h>
11-
@import SocketIOClientSwift;
11+
@import SocketIO;
1212

1313
@interface SocketObjectiveCTest : XCTestCase
1414

@@ -21,7 +21,7 @@ @implementation SocketObjectiveCTest
2121
- (void)setUp {
2222
[super setUp];
2323
NSURL* url = [[NSURL alloc] initWithString:@"http://localhost"];
24-
self.socket = [[SocketIOClient alloc] initWithSocketURL:url options:nil];
24+
self.socket = [[SocketIOClient alloc] initWithSocketURL:url config:nil];
2525
}
2626

2727
- (void)testOnSyntax {

SocketIO-MacTests/SocketParserTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import XCTest
10-
@testable import SocketIOClientSwift
10+
@testable import SocketIO
1111

1212
class SocketParserTest: XCTestCase {
1313
let testSocket = SocketIOClient(socketURL: NSURL())

SocketIO-MacTests/SocketSideEffectTest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//
88

99
import XCTest
10-
@testable import SocketIOClientSwift
10+
@testable import SocketIO
1111

1212
class SocketSideEffectTest: XCTestCase {
1313
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!

0 commit comments

Comments
 (0)