Package com.tnsai.protocols.handlers
Class BroadcastHandler
java.lang.Object
com.tnsai.protocols.handlers.AbstractProtocolHandler
com.tnsai.protocols.handlers.BroadcastHandler
- All Implemented Interfaces:
ProtocolHandler
Handler for broadcast messaging (one-to-many).
Maintains topic subscribers and broadcasts messages to all.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.tnsai.protocols.handlers.ProtocolHandler
ProtocolHandler.HandlerCallback, ProtocolHandler.HandlerException -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGets subscriber count for the topic.getTopic()Gets the topic for this handler.com.tnsai.protocols.models.Messagesend(com.tnsai.protocols.models.Message message) Sends a message using this protocol.voidsendAsync(com.tnsai.protocols.models.Message message, ProtocolHandler.HandlerCallback callback) Sends a message asynchronously.voidSubscribes an agent to the topic.voidunsubscribe(String agentId) Unsubscribes an agent from the topic.Methods inherited from class com.tnsai.protocols.handlers.AbstractProtocolHandler
getTransport, isRunning, start, stop
-
Constructor Details
-
BroadcastHandler
-
-
Method Details
-
subscribe
Subscribes an agent to the topic.- Parameters:
agentId- Agent ID
-
unsubscribe
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:ProtocolHandlerSends 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:ProtocolHandlerSends a message asynchronously.- Parameters:
message- Message to sendcallback- Callback for response
-
getTopic
Gets the topic for this handler.- Returns:
- Topic name
-
getSubscriberCount
public int getSubscriberCount()Gets subscriber count for the topic.- Returns:
- Number of subscribers
-