Protocols

The following protocols are available globally.

  • Declares that a type can set configs from a SocketIOClientConfiguration.

    See more

    Declaration

    Swift

    public protocol ConfigSettable
  • Defines the interface for a SocketIOClient.

    See more

    Declaration

    Swift

    public protocol SocketIOClientSpec : AnyObject
  • Declares that a type will be a delegate to an engine.

    See more

    Declaration

    Swift

    @objc
    public protocol SocketEngineClient
  • Protocol that is used to implement socket.io polling support

    See more

    Declaration

    Swift

    public protocol SocketEnginePollable : SocketEngineSpec
  • Specifies a SocketEngine.

    See more

    Declaration

    Swift

    public protocol SocketEngineSpec : AnyObject
  • Protocol that is used to implement socket.io WebSocket support

    See more

    Declaration

    Swift

    public protocol SocketEngineWebsocket : SocketEngineSpec
  • A manager for a socket.io connection.

    A SocketManagerSpec is responsible for multiplexing multiple namespaces through a single SocketEngineSpec.

    Example with SocketManager:

    let manager = SocketManager(socketURL: URL(string:"http://localhost:8080/")!)
    let defaultNamespaceSocket = manager.defaultSocket
    let swiftSocket = manager.socket(forNamespace: "/swift")
    
    // defaultNamespaceSocket and swiftSocket both share a single connection to the server
    

    Sockets created through the manager are retained by the manager. So at the very least, a single strong reference to the manager must be maintained to keep sockets alive.

    To disconnect a socket and remove it from the manager, either call SocketIOClient.disconnect() on the socket, or call one of the disconnectSocket methods on this class.

    See more

    Declaration

    Swift

    public protocol SocketManagerSpec : AnyObject, SocketEngineClient
  • Defines that a type will be able to parse socket.io-protocol messages.

    See more

    Declaration

    Swift

    public protocol SocketParsable : AnyObject
  • Says that a type will be able to buffer binary data before all data for an event has come in.

    See more

    Declaration

    Swift

    public protocol SocketDataBufferable : AnyObject
  • Represents a class will log client events.

    See more

    Declaration

    Swift

    public protocol SocketLogger : AnyObject
  • A marking protocol that says a type can be represented in a socket.io packet.

    Example:

    struct CustomData : SocketData {
       let name: String
       let age: Int
    
       func socketRepresentation() -> SocketData {
           return ["name": name, "age": age]
       }
    }
    
    socket.emit("myEvent", CustomData(name: "Erik", age: 24))
    
    See more

    Declaration

    Swift

    public protocol SocketData