Class DiscordWebSocketHandler


  • public class DiscordWebSocketHandler
    extends Object
    Represents a WebSocket handler specialized for Discord gateway operations.

    Includes a zlib-based decompressor and dedicated handling of closing events that normally occur during Discord gateway lifecycle.

    This handler uses a FluxSink of GatewayPayload to push inbound payloads and a Flux of GatewayPayload to pull outbound payloads.

    The handler also provides two methods to control the lifecycle and proper cleanup, like close() and error(Throwable) which perform operations on the current session. It is necessary to use these methods in order to signal closure or errors and cleanly complete the session.

    All payloads going through this handler are passed to the given PayloadReader and PayloadWriter.

    • Constructor Detail

      • DiscordWebSocketHandler

        public DiscordWebSocketHandler​(PayloadReader reader,
                                       PayloadWriter writer,
                                       reactor.core.publisher.FluxSink<GatewayPayload<?>> inbound,
                                       reactor.core.publisher.Flux<GatewayPayload<?>> outbound,
                                       reactor.core.publisher.Flux<GatewayPayload<Heartbeat>> heartbeat,
                                       int shardIndex,
                                       GatewayLimiter limiter)
        Create a new handler with the given payload reader, payload writer and payload exchanges.
        Parameters:
        reader - the PayloadReader to process each inbound payload
        writer - the PayloadWriter to process each outbound payload
        inbound - the FluxSink of GatewayPayloads to process inbound payloads
        outbound - the Flux of GatewayPayloads to process outbound payloads
        heartbeat - the Flux of heartbeat payloads
        shardIndex - the shard index of this connection, for tracing
        limiter - a GatewayLimiter to throttle IDENTIFY requests