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
Indicates that JDA has been disconnected from the remote server.
When this event is fired JDA will try to reconnect if possible unless
When this event is fired JDA will try to reconnect if possible unless
JDABuilder.setAutoReconnect(Boolean)
has been provided false
or the disconnect was too fatal in which case a ShutdownEvent
is fired.
When reconnecting was successful either a ReconnectEvent
or ResumedEvent
is fired.
-
Constructor Summary
ConstructorDescriptionDisconnectEvent
(JDA api, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer, OffsetDateTime disconnectTime) -
Method Summary
Modifier and TypeMethodDescriptionThe close frame we sent to discordPossibly-nullCloseCode
representing the meaning for this DisconnectEventThe close frame discord sent to usTime at which we noticed the disconnectionboolean
Whether the connection was closed by discordMethods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getResponseNumber
-
Constructor Details
-
DisconnectEvent
public DisconnectEvent(@Nonnull JDA api, @Nullable WebSocketFrame serverCloseFrame, @Nullable WebSocketFrame clientCloseFrame, boolean closedByServer, @Nonnull OffsetDateTime disconnectTime)
-
-
Method Details
-
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
The close frame discord sent to us- Returns:
- The
WebSocketFrame
discord sent as closing handshake
-
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
Time at which we noticed the disconnection- Returns:
- Time of closure
-