Package net.dv8tion.jda.api.events
Class DisconnectEvent
- java.lang.Object
-
- net.dv8tion.jda.api.events.Event
-
- net.dv8tion.jda.api.events.DisconnectEvent
-
- All Implemented Interfaces:
GenericEvent
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 in which case aShutdownEvent
is fired.When reconnecting was successful either a
ReconnectEvent
orResumedEvent
is fired.
-
-
Constructor Summary
Constructors Constructor Description DisconnectEvent(JDA api, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer, java.time.OffsetDateTime disconnectTime)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description WebSocketFrame
getClientCloseFrame()
The close frame we sent to discordCloseCode
getCloseCode()
Possibly-nullCloseCode
representing the meaning for this DisconnectEventWebSocketFrame
getServiceCloseFrame()
The close frame discord sent to usjava.time.OffsetDateTime
getTimeDisconnected()
Time at which we noticed the disconnectionboolean
isClosedByServer()
Whether the connection was closed by discord-
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getResponseNumber
-
-
-
-
Constructor Detail
-
DisconnectEvent
public DisconnectEvent(@Nonnull JDA api, @Nullable WebSocketFrame serverCloseFrame, @Nullable WebSocketFrame clientCloseFrame, boolean closedByServer, @Nonnull java.time.OffsetDateTime disconnectTime)
-
-
Method Detail
-
getCloseCode
@Nullable 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
-
getServiceCloseFrame
@Nullable public WebSocketFrame getServiceCloseFrame()
The close frame discord sent to us- Returns:
- The
WebSocketFrame
discord sent as closing handshake
-
getClientCloseFrame
@Nullable public 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
-
getTimeDisconnected
@Nonnull public java.time.OffsetDateTime getTimeDisconnected()
Time at which we noticed the disconnection- Returns:
- Time of closure
-
-