Package net.dv8tion.jda.core.events
Class DisconnectEvent
- java.lang.Object
-
- net.dv8tion.jda.core.events.Event
-
- net.dv8tion.jda.core.events.DisconnectEvent
-
public class DisconnectEvent extends Event
Indicates that JDA has been disconnected from the remote server.
When this event is fired JDA will try to reconnect if possible unlessJDABuilder.setAutoReconnect(Boolean)
has been providedfalse
or the disconnect was too fatal.When reconnecting was successful either a
ReconnectEvent
or aResumedEvent
is fired.
-
-
Constructor Summary
Constructors Constructor Description DisconnectEvent(JDA api, com.neovisionaries.ws.client.WebSocketFrame serverCloseFrame, com.neovisionaries.ws.client.WebSocketFrame clientCloseFrame, boolean closedByServer, java.time.OffsetDateTime disconnectTime)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.neovisionaries.ws.client.WebSocketFrame
getClientCloseFrame()
The close frame we sent to discordCloseCode
getCloseCode()
Possibly-nullCloseCode
representing the meaning for this DisconnectEventjava.util.List<java.lang.String>
getCloudflareRays()
Contains allcf-ray
headers that JDA received in this session.java.time.OffsetDateTime
getDisconnectTime()
Time at which we noticed the disconnectioncom.neovisionaries.ws.client.WebSocketFrame
getServiceCloseFrame()
The close frame discord sent to usboolean
isClosedByServer()
Whether the connection was closed by discord-
Methods inherited from class net.dv8tion.jda.core.events.Event
getJDA, getResponseNumber
-
-
-
-
Constructor Detail
-
DisconnectEvent
public DisconnectEvent(JDA api, com.neovisionaries.ws.client.WebSocketFrame serverCloseFrame, com.neovisionaries.ws.client.WebSocketFrame clientCloseFrame, boolean closedByServer, java.time.OffsetDateTime disconnectTime)
-
-
Method Detail
-
getCloseCode
public CloseCode getCloseCode()
Possibly-nullCloseCode
representing the meaning for this DisconnectEventThis is
null
if this disconnect did either not happen because the Service closed the session (seeisClosedByServer()
) or if there is no mapped CloseCode enum constant for the service close code!- Returns:
- Possibly-null
CloseCode
-
getCloudflareRays
public java.util.List<java.lang.String> getCloudflareRays()
Contains allcf-ray
headers that JDA received in this session.
These receive a new value whenever the WebSockedClient reconnects to the gateway.This is useful to monitor cloudflare activity from the Discord Developer perspective.
Use this list to report connection issues.- Returns:
- Immutable list of all cf-ray values for this session
-
getServiceCloseFrame
public com.neovisionaries.ws.client.WebSocketFrame getServiceCloseFrame()
The close frame discord sent to us- Returns:
- The
WebSocketFrame
discord sent as closing handshake
-
getClientCloseFrame
public com.neovisionaries.ws.client.WebSocketFrame getClientCloseFrame()
The close frame we sent to discord- Returns:
- The
WebSocketFrame
we sent as closing handshake
-
isClosedByServer
public boolean isClosedByServer()
Whether the connection was closed by discord- Returns:
- True, if discord closed our connection
-
getDisconnectTime
public java.time.OffsetDateTime getDisconnectTime()
Time at which we noticed the disconnection- Returns:
- Time of closure
-
-