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")
  • Gets a socket by its name.

    Declaration

    Swift

    open subscript(string: String) -> SocketIOClient?

    Return Value

    The socket, if one had the given name.

  • The shared manager.

    Declaration

    Swift

    open static let sharedManager = SocketClientManager()
  • 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.

  • 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.

  • 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.

  • Removes all the sockets in the manager.

    Declaration

    Swift

    open func removeSockets()