public class DiscordWebSocketHandler extends Object
Includes a zlib-based decompressor and dedicated handling of closing events that normally occur during Discord gateway lifecycle.
This handler uses a FluxSink of ByteBuf to push inbound payloads and a Flux of
ByteBuf 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.
| Constructor and Description |
|---|
DiscordWebSocketHandler(FluxSink<ByteBuf> inbound,
Flux<ByteBuf> outbound,
MonoProcessor<CloseStatus> closeTrigger,
int shardIndex)
Create a new handler with the given data pipelines.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Initiates a close sequence that will terminate this session.
|
void |
error(Throwable error)
Initiates a close sequence with the given error.
|
Mono<Void> |
handle(WebsocketInbound in,
WebsocketOutbound out) |
public DiscordWebSocketHandler(FluxSink<ByteBuf> inbound, Flux<ByteBuf> outbound, MonoProcessor<CloseStatus> closeTrigger, int shardIndex)
inbound - the FluxSink of ByteBuf to process inbound payloadsoutbound - the Flux of ByteBuf to process outbound payloadscloseTrigger - a MonoProcessor that triggers the closing of this sessionshardIndex - the shard index of this connection, for tracingpublic Mono<Void> handle(WebsocketInbound in, WebsocketOutbound out)
public void close()
Mono in
handle(reactor.netty.http.websocket.WebsocketInbound, reactor.netty.http.websocket.WebsocketOutbound)
through a complete signal, dropping all future signals.public void error(Throwable error)
handle(reactor.netty.http.websocket.WebsocketInbound, reactor.netty.http.websocket.WebsocketOutbound)
method, while completing both exchanges through normal complete signals.
The error can then be channeled downstream and acted upon accordingly.
error - the cause for this session termination