Back to Socket Io Client Swift

Protocols

docs/Protocols.html

16.1.13.7 KB
Original Source

Protocols

The following protocols are available globally.

`

                ConfigSettable
                `

Declares that a type can set configs from a SocketIOClientConfiguration.

See more

Declaration

Swift

public protocol ConfigSettable

`

                SocketIOClientSpec
                `

Defines the interface for a SocketIOClient.

See more

Declaration

Swift

public protocol SocketIOClientSpec : AnyObject

`

                SocketEngineClient
                `

Declares that a type will be a delegate to an engine.

See more

Declaration

Swift

@objc
public protocol SocketEngineClient

`

                SocketEnginePollable
                `

Protocol that is used to implement socket.io polling support

See more

Declaration

Swift

public protocol SocketEnginePollable : SocketEngineSpec

`

                SocketEngineSpec
                `

Specifies a SocketEngine.

See more

Declaration

Swift

public protocol SocketEngineSpec : AnyObject

`

                SocketEngineWebsocket
                `

Protocol that is used to implement socket.io WebSocket support

See more

Declaration

Swift

public protocol SocketEngineWebsocket : SocketEngineSpec

`

                SocketManagerSpec
                `

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

`

                SocketParsable
                `

Defines that a type will be able to parse socket.io-protocol messages.

See more

Declaration

Swift

public protocol SocketParsable : AnyObject

`

                SocketDataBufferable
                `

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

`

                SocketLogger
                `

Represents a class will log client events.

See more

Declaration

Swift

public protocol SocketLogger : AnyObject

`

                SocketData
                `

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