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 implementation

    Attaches 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 implementation

    Starts the connection to the Discord gateway.

    Default Implementation

    Starts the connection to the Discord gateway.

    Declaration

    Swift

    func connect()
  • Disconnects the engine. An engine.disconnect is fired on disconnection.

    Declaration

    Swift

    func disconnect()
  • Handles a close from the WebSocket.

    Declaration

    Swift

    func handleClose(reason: Error?)

    Parameters

    reason

    The reason the socket closed.

  • error(message:) Extension method

    Logs that an error occured.

    Declaration

    Swift

    public func error(message: String)

    Parameters

    message

    The error message