Class GatewayPingEvent

java.lang.Object
net.dv8tion.jda.api.events.Event
net.dv8tion.jda.api.events.GatewayPingEvent
All Implemented Interfaces:
GenericEvent, UpdateEvent<JDA,Long>

public class GatewayPingEvent extends Event implements UpdateEvent<JDA,Long>
Indicates that the gateway ping has been updated by the heartbeat cycle.
You can always get the last ping update with JDA.getGatewayPing().

Can be used to detect changes to the gateway ping.

Identifier: gateway-ping

  • Field Details

  • Constructor Details

    • GatewayPingEvent

      public GatewayPingEvent(@Nonnull JDA api, long old)
  • Method Details

    • getNewPing

      public long getNewPing()
      The new ping for the current JDA session
      Returns:
      The new ping in milliseconds
    • getOldPing

      public long getOldPing()
      The previous ping for the current JDA session
      Returns:
      The previous ping in milliseconds, or -1 if no ping was available yet
    • getPropertyIdentifier

      @Nonnull public String getPropertyIdentifier()
      Description copied from interface: UpdateEvent
      The field name for the updated property

      Example

      
       @Override
       public void onGenericRoleUpdate(GenericRoleUpdateEvent event)
       {
           switch (event.getPropertyIdentifier())
           {
           case RoleUpdateColorEvent.IDENTIFIER:
               System.out.printf("Updated color for role: %s%n", event);
               break;
           case RoleUpdatePositionEvent.IDENTIFIER:
               RoleUpdatePositionEvent update = (RoleUpdatePositionEvent) event;
               System.out.printf("Updated position for role: %s raw(%s->%s)%n", event, update.getOldPositionRaw(), update.getNewPositionRaw());
               break;
           default: return;
           }
       }
       
      Specified by:
      getPropertyIdentifier in interface UpdateEvent<JDA,Long>
      Returns:
      The name of the updated property
    • getEntity

      @Nonnull public JDA getEntity()
      Description copied from interface: UpdateEvent
      The affected entity
      Specified by:
      getEntity in interface UpdateEvent<JDA,Long>
      Returns:
      The affected entity
    • getOldValue

      @Nonnull public Long getOldValue()
      Description copied from interface: UpdateEvent
      The old value
      Specified by:
      getOldValue in interface UpdateEvent<JDA,Long>
      Returns:
      The old value
    • getNewValue

      @Nonnull public Long getNewValue()
      Description copied from interface: UpdateEvent
      The new value
      Specified by:
      getNewValue in interface UpdateEvent<JDA,Long>
      Returns:
      The new value
    • toString

      public String toString()
      Overrides:
      toString in class Object