Interface IPacketListenerRegistry

  • All Known Implementing Classes:
    DefaultPacketListenerRegistry

    public interface IPacketListenerRegistry
    The packet listener registry allows to manage listeners that can handle input packet messages.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addListener​(int channel, IPacketListener... listeners)
      Adds a new listeners for packets that are received on a specific channel
      java.util.Collection<java.lang.Integer> getChannels()
      Returns all channelIds that the packet listener registry has listeners registered
      java.util.Collection<IPacketListener> getListeners()
      Returns all listeners by all channels from the registry
      IPacketListenerRegistry getParent()
      Returns the parent PacketListenerRegistry implementation instance if exists
      void handlePacket​(INetworkChannel channel, IPacket packet)
      Handles an incoming packet and invoke all listeners that are registered in this registry
      boolean hasListener​(java.lang.Class<? extends IPacketListener> clazz)
      Returns true if the a specific listener class is contain in this registry
      void removeListener​(int channel, IPacketListener... listeners)
      Removes the listeners if they are registered on this listener registry.
      void removeListeners()
      Removes all listeners by all channel from the registry
      void removeListeners​(int channel)
      Removes all listeners on a specific channel
      void removeListeners​(java.lang.ClassLoader classLoader)
      Remove all listeners that are registered on the specific classLoader instance
    • Method Detail

      • getParent

        IPacketListenerRegistry getParent()
        Returns the parent PacketListenerRegistry implementation instance if exists
      • addListener

        void addListener​(int channel,
                         IPacketListener... listeners)
        Adds a new listeners for packets that are received on a specific channel
        Parameters:
        channel - the channel, that the listener should listen on
        listeners - the listeners that should be add for this channel
      • removeListener

        void removeListener​(int channel,
                            IPacketListener... listeners)
        Removes the listeners if they are registered on this listener registry. If the listeners items are null, then it should ignored
        Parameters:
        channel - the channel, that the listener should listen on
        listeners - the listeners, that should remove on this registry
      • removeListeners

        void removeListeners​(int channel)
        Removes all listeners on a specific channel
        Parameters:
        channel - the channel id from that all listeners should remove
      • removeListeners

        void removeListeners​(java.lang.ClassLoader classLoader)
        Remove all listeners that are registered on the specific classLoader instance
        Parameters:
        classLoader - the classLoader, from that all listeners that are contained on the registry should remove
      • hasListener

        boolean hasListener​(java.lang.Class<? extends IPacketListener> clazz)
        Returns true if the a specific listener class is contain in this registry
      • removeListeners

        void removeListeners()
        Removes all listeners by all channel from the registry
      • getChannels

        java.util.Collection<java.lang.Integer> getChannels()
        Returns all channelIds that the packet listener registry has listeners registered
      • getListeners

        java.util.Collection<IPacketListener> getListeners()
        Returns all listeners by all channels from the registry
      • handlePacket

        void handlePacket​(INetworkChannel channel,
                          IPacket packet)
        Handles an incoming packet and invoke all listeners that are registered in this registry
        Parameters:
        channel - the channel, from that the packet was received
        packet - the packet that should handle