Class AsyncFilterManager
- All Implemented Interfaces:
AsynchronousManager
By using AsyncMarker.incrementProcessingDelay(), a packet can be delayed without having to block the
processing thread.
-
Constructor Summary
ConstructorsConstructorDescriptionAsyncFilterManager(ErrorReporter reporter, ProtocolScheduler scheduler) Initialize a asynchronous filter manager. -
Method Summary
Modifier and TypeMethodDescriptionvoidRemove listeners, close threads and transmit every delayed packet.Construct a asynchronous marker with all the default values.createAsyncMarker(long timeoutDelta) Construct an async marker with the given sending priority delta and timeout delta.voidenqueueSyncPacket(PacketEvent syncPacket, AsyncMarker asyncMarker) Enqueue a packet for asynchronous processing.Get an immutable set of every registered asynchronous packet listener.Retrieve the default error reporter.Retrieve the protocol manager.Retrieve the default packet stream.com.comphenix.protocol.async.PacketProcessingQueuegetProcessingQueue(PacketEvent packet) Retrieve the processing queue this packet belongs to.Retrieves a immutable set containing the types of the received client packets that will be observed by the asynchronous listeners.Retrieve the current task scheduler.com.comphenix.protocol.async.PacketSendingQueuegetSendingQueue(PacketEvent packet) Retrieve the sending queue this packet belongs to.com.comphenix.protocol.async.PacketSendingQueuegetSendingQueue(PacketEvent packet, boolean createNew) Retrieve the sending queue this packet belongs to.Retrieves a immutable set containing the types of the sent server packets that will be observed by the asynchronous listeners.Get a immutable set of every registered timeout handler.booleanhasAsynchronousListeners(PacketEvent packet) Determine if a given synchronous packet has asynchronous listeners.registerAsyncHandler(PacketListener listener) Registers an asynchronous packet handler.registerAsyncHandler(PacketListener listener, boolean autoInject) Registers an asynchronous packet handler.voidregisterTimeoutHandler(PacketListener listener) Register a synchronous listener that handles packets when they time out.voidremovePlayer(org.bukkit.entity.Player player) Clean up after a given player has logged out.voidsendProcessedPackets(int tickCounter, boolean onMainThread) Send any due packets, or clean up packets that have expired.voidsetManager(ProtocolManager manager) Set the associated protocol manager.voidsignalFreeProcessingSlot(PacketEvent packet, boolean onMainThread) Signal that a packet has finished processing.voidsignalPacketTransmission(PacketEvent packet) Signal that a packet is ready to be transmitted.voidUnregisters and closes the given asynchronous handler.voidunregisterAsyncHandler(PacketListener listener) Unregisters and closes the first asynchronous handler associated with the given listener.voidunregisterAsyncHandlers(org.bukkit.plugin.Plugin plugin) Unregisters every asynchronous handler associated with this plugin.voidunregisterTimeoutHandler(PacketListener listener) Unregisters a given timeout listener.
-
Constructor Details
-
AsyncFilterManager
Initialize a asynchronous filter manager.Internal method. Retrieve the global asynchronous manager from the protocol manager instead.
- Parameters:
reporter- - desired error reporter.scheduler- - task scheduler.
-
-
Method Details
-
getManager
Retrieve the protocol manager.- Returns:
- The protocol manager.
-
setManager
Set the associated protocol manager.- Parameters:
manager- - the new manager.
-
registerAsyncHandler
Description copied from interface:AsynchronousManagerRegisters an asynchronous packet handler.Use
AsyncMarker.incrementProcessingDelay()to delay a packet until its ready to be transmitted.To start listening asynchronously, pass the getListenerLoop() runnable to a different thread.
- Specified by:
registerAsyncHandlerin interfaceAsynchronousManager- Parameters:
listener- - the packet listener that will receive these asynchronous events.- Returns:
- An asynchronous handler.
-
registerTimeoutHandler
Description copied from interface:AsynchronousManagerRegister a synchronous listener that handles packets when they time out.- Specified by:
registerTimeoutHandlerin interfaceAsynchronousManager- Parameters:
listener- - synchronous listener that will handle timed out packets.
-
getTimeoutHandlers
Description copied from interface:AsynchronousManagerGet a immutable set of every registered timeout handler.- Specified by:
getTimeoutHandlersin interfaceAsynchronousManager- Returns:
- Set of every registered timeout handler.
-
getAsyncHandlers
Description copied from interface:AsynchronousManagerGet an immutable set of every registered asynchronous packet listener.- Specified by:
getAsyncHandlersin interfaceAsynchronousManager- Returns:
- Set of every asynchronous packet listener.
-
registerAsyncHandler
Registers an asynchronous packet handler.Use
AsyncMarker.incrementProcessingDelay()to delay a packet until its ready to be transmitted.To start listening asynchronously, pass the getListenerLoop() runnable to a different thread.
Asynchronous events will only be executed if a synchronous listener with the same packets is registered. If you already have a synchronous event, call this method with autoInject set to FALSE.
- Parameters:
listener- - the packet listener that will receive these asynchronous events.autoInject- - whether or not to automatically create the corresponding synchronous listener,- Returns:
- An asynchronous handler.
-
unregisterTimeoutHandler
Description copied from interface:AsynchronousManagerUnregisters a given timeout listener.- Specified by:
unregisterTimeoutHandlerin interfaceAsynchronousManager- Parameters:
listener- - the timeout listener to unregister.
-
unregisterAsyncHandler
Description copied from interface:AsynchronousManagerUnregisters and closes the first asynchronous handler associated with the given listener.- Specified by:
unregisterAsyncHandlerin interfaceAsynchronousManager- Parameters:
listener- - asynchronous listener
-
unregisterAsyncHandler
Description copied from interface:AsynchronousManagerUnregisters and closes the given asynchronous handler.- Specified by:
unregisterAsyncHandlerin interfaceAsynchronousManager- Parameters:
handler- - asynchronous handler.
-
unregisterAsyncHandlers
public void unregisterAsyncHandlers(org.bukkit.plugin.Plugin plugin) Description copied from interface:AsynchronousManagerUnregisters every asynchronous handler associated with this plugin.- Specified by:
unregisterAsyncHandlersin interfaceAsynchronousManager- Parameters:
plugin- - the original plugin.
-
enqueueSyncPacket
Enqueue a packet for asynchronous processing.- Parameters:
syncPacket- - synchronous packet event.asyncMarker- - the asynchronous marker to use.
-
getReceivingTypes
Description copied from interface:AsynchronousManagerRetrieves a immutable set containing the types of the received client packets that will be observed by the asynchronous listeners.- Specified by:
getReceivingTypesin interfaceAsynchronousManager- Returns:
- Every filtered client packet.
-
getSendingTypes
Description copied from interface:AsynchronousManagerRetrieves a immutable set containing the types of the sent server packets that will be observed by the asynchronous listeners.- Specified by:
getSendingTypesin interfaceAsynchronousManager- Returns:
- Every filtered server packet.
-
getScheduler
Retrieve the current task scheduler.- Returns:
- Current task scheduler.
-
hasAsynchronousListeners
Description copied from interface:AsynchronousManagerDetermine if a given synchronous packet has asynchronous listeners.- Specified by:
hasAsynchronousListenersin interfaceAsynchronousManager- Parameters:
packet- - packet to test.- Returns:
- TRUE if it does, FALSE otherwise.
-
createAsyncMarker
Construct a asynchronous marker with all the default values.- Returns:
- Asynchronous marker.
-
createAsyncMarker
Construct an async marker with the given sending priority delta and timeout delta.- Parameters:
timeoutDelta- - how long (in ms) until the packet expire.- Returns:
- An async marker.
-
getPacketStream
Description copied from interface:AsynchronousManagerRetrieve the default packet stream.- Specified by:
getPacketStreamin interfaceAsynchronousManager- Returns:
- Default packet stream.
-
getErrorReporter
Description copied from interface:AsynchronousManagerRetrieve the default error reporter.- Specified by:
getErrorReporterin interfaceAsynchronousManager- Returns:
- Default reporter.
-
cleanupAll
public void cleanupAll()Description copied from interface:AsynchronousManagerRemove listeners, close threads and transmit every delayed packet.- Specified by:
cleanupAllin interfaceAsynchronousManager
-
signalPacketTransmission
Description copied from interface:AsynchronousManagerSignal that a packet is ready to be transmitted.This should only be called if
AsyncMarker.incrementProcessingDelay()has been called previously.- Specified by:
signalPacketTransmissionin interfaceAsynchronousManager- Parameters:
packet- - packet to signal.
-
getSendingQueue
Retrieve the sending queue this packet belongs to.- Parameters:
packet- - the packet.- Returns:
- The server or client sending queue the packet belongs to.
-
getSendingQueue
public com.comphenix.protocol.async.PacketSendingQueue getSendingQueue(PacketEvent packet, boolean createNew) Retrieve the sending queue this packet belongs to.- Parameters:
packet- - the packet.createNew- - if TRUE, create a new queue if it hasn't already been created.- Returns:
- The server or client sending queue the packet belongs to.
-
getProcessingQueue
Retrieve the processing queue this packet belongs to.- Parameters:
packet- - the packet.- Returns:
- The server or client sending processing the packet belongs to.
-
signalFreeProcessingSlot
Signal that a packet has finished processing. Tries to process further packets if a processing slot is still free.- Parameters:
packet- - packet to signal.onMainThread- whether or not this method was run by the main thread.
-
sendProcessedPackets
public void sendProcessedPackets(int tickCounter, boolean onMainThread) Send any due packets, or clean up packets that have expired.- Parameters:
tickCounter- Tick counteronMainThread- Whether or not to execute on the main thread
-
removePlayer
public void removePlayer(org.bukkit.entity.Player player) Clean up after a given player has logged out.- Parameters:
player- - the player that has just logged out.
-