public class AsyncMarker extends java.lang.Object implements java.io.Serializable, java.lang.Comparable<AsyncMarker>
Asynchronous listeners can use this to set packet timeout or transmission order.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SENDING_DELTA
Default number of packets to skip.
|
static int |
DEFAULT_TIMEOUT_DELTA
Default number of milliseconds until a packet will rejected.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(AsyncMarker o) |
boolean |
equals(java.lang.Object other) |
long |
getInitialTime()
Retrieve the time the packet was initially queued for asynchronous processing.
|
AsyncListenerHandler |
getListenerHandler()
Retrieve the current asynchronous listener handler.
|
long |
getNewSendingIndex()
Retrieve the desired sending order after processing has completed.
|
long |
getOriginalSendingIndex()
Retrieve the order the packet was originally transmitted.
|
PacketStream |
getPacketStream()
Retrieve the packet stream responsible for transmitting this packet.
|
int |
getProcessingDelay()
Retrieve the number of times a packet must be signalled to be done before it's sent.
|
java.lang.Object |
getProcessingLock()
Processing lock used to synchronize access to the parent PacketEvent and PacketContainer.
|
long |
getQueuedSendingIndex()
Retrieve the sending index when the packet was queued.
|
long |
getTimeout()
Retrieve the time the packet will be forcefully rejected.
|
int |
getWorkerID()
Retrieve the current worker ID.
|
boolean |
hasExpired()
Determine if this packet has expired.
|
boolean |
hasExpired(long currentTime)
Determine if this packet has expired given this time.
|
int |
hashCode() |
int |
incrementProcessingDelay()
Increment the number of times the current packet must be signalled as done before its transmitted.
|
boolean |
isAsyncCancelled()
Determine if the asynchronous handling should be cancelled.
|
boolean |
isMinecraftAsync(PacketEvent event)
Determine if Minecraft allows asynchronous processing of this packet.
|
boolean |
isProcessed()
Retrieve whether or not this packet has been processed by the async listeners.
|
boolean |
isQueued()
Whether or not this packet is or has been queued for processing.
|
boolean |
isTransmitted()
Retrieve whether or not this packet has already been sent.
|
void |
setAsyncCancelled(boolean asyncCancelled)
Set whether or not the asynchronous handling should be cancelled.
|
void |
setNewSendingIndex(long newSendingIndex)
Sets the desired sending order after processing has completed.
|
void |
setPacketStream(PacketStream packetStream)
Sets the output packet stream responsible for transmitting this packet.
|
void |
setProcessingLock(java.lang.Object processingLock) |
void |
setTimeout(long timeout)
Set the time the packet will be forcefully rejected.
|
public static final int DEFAULT_TIMEOUT_DELTA
public static final int DEFAULT_SENDING_DELTA
public long getInitialTime()
public long getTimeout()
public void setTimeout(long timeout)
timeout
- - time to reject the packet, in milliseconds since 01.01.1970 00:00.public long getOriginalSendingIndex()
public long getNewSendingIndex()
Higher sending order means lower priority.
public void setNewSendingIndex(long newSendingIndex)
Higher sending order means lower priority.
newSendingIndex
- - new packet send index.public PacketStream getPacketStream()
public void setPacketStream(PacketStream packetStream)
packetStream
- - new output packet stream.public boolean isProcessed()
public int incrementProcessingDelay()
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.
public int getProcessingDelay()
public boolean isQueued()
public long getQueuedSendingIndex()
public java.lang.Object getProcessingLock()
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.
public void setProcessingLock(java.lang.Object processingLock)
public boolean isTransmitted()
public boolean hasExpired()
public boolean hasExpired(long currentTime)
currentTime
- - the current time in milliseconds since 01.01.1970 00:00.public boolean isAsyncCancelled()
public void setAsyncCancelled(boolean asyncCancelled)
This is only relevant during the synchronous processing. Asynchronous listeners should use the normal cancel-field to cancel a PacketEvent.
asyncCancelled
- - TRUE to cancel it, FALSE otherwise.public AsyncListenerHandler getListenerHandler()
public int getWorkerID()
public boolean isMinecraftAsync(PacketEvent event) throws FieldAccessException
FieldAccessException
public int compareTo(AsyncMarker o)
compareTo
in interface java.lang.Comparable<AsyncMarker>
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object