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
ConstructorsConstructorDescriptionSessionDisconnectEvent(JDA api, WebSocketFrame serverCloseFrame, WebSocketFrame clientCloseFrame, boolean closedByServer, OffsetDateTime disconnectTime) -
Method Summary
Modifier and TypeMethodDescriptionThe close frame we sent to discordPossibly-nullCloseCoderepresenting the meaning for this DisconnectEventThe close frame discord sent to usTime at which we noticed the disconnectionbooleanWhether the connection was closed by discordMethods inherited from class net.dv8tion.jda.api.events.session.GenericSessionEvent
getStateMethods 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-nullCloseCoderepresenting the meaning for this DisconnectEventThis is
nullif 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
WebSocketFramediscord sent as closing handshake
-
getClientCloseFrame
The close frame we sent to discord- Returns:
- The
WebSocketFramewe 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
-