Class DefaultPacketListenerRegistry
- java.lang.Object
-
- de.dytanic.cloudnet.driver.network.protocol.DefaultPacketListenerRegistry
-
- All Implemented Interfaces:
IPacketListenerRegistry
public final class DefaultPacketListenerRegistry extends java.lang.Object implements IPacketListenerRegistry
Default IPacketListenerRegistry implementation
-
-
Constructor Summary
Constructors Constructor Description DefaultPacketListenerRegistry()DefaultPacketListenerRegistry(IPacketListenerRegistry parent)
-
Method Summary
All Methods Instance Methods Concrete 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
-
-
-
Constructor Detail
-
DefaultPacketListenerRegistry
public DefaultPacketListenerRegistry()
-
DefaultPacketListenerRegistry
public DefaultPacketListenerRegistry(IPacketListenerRegistry parent)
-
-
Method Detail
-
addListener
public void addListener(int channel, IPacketListener... listeners)Description copied from interface:IPacketListenerRegistryAdds a new listeners for packets that are received on a specific channel- Specified by:
addListenerin interfaceIPacketListenerRegistry- Parameters:
channel- the channel, that the listener should listen onlisteners- the listeners that should be add for this channel
-
removeListener
public void removeListener(int channel, IPacketListener... listeners)Description copied from interface:IPacketListenerRegistryRemoves the listeners if they are registered on this listener registry. If the listeners items are null, then it should ignored- Specified by:
removeListenerin interfaceIPacketListenerRegistry- Parameters:
channel- the channel, that the listener should listen onlisteners- the listeners, that should remove on this registry
-
removeListeners
public void removeListeners(int channel)
Description copied from interface:IPacketListenerRegistryRemoves all listeners on a specific channel- Specified by:
removeListenersin interfaceIPacketListenerRegistry- Parameters:
channel- the channel id from that all listeners should remove
-
removeListeners
public void removeListeners(java.lang.ClassLoader classLoader)
Description copied from interface:IPacketListenerRegistryRemove all listeners that are registered on the specific classLoader instance- Specified by:
removeListenersin interfaceIPacketListenerRegistry- Parameters:
classLoader- the classLoader, from that all listeners that are contained on the registry should remove
-
hasListener
public boolean hasListener(java.lang.Class<? extends IPacketListener> clazz)
Description copied from interface:IPacketListenerRegistryReturns true if the a specific listener class is contain in this registry- Specified by:
hasListenerin interfaceIPacketListenerRegistry
-
removeListeners
public void removeListeners()
Description copied from interface:IPacketListenerRegistryRemoves all listeners by all channel from the registry- Specified by:
removeListenersin interfaceIPacketListenerRegistry
-
getChannels
public java.util.Collection<java.lang.Integer> getChannels()
Description copied from interface:IPacketListenerRegistryReturns all channelIds that the packet listener registry has listeners registered- Specified by:
getChannelsin interfaceIPacketListenerRegistry
-
getListeners
public java.util.Collection<IPacketListener> getListeners()
Description copied from interface:IPacketListenerRegistryReturns all listeners by all channels from the registry- Specified by:
getListenersin interfaceIPacketListenerRegistry
-
handlePacket
public void handlePacket(INetworkChannel channel, IPacket packet)
Description copied from interface:IPacketListenerRegistryHandles an incoming packet and invoke all listeners that are registered in this registry- Specified by:
handlePacketin interfaceIPacketListenerRegistry- Parameters:
channel- the channel, from that the packet was receivedpacket- the packet that should handle
-
getParent
public IPacketListenerRegistry getParent()
Description copied from interface:IPacketListenerRegistryReturns the parent PacketListenerRegistry implementation instance if exists- Specified by:
getParentin interfaceIPacketListenerRegistry
-
-