Class BroadcastHandler

java.lang.Object
com.tnsai.protocols.handlers.AbstractProtocolHandler
com.tnsai.protocols.handlers.BroadcastHandler
All Implemented Interfaces:
ProtocolHandler

public final class BroadcastHandler extends AbstractProtocolHandler
Handler for broadcast messaging (one-to-many). Maintains topic subscribers and broadcasts messages to all.
  • Constructor Details

    • BroadcastHandler

      public BroadcastHandler(Transport transport, String topic)
  • Method Details

    • subscribe

      public void subscribe(String agentId)
      Subscribes an agent to the topic.
      Parameters:
      agentId - Agent ID
    • unsubscribe

      public void unsubscribe(String agentId)
      Unsubscribes an agent from the topic.
      Parameters:
      agentId - Agent ID
    • send

      public com.tnsai.protocols.models.Message send(com.tnsai.protocols.models.Message message) throws ProtocolHandler.HandlerException
      Description copied from interface: ProtocolHandler
      Sends a message using this protocol.
      Parameters:
      message - Message to send
      Returns:
      Response message (null for async protocols)
      Throws:
      ProtocolHandler.HandlerException - if send fails
    • sendAsync

      public void sendAsync(com.tnsai.protocols.models.Message message, ProtocolHandler.HandlerCallback callback)
      Description copied from interface: ProtocolHandler
      Sends a message asynchronously.
      Parameters:
      message - Message to send
      callback - Callback for response
    • getTopic

      public String getTopic()
      Gets the topic for this handler.
      Returns:
      Topic name
    • getSubscriberCount

      public int getSubscriberCount()
      Gets subscriber count for the topic.
      Returns:
      Number of subscribers