Class SessionDisconnectEvent
java.lang.Object
net.dv8tion.jda.api.events.Event
net.dv8tion.jda.api.events.session.GenericSessionEvent
net.dv8tion.jda.api.events.session.SessionDisconnectEvent
- 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 SessionRecreateEvent
or SessionResumeEvent
is fired.
-
Constructor Summary
ConstructorDescriptionSessionDisconnectEvent
(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.session.GenericSessionEvent
getState
Methods inherited from class net.dv8tion.jda.api.events.Event
getJDA, getRawData, getResponseNumber, toString
-
Constructor Details
-
SessionDisconnectEvent
public SessionDisconnectEvent(@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
-