Class ChannelManager
java.lang.Object
io.agentscope.harness.agent.gateway.ChannelManager
Registry and lifecycle manager for
Channel adapters. Provides outbound dispatch so the
gateway can deliver proactive messages (e.g. subagent announces) through the correct channel.
Lifecycle
register(Channel)— add a channel to the registryinitAll(Gateway)— inject the gateway into all registered channelsstartAll()— start all channels (connect to external transports)stopAll()— stop all channels and release resources
Outbound delivery
deliver(OutboundAddress, List) looks up the target channel by OutboundAddress.channelId() and delegates to Channel.deliver(OutboundAddress, List).-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns an unmodifiable snapshot of all registered channel ids.voiddeliver(OutboundAddress address, List<io.agentscope.core.message.Msg> messages) Delivers proactive outbound messages through the channel identified byOutboundAddress.channelId().Returns an unmodifiable snapshot of all registered channels.getChannel(String channelId) Returns the channel registered under the given id, if any.voidInjects the gateway into all registered channels viaChannel.init(Gateway).booleanWhetherstartAll()has been called.voidRegisters a channel adapter.voidstartAll()Starts all registered channels.voidstopAll()Stops all registered channels and clears the registry.booleanunregister(String channelId) Stops and removes the channel registered underchannelId, if any.
-
Constructor Details
-
ChannelManager
public ChannelManager()
-
-
Method Details
-
register
Registers a channel adapter. If a channel with the sameChannel.channelId()is already registered, it is replaced. -
unregister
Stops and removes the channel registered underchannelId, if any. Returnstruewhen a channel was removed,falsewhen no channel was registered under that id. -
getChannel
Returns the channel registered under the given id, if any. -
channelIds
Returns an unmodifiable snapshot of all registered channel ids. -
getAllChannels
Returns an unmodifiable snapshot of all registered channels. -
initAll
Injects the gateway into all registered channels viaChannel.init(Gateway). Called once during bootstrap beforestartAll(). -
startAll
public void startAll()Starts all registered channels. Channels that fail to start are logged but do not abort. -
stopAll
public void stopAll()Stops all registered channels and clears the registry. -
isStarted
public boolean isStarted()WhetherstartAll()has been called. -
deliver
Delivers proactive outbound messages through the channel identified byOutboundAddress.channelId(). If the target channel is not registered, the messages are dropped with a warning log.- Parameters:
address- the delivery targetmessages- the messages to deliver
-