[docs]defcreate_mqtt(broker_addr:tuple|dict|str,client_id:str,codec:Codec=None,clock:Clock=None,inbox_topic:str|None=None,copy_internal_messages:bool=False,**kwargs,):""" This method is called to instantiate an MQTT container :param broker_addr: The address of the broker this container will connect to. it has to be a tuple of (host, port). :param client_id: The id of the MQTT Client :param codec: Defines the codec to use. Defaults to JSON :param clock: The clock that the scheduler of the agent should be based on. Defaults to the AsyncioClock :param inbox_topic: Default subscription to the a specific MQTT topic :param copy_internal_messages: Explicitly copy internal messages. Defaults to False :return: The instance of a MQTTContainer """ifcodecisNone:codec=JSON()ifclockisNone:clock=AsyncioClock()returnMQTTContainer(client_id=client_id,broker_addr=broker_addr,clock=clock,codec=codec,inbox_topic=inbox_topic,copy_internal_messages=copy_internal_messages,**kwargs,)
[docs]defcreate_tcp(addr:str|tuple[str,int],codec:Codec=None,clock:Clock=None,copy_internal_messages:bool=False,auto_port=False,**kwargs:dict[str,Any],)->Container:""" This method is called to instantiate a tcp container :param addr: The address to use. it has to be a tuple of (host, port). :param codec: Defines the codec to use. Defaults to JSON :param clock: The clock that the scheduler of the agent should be based on. Defaults to the AsyncioClock :param copy_internal_messages: Explicitly copy internal messages. Defaults to False :param auto_port: Whether you want to let the operating system pick the port. Defaults to False :return: The instance of a TCPContainer """ifcodecisNone:codec=JSON()ifclockisNone:clock=AsyncioClock()ifisinstance(addr,str):host,port=addr.split(":")addr=(host,int(port))# initialize TCPContainerreturnTCPContainer(addr=(addr[0],0)ifauto_portelseaddr,codec=codec,clock=clock,copy_internal_messages=copy_internal_messages,**kwargs,)