Object GatewayAPI

  • All Implemented Interfaces:

    
    public class GatewayAPI
    
                        

    Api for easily listening to gateway events

    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static GatewayAPI INSTANCE
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Constructor Detail

    • Method Detail

      • onRawEvent

         final static Boolean onRawEvent(GatewayAPI.EventListener<String> listener)

        Listens to all raw gateway events

        Parameters:
        listener - The method that gets called when a gateway event is received, it is passed the full event string rather than just the data.
      • onRawEvent

         final static Unit onRawEvent(List<String> names, Function1<String, Unit> listener)

        Listens to a specific set of gateway events

        See user docs for a list of possible events

        Parameters:
        names - List of event names to listen to (Case insensitive).
        listener - The method that gets called when any of the gateway events are received, it is passed the full event string rather than just the data.
      • onRawEvent

         final static Unit onRawEvent(String name, Function1<String, Unit> listener)

        Listens to a specific gateway event

        See user docs for a list of possible events

        Parameters:
        name - The name of the event (Case insensitive).
        listener - The method that gets called when the gateway event is received, it is passed the full event string rather than just the data.
      • onEvent

         final <T extends Any> Unit onEvent(String name, Function1<T, Unit> listener)

        Listens to a specific gateway event

        See user docs for a list of possible events

        Parameters:
        name - The name of the event (Case insensitive).
        listener - The method that gets called when the gateway event is received, it is passed a deserialized model of type T.
      • onEvent

         final static <T extends Any> Unit onEvent(String name, Class<T> clazz, Function1<T, Unit> listener)

        Listens to a specific gateway event

        See user docs for a list of possible events

        Parameters:
        name - The name of the event (Case insensitive).
        clazz - The type that the event's data should be deserialized to.
        listener - The method that gets called when the gateway event is received, it is passed an instance of clazz.