Skip to content

Commit 8584b90

Browse files
committed
simplify namespace api
1 parent 7acce7d commit 8584b90

File tree

3 files changed

+6
-13
lines changed

3 files changed

+6
-13
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ Methods
178178
9. `connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
179179
10. `close()` - Closes the socket. Once a socket is closed it should not be reopened.
180180
11. `reconnect()` - Causes the client to reconnect to the server.
181-
12. `joinNamespace()` - Causes the client to join nsp. Shouldn't need to be called unless you change nsp manually.
181+
12. `joinNamespace(namespace: String)` - Causes the client to join namespace. Shouldn't need to be called unless you change namespaces manually.
182182
13. `leaveNamespace()` - Causes the client to leave the nsp and go back to /
183183
14. `off(event: String)` - Removes all event handlers for event.
184184
15. `off(id id: NSUUID)` - Removes the event that corresponds to id.

Source/SocketIOClient.swift

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -358,24 +358,17 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
358358
}
359359

360360
/**
361-
Joins nsp if it is not /
361+
Joins namespace
362362
*/
363-
public func joinNamespace() {
364-
DefaultSocketLogger.Logger.log("Joining namespace", type: logType)
363+
public func joinNamespace(namespace: String) {
364+
nsp = namespace
365365

366366
if nsp != "/" {
367+
DefaultSocketLogger.Logger.log("Joining namespace", type: logType)
367368
engine?.send("0\(nsp)", withData: [])
368369
}
369370
}
370371

371-
/**
372-
Joins namespace /
373-
*/
374-
public func joinNamespace(namespace: String) {
375-
self.nsp = namespace
376-
joinNamespace()
377-
}
378-
379372
/**
380373
Removes handler(s)
381374
*/

Source/SocketParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SocketParser {
3030

3131
private static func handleConnect(p: SocketPacket, socket: SocketIOClient) {
3232
if p.nsp == "/" && socket.nsp != "/" {
33-
socket.joinNamespace()
33+
socket.joinNamespace(socket.nsp)
3434
} else if p.nsp != "/" && socket.nsp == "/" {
3535
socket.didConnect()
3636
} else {

0 commit comments

Comments
 (0)