DiscordGatewayable

public protocol DiscordGatewayable : DiscordEngineHeartbeatable

Declares that a type will communicate with a Discord gateway.

  • Creates the handshake object that Discord expects. Override if you need to customize the handshake object.

    Declaration

    Swift

    var handshakeObject: [String: Any]
  • Creates the resume object that Discord expects. Override if you need to customize the resume object.

    Declaration

    Swift

    var resumeObject: [String: Any]
  • Handles a DiscordGatewayPayload. You shouldn’t need to call this directly.

    Override this method if you need to customize payload handling.

    Declaration

    Swift

    func handleGatewayPayload(_ payload: DiscordGatewayPayload)

    Parameters

    payload

    The payload object

  • Handles a dispatch payload.

    Declaration

    Swift

    func handleDispatch(_ payload: DiscordGatewayPayload)

    Parameters

    payload

    The dispatch payload

  • Handles the hello event.

    Declaration

    Swift

    func handleHello(_ payload: DiscordGatewayPayload)

    Parameters

    payload

    The dispatch payload

  • Handles the resumed event.

    Declaration

    Swift

    func handleResumed(_ payload: DiscordGatewayPayload)

    Parameters

    payload

    The payload for the event.

  • Parses a raw message from the WebSocket. This is the entry point for all Discord events. You shouldn’t call this directly.

    Override this method if you need to customize parsing.

    Declaration

    Swift

    func parseGatewayMessage(_ string: String)

    Parameters

    string

    The raw payload string

  • sendPayload(_:) Default implementation

    Sends a payload to Discord.

    Default Implementation

    Default Implementation.

    Declaration

    Swift

    func sendPayload(_ payload: DiscordGatewayPayload)

    Parameters

    payload

    The payload to send.

  • Starts the handshake with the Discord server. You shouldn’t need to call this directly.

    Override this method if you need to customize the handshake process.

    Declaration

    Swift

    func startHandshake()