Protocols
The following protocols are available globally.
-
Declares that a type can set configs from a
See moreSocketIOClientConfiguration
.Declaration
Swift
public protocol ConfigSettable
-
Defines the interface for a SocketIOClient.
See moreDeclaration
Swift
public protocol SocketIOClientSpec : AnyObject
-
Declares that a type will be a delegate to an engine.
See moreDeclaration
Swift
@objc public protocol SocketEngineClient
-
Protocol that is used to implement socket.io polling support
See moreDeclaration
Swift
public protocol SocketEnginePollable : SocketEngineSpec
-
Specifies a SocketEngine.
See moreDeclaration
Swift
public protocol SocketEngineSpec : AnyObject
-
Protocol that is used to implement socket.io WebSocket support
See moreDeclaration
Swift
public protocol SocketEngineWebsocket : SocketEngineSpec
-
A manager for a socket.io connection.
A
SocketManagerSpec
is responsible for multiplexing multiple namespaces through a singleSocketEngineSpec
.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
See moreSocketIOClient.disconnect()
on the socket, or call one of thedisconnectSocket
methods on this class.Declaration
Swift
public protocol SocketManagerSpec : AnyObject, SocketEngineClient
-
Defines that a type will be able to parse socket.io-protocol messages.
See moreDeclaration
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 moreDeclaration
Swift
public protocol SocketDataBufferable : AnyObject
-
Represents a class will log client events.
See moreDeclaration
Swift
public protocol SocketLogger : AnyObject
-
A marking protocol that says a type can be represented in a socket.io packet.
Example:
See morestruct CustomData : SocketData { let name: String let age: Int func socketRepresentation() -> SocketData { return ["name": name, "age": age] } } socket.emit("myEvent", CustomData(name: "Erik", age: 24))
Declaration
Swift
public protocol SocketData