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 providedfalseor the disconnect was too fatal in which case aShutdownEventis fired.When reconnecting was successful either a
ReconnectEventorResumedEventis 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 WebSocketFramegetClientCloseFrame()The close frame we sent to discordCloseCodegetCloseCode()Possibly-nullCloseCoderepresenting the meaning for this DisconnectEventWebSocketFramegetServiceCloseFrame()The close frame discord sent to usjava.time.OffsetDateTimegetTimeDisconnected()Time at which we noticed the disconnectionbooleanisClosedByServer()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-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
@Nullable public WebSocketFrame getServiceCloseFrame()
The close frame discord sent to us- Returns:
- The
WebSocketFramediscord sent as closing handshake
-
getClientCloseFrame
@Nullable public WebSocketFrame 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
@Nonnull public java.time.OffsetDateTime getTimeDisconnected()
Time at which we noticed the disconnection- Returns:
- Time of closure
-
-