Skip to content

Commit fe02b8e

Browse files
committed
change socketparser into a protocol
1 parent 0c8ff90 commit fe02b8e

File tree

14 files changed

+135
-71
lines changed

14 files changed

+135
-71
lines changed

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

Lines changed: 35 additions & 13 deletions
Large diffs are not rendered by default.

Socket.IO-Client-Swift.xcodeproj/xcshareddata/xcschemes/SocketIO-Mac.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0640"
3+
LastUpgradeVersion = "0720"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Socket.IO-Client-Swift.xcodeproj/xcshareddata/xcschemes/SocketIO-iOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0640"
3+
LastUpgradeVersion = "0720"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Socket.IO-Client-Swift.xcodeproj/xcshareddata/xcschemes/SocketIO-tvOS.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0710"
3+
LastUpgradeVersion = "0720"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

SocketIO-Mac/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

SocketIO-MacTests/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

SocketIO-MacTests/SocketParserTest.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import XCTest
1010
@testable import SocketIO
1111

1212
class SocketParserTest: XCTestCase {
13+
let testSocket = SocketIOClient(socketURL: "")
1314

1415
//Format key: message; namespace-data-binary-id
1516
static let packetTypes: Dictionary<String, (String, [AnyObject], [NSData], Int)> = [
@@ -93,7 +94,7 @@ class SocketParserTest: XCTestCase {
9394

9495
func testInvalidInput() {
9596
let message = "8"
96-
switch SocketParser.parseString(message) {
97+
switch testSocket.parseString(message) {
9798
case .Left(_):
9899
return
99100
case .Right(_):
@@ -111,7 +112,7 @@ class SocketParserTest: XCTestCase {
111112

112113
func validateParseResult(message: String) {
113114
let validValues = SocketParserTest.packetTypes[message]!
114-
let packet = SocketParser.parseString(message)
115+
let packet = testSocket.parseString(message)
115116
let type = message.substringWithRange(Range<String.Index>(start: message.startIndex, end: message.startIndex.advancedBy(1)))
116117
if case let .Right(packet) = packet {
117118
XCTAssertEqual(packet.type, SocketPacket.PacketType(rawValue: Int(type) ?? -1)!)
@@ -128,7 +129,7 @@ class SocketParserTest: XCTestCase {
128129
let keys = Array(SocketParserTest.packetTypes.keys)
129130
measureBlock({
130131
for item in keys.enumerate() {
131-
SocketParser.parseString(item.element)
132+
self.testSocket.parseString(item.element)
132133
}
133134
})
134135
}

SocketIO-iOS/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

SocketIO-iOSTests/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<key>CFBundleExecutable</key>
88
<string>$(EXECUTABLE_NAME)</string>
99
<key>CFBundleIdentifier</key>
10-
<string>io.socket.$(PRODUCT_NAME:rfc1034identifier)</string>
10+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
1111
<key>CFBundleInfoDictionaryVersion</key>
1212
<string>6.0</string>
1313
<key>CFBundleName</key>

Source/SocketClientSpec.swift

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//
2+
// SocketClientSpec.swift
3+
// Socket.IO-Client-Swift
4+
//
5+
// Created by Erik Little on 1/3/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+
protocol SocketClientSpec: class {
28+
var nsp: String { get set }
29+
var waitingData: [SocketPacket] { get set }
30+
31+
func didConnect()
32+
func didDisconnect(reason: String)
33+
func didError(reason: AnyObject)
34+
func handleAck(ack: Int, data: [AnyObject])
35+
func handleEvent(event: String, data: [AnyObject], isInternalMessage: Bool, withAck ack: Int)
36+
func joinNamespace(namespace: String)
37+
}

0 commit comments

Comments
 (0)