Class AsyncMarker
- All Implemented Interfaces:
Serializable,Comparable<AsyncMarker>
Asynchronous listeners can use this to set packet timeout or transmission order.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault number of packets to skip.static final intDefault number of milliseconds until a packet will rejected. -
Method Summary
Modifier and TypeMethodDescriptionintbooleanlongRetrieve the time the packet was initially queued for asynchronous processing.Retrieve the current asynchronous listener handler.longRetrieve the desired sending order after processing has completed.longRetrieve the order the packet was originally transmitted.Retrieve the packet stream responsible for transmitting this packet.intRetrieve the number of times a packet must be signalled to be done before it's sent.Processing lock used to synchronize access to the parent PacketEvent and PacketContainer.longRetrieve the sending index when the packet was queued.longRetrieve the time the packet will be forcefully rejected.intRetrieve the current worker ID.booleanDetermine if this packet has expired.booleanhasExpired(long currentTime) Determine if this packet has expired given this time.inthashCode()intIncrement the number of times the current packet must be signalled as done before its transmitted.booleanDetermine if the asynchronous handling should be cancelled.booleanisMinecraftAsync(PacketEvent event) Determine if Minecraft allows asynchronous processing of this packet.booleanRetrieve whether or not this packet has been processed by the async listeners.booleanisQueued()Whether or not this packet is or has been queued for processing.booleanRetrieve whether or not this packet has already been sent.voidsetAsyncCancelled(boolean asyncCancelled) Set whether or not the asynchronous handling should be cancelled.voidsetNewSendingIndex(long newSendingIndex) Sets the desired sending order after processing has completed.voidsetPacketStream(PacketStream packetStream) Sets the output packet stream responsible for transmitting this packet.voidsetProcessingLock(Object processingLock) voidsetTimeout(long timeout) Set the time the packet will be forcefully rejected.
-
Field Details
-
DEFAULT_TIMEOUT_DELTA
public static final int DEFAULT_TIMEOUT_DELTADefault number of milliseconds until a packet will rejected.- See Also:
-
DEFAULT_SENDING_DELTA
public static final int DEFAULT_SENDING_DELTADefault number of packets to skip.- See Also:
-
-
Method Details
-
getInitialTime
public long getInitialTime()Retrieve the time the packet was initially queued for asynchronous processing.- Returns:
- The initial time in number of milliseconds since 01.01.1970 00:00.
-
getTimeout
public long getTimeout()Retrieve the time the packet will be forcefully rejected.- Returns:
- The time to reject the packet, in milliseconds since 01.01.1970 00:00.
-
setTimeout
public void setTimeout(long timeout) Set the time the packet will be forcefully rejected.- Parameters:
timeout- - time to reject the packet, in milliseconds since 01.01.1970 00:00.
-
getOriginalSendingIndex
public long getOriginalSendingIndex()Retrieve the order the packet was originally transmitted.- Returns:
- The original packet index.
-
getNewSendingIndex
public long getNewSendingIndex()Retrieve the desired sending order after processing has completed.Higher sending order means lower priority.
- Returns:
- Desired sending order.
-
setNewSendingIndex
public void setNewSendingIndex(long newSendingIndex) Sets the desired sending order after processing has completed.Higher sending order means lower priority.
- Parameters:
newSendingIndex- - new packet send index.
-
getPacketStream
Retrieve the packet stream responsible for transmitting this packet.- Returns:
- The packet stream.
-
setPacketStream
Sets the output packet stream responsible for transmitting this packet.- Parameters:
packetStream- - new output packet stream.
-
isProcessed
public boolean isProcessed()Retrieve whether or not this packet has been processed by the async listeners.- Returns:
- TRUE if it has been processed, FALSE otherwise.
-
incrementProcessingDelay
public int incrementProcessingDelay()Increment the number of times the current packet must be signalled as done before its transmitted.This is useful if an asynchronous listener is waiting for further information before the packet can be sent to the user. A packet listener MUST eventually call
AsyncFilterManager.signalPacketTransmission(PacketEvent), even if the packet is cancelled, after this method is called.It is recommended that processing outside a packet listener is wrapped in a synchronized block using the
getProcessingLock()method.- Returns:
- The new processing delay.
-
getProcessingDelay
public int getProcessingDelay()Retrieve the number of times a packet must be signalled to be done before it's sent.- Returns:
- Number of processing delays.
-
isQueued
public boolean isQueued()Whether or not this packet is or has been queued for processing.- Returns:
- TRUE if it has, FALSE otherwise.
-
getQueuedSendingIndex
public long getQueuedSendingIndex()Retrieve the sending index when the packet was queued.- Returns:
- Queued sending index.
-
getProcessingLock
Processing lock used to synchronize access to the parent PacketEvent and PacketContainer.This lock is automatically acquired for every asynchronous packet listener. It should only be used to synchronize access to a PacketEvent if it's processing has been delayed.
- Returns:
- A processing lock.
-
setProcessingLock
-
isTransmitted
public boolean isTransmitted()Retrieve whether or not this packet has already been sent.- Returns:
- TRUE if it has been sent before, FALSE otherwise.
-
hasExpired
public boolean hasExpired()Determine if this packet has expired.- Returns:
- TRUE if it has, FALSE otherwise.
-
hasExpired
public boolean hasExpired(long currentTime) Determine if this packet has expired given this time.- Parameters:
currentTime- - the current time in milliseconds since 01.01.1970 00:00.- Returns:
- TRUE if it has, FALSE otherwise.
-
isAsyncCancelled
public boolean isAsyncCancelled()Determine if the asynchronous handling should be cancelled.- Returns:
- TRUE if it should, FALSE otherwise.
-
setAsyncCancelled
public void setAsyncCancelled(boolean asyncCancelled) Set whether or not the asynchronous handling should be cancelled.This is only relevant during the synchronous processing. Asynchronous listeners should use the normal cancel-field to cancel a PacketEvent.
- Parameters:
asyncCancelled- - TRUE to cancel it, FALSE otherwise.
-
getListenerHandler
Retrieve the current asynchronous listener handler.- Returns:
- Asychronous listener handler, or NULL if this packet is not asynchronous.
-
getWorkerID
public int getWorkerID()Retrieve the current worker ID.- Returns:
- Current worker ID.
-
isMinecraftAsync
Determine if Minecraft allows asynchronous processing of this packet.- Parameters:
event- - packet event- Returns:
- TRUE if it does, FALSE otherwise.
- Throws:
FieldAccessException- If determining fails for some reasaon
-
compareTo
- Specified by:
compareToin interfaceComparable<AsyncMarker>
-
equals
-
hashCode
public int hashCode()
-