"""Module containing a LocalBroker thatenables local communication with subscriptions."""fromtypingimportUnionfrom.brokerimportBrokerfromagentlib.coreimportdatamodels
[docs]classLocalBroker(Broker):"""Local broker class which sends messages"""
[docs]defsend(self,agent_id:str,message:Union[bytes,datamodels.AgentVariable]):""" Send the given message to all clients if the source matches. Args: agent_id: Source to match message: The message to send Returns: """forclientinself._clients:forsubinclient.subscriptions:ifsub==agent_id:client.receive(message)