Interface IPacketListenerRegistry
-
- All Known Implementing Classes:
DefaultPacketListenerRegistry
public interface IPacketListenerRegistryThe 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 voidaddListener(int channel, IPacketListener... listeners)Adds a new listeners for packets that are received on a specific channeljava.util.Collection<java.lang.Integer>getChannels()Returns all channelIds that the packet listener registry has listeners registeredjava.util.Collection<IPacketListener>getListeners()Returns all listeners by all channels from the registryIPacketListenerRegistrygetParent()Returns the parent PacketListenerRegistry implementation instance if existsvoidhandlePacket(INetworkChannel channel, IPacket packet)Handles an incoming packet and invoke all listeners that are registered in this registrybooleanhasListener(java.lang.Class<? extends IPacketListener> clazz)Returns true if the a specific listener class is contain in this registryvoidremoveListener(int channel, IPacketListener... listeners)Removes the listeners if they are registered on this listener registry.voidremoveListeners()Removes all listeners by all channel from the registryvoidremoveListeners(int channel)Removes all listeners on a specific channelvoidremoveListeners(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 onlisteners- 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 onlisteners- 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 receivedpacket- the packet that should handle
-
-