docs/Protocols/SocketEngineSpec.html
public protocol SocketEngineSpec : AnyObject
Specifies a SocketEngine.
Properties
`
client
`
The client for this engine.
Swift
var client: SocketEngineClient? { get set }
`
closed
`
true if this engine is closed.
Swift
var closed: Bool { get }
`
compress
`
If true the engine will attempt to use WebSocket compression.
Swift
var compress: Bool { get }
`
connected
`
true if this engine is connected. Connected means that the initial poll connect has succeeded.
Swift
var connected: Bool { get }
`
connectParams
`
The connect parameters sent during a connect.
Swift
var connectParams: [String : Any]? { get set }
`
cookies
`
An array of HTTPCookies that are sent during the connection.
Swift
var cookies: [HTTPCookie]? { get }
`
engineQueue
`
The queue that all engine actions take place on.
Swift
var engineQueue: DispatchQueue { get }
`
extraHeaders
`
A dictionary of extra http headers that will be set during connection.
Swift
var extraHeaders: [String : String]? { get set }
`
fastUpgrade
`
When true, the engine is in the process of switching to WebSockets.
Swift
var fastUpgrade: Bool { get }
`
forcePolling
`
When true, the engine will only use HTTP long-polling as a transport.
Swift
var forcePolling: Bool { get }
`
forceWebsockets
`
When true, the engine will only use WebSockets as a transport.
Swift
var forceWebsockets: Bool { get }
`
polling
`
If true, the engine is currently in HTTP long-polling mode.
Swift
var polling: Bool { get }
`
probing
`
If true, the engine is currently seeing whether it can upgrade to WebSockets.
Swift
var probing: Bool { get }
`
sid
`
The session id for this engine.
Swift
var sid: String { get }
`
socketPath
`
The path to engine.io.
Swift
var socketPath: String { get }
`
urlPolling
`
The url for polling.
Swift
var urlPolling: URL { get }
`
urlWebSocket
`
The url for WebSockets.
Swift
var urlWebSocket: URL { get }
`
version
`
The version of engine.io being used. Default is three.
Swift
var version: SocketIOVersion { get }
`
websocket
`
If true, then the engine is currently in WebSockets mode.
Swift
@available(*, deprecated, message: "No longer needed, if we're not polling, then we must be doing websockets")
var websocket: Bool { get }
`
ws
`
The WebSocket for this engine.
Swift
var ws: WebSocket? { get }
Initializers
`
init(client:url:options:)
`
Creates a new engine.
Swift
init(client: SocketEngineClient, url: URL, options: [String : Any]?)
| client |
The client for this engine.
|
| url |
The url for this engine.
|
| options |
The options for this engine.
|
Methods
`
connect()
`
Starts the connection to the server.
Swift
func connect()
`
didError(reason:)
`
Called when an error happens during execution. Causes a disconnection.
Swift
func didError(reason: String)
`
disconnect(reason:)
`
Disconnects from the server.
Swift
func disconnect(reason: String)
| reason |
The reason for the disconnection. This is communicated up to the client.
|
`
doFastUpgrade()
`
Called to switch from HTTP long-polling to WebSockets. After calling this method the engine will be in WebSocket mode.
You shouldn’t call this directly
Swift
func doFastUpgrade()
`
flushWaitingForPostToWebSocket()
`
Causes any packets that were waiting for POSTing to be sent through the WebSocket. This happens because when the engine is attempting to upgrade to WebSocket it does not do any POSTing.
You shouldn’t call this directly
Swift
func flushWaitingForPostToWebSocket()
`
parseEngineData(_:)
`
Parses raw binary received from engine.io.
Swift
func parseEngineData(_ data: Data)
| data |
The data to parse.
|
`
parseEngineMessage(_:)
`
Parses a raw engine.io packet.
Swift
func parseEngineMessage(_ message: String)
| message |
The message to parse.
|
`
write(_:withType:withData:completion:)
`
Writes a message to engine.io, independent of transport.
Swift
func write(_ msg: String, withType type: SocketEnginePacketType, withData data: [Data], completion: (() -> ())?)
| msg |
The message to send.
|
| type |
The type of this message.
|
| data |
Any data that this message has.
|
| completion |
Callback called on transport write completion.
|