Back to Socket Io Client Swift

SocketClientManager

docs/Classes/SocketClientManager.html

16.1.12.3 KB
Original Source

SocketClientManager

open class SocketClientManager : NSObject

Experimental socket manager.

API subject to change.

Can be used to persist sockets across ViewControllers.

Sockets are strongly stored, so be sure to remove them once they are no longer needed.

Example usage:

let manager = SocketClientManager.sharedManager
manager["room1"] = socket1
manager["room2"] = socket2
manager.removeSocket(socket: socket2)
manager["room1"]?.emit("hello")

[

Properties.

](#/Properties.)

`

                sharedManager
                `

The shared manager.

Declaration

Swift

open static let sharedManager = SocketClientManager()

`

                subscript(_:)
                `

Gets a socket by its name.

Declaration

Swift

open subscript(string: String) -> SocketIOClient?

Return Value

The socket, if one had the given name.

[

Methods.

](#/Methods.)

`

                addSocket(_:labeledAs:)
                `

Adds a socket.

Declaration

Swift

open func addSocket(_ socket: SocketIOClient, labeledAs label: String)

Parameters

| socket |

The socket to add.

| | labeledAs |

The label for this socket.

|

`

                removeSocket(withLabel:)
                `

Removes a socket by a given name.

Declaration

Swift

open func removeSocket(withLabel label: String) -> SocketIOClient?

Parameters

| withLabel |

The label of the socket to remove.

|

Return Value

The socket for the given label, if one was present.

`

                removeSocket(_:)
                `

Removes a socket.

Declaration

Swift

open func removeSocket(_ socket: SocketIOClient) -> SocketIOClient?

Parameters

| socket |

The socket to remove.

|

Return Value

The socket if it was in the manager.

`

                removeSockets()
                `

Removes all the sockets in the manager.

Declaration

Swift

open func removeSockets()