Compare commits

...

2 Commits

Author SHA1 Message Date
MagicBot c2152432ce Comment cleanup 2024-04-26 15:00:03 -04:00
MagicBot 9348852e2c Comment cleanup 2024-04-26 14:57:02 -04:00
+7 -8
View File
@@ -21,8 +21,8 @@ import java.util.regex.Pattern;
// All outgoing Protocol messages to the player are managed through the MessageDispatcher.class.
// All incoming Protocol messages from the player are managed by the Protocol.class.
//
// A DispatchMessage is configured then wrapped in a Dispatch for a distribution list.
// A Dispatch can be submitted to the Dispatcher from any thread.
// A DispatchMessage is configured (Protocol messsage) and wrapped in a Dispatch (distribution list).
// A Dispatch can be submitted to the MessageDispatcher for delivery from any thread.
//
// Dispatches are interleaved between channels. This is to ensure
// a combat or movement message is not delayed by spam clicking a
@@ -30,13 +30,10 @@ import java.util.regex.Pattern;
public class MessageDispatcher implements Runnable {
// Instance variables
// Class variables
private static final ConcurrentLinkedQueue<Dispatch>[] _messageQueue = new ConcurrentLinkedQueue[DispatchChannel.values().length];
private static final LinkedBlockingQueue<Boolean> _blockingQueue = new LinkedBlockingQueue<>();
// Class variables
public static volatile long[] messageCount = new long[DispatchChannel.values().length];
public static LongAdder[] dispatchCount = new LongAdder[DispatchChannel.values().length];
@@ -47,8 +44,6 @@ public class MessageDispatcher implements Runnable {
private final Pattern filterPattern; // Unused, but just in case
private Dispatch messageDispatch;
// Thread constructor
public MessageDispatcher() {
// Create new FIFO queues for this network thread
@@ -94,6 +89,10 @@ public class MessageDispatcher implements Runnable {
public static void send(Dispatch messageDispatch, DispatchChannel dispatchChannel) {
// A Dispatch should be borrowed from the local cache.
// They will automatically be released back to the queue
// once delivered.
// Don't queue up empty dispatches!
if (messageDispatch.player == null)