java.lang.Object
net.joseplay.allianceutils.api.pluginComunicate.packets.PacketDispatcher

public class PacketDispatcher extends Object
Responsible for dispatching UniPacket instances across the system.

This class handles:

  • Local packet execution
  • Redis-based cross-server communication
  • Event triggering for send/receive lifecycle

Behavior depends on configuration:

  • If Redis is enabled → packets are sent through Redis
  • If disabled → packets execute locally
  • Constructor Details

    • PacketDispatcher

      public PacketDispatcher(PacketRegistry registry, PacketExecutorRegistry executorRegistry)
      Creates a new dispatcher.
      Parameters:
      registry - packet registry for serialization/deserialization
      executorRegistry - executor registry for handling packets
  • Method Details

    • send

      public void send(UniPacket packet, boolean executeLocal)
      Sends a packet.
      Parameters:
      packet - the packet to send
      executeLocal - whether to execute locally before/without sending to Redis
    • send

      public void send(UniPacket packet)
      Sends a packet and executes it locally by default.
    • receiveFromRedis

      public void receiveFromRedis(String jsonMessage)
      Handles packets received from Redis.
      Parameters:
      jsonMessage - serialized packet data