DiscordWebSocketable
public protocol DiscordWebSocketable : class
Declares that a type will be capable of communicating with Discord’s WebSockets
-
MARK: Properties The url to connect to.
Declaration
Swift
var connectURL: String -
The UUID for this WebSocketable.
Declaration
Swift
var connectUUID: UUID -
A description of this WebSocketable.
Declaration
Swift
var description: String -
The queue WebSockets do their parsing on.
Declaration
Swift
var parseQueue: DispatchQueue -
A reference to the underlying WebSocket. This is a WebSockets.Websocket on Linux and Starscream.WebSocket on macOS/iOS.
Declaration
Swift
var websocket: WebSocket?
-
attachWebSocketHandlers()Default implementationAttaches the WebSocket handlers that listen for text/connects/disconnects/etc
Override if you need to provide custom handlers.
Note: You should handle both WebSockets.WebSocket and Starscream.WebSocket handlers.
Default Implementation
Default implementation.
Declaration
Swift
func attachWebSocketHandlers() -
connect()Default implementationStarts the connection to the Discord gateway.
Default Implementation
Starts the connection to the Discord gateway.
Declaration
Swift
func connect() -
Disconnects the engine. An
engine.disconnectis fired on disconnection.Declaration
Swift
func disconnect() -
Handles a close from the WebSocket.
Declaration
Swift
func handleClose(reason: Error?)Parameters
reasonThe reason the socket closed.
-
error(message:)Extension methodLogs that an error occured.
Declaration
Swift
public func error(message: String)Parameters
messageThe error message
DiscordWebSocketable Protocol Reference