def send_decline(self, msg_id: int, dialogue_id: int, destination: str, target: int, context=uri.Context()) -> None: """Send a Decline. See :func:`~oef.core.OEFCoreInterface.send_decline`.""" self.logger_debug( "Agent {}: dialogue_id={}, destination={}, msg_id={}, target={}". format(self.public_key, msg_id, dialogue_id, destination, target)) self.output(data={ "msg_id": msg_id, "agent_uri": destination, "send_message": { "dialogue_id": dialogue_id, "destination": destination, "target_uri": context.targetURI.toString(), "source_uri": context.sourceURI.toString(), "fipa": { "target": target, "decline": {} } } }, conn=self.conn)
def send_propose(self, msg_id: int, dialogue_id: int, destination: str, target: int, proposals: PROPOSE_TYPES, context=uri.Context()) -> None: """Send a Propose. See :func:`~oef.core.OEFCoreInterface.send_propose`.""" self.logger_debug( "Agent {}: msg_id={}, dialogue_id={}, destination={}, target={}, proposals={}" .format(self.public_key, msg_id, dialogue_id, destination, target, proposals)) self.output(data={ "msg_id": msg_id, "agent_uri": destination, "send_message": { "dialogue_id": dialogue_id, "destination": destination, "target_uri": context.targetURI.toString(), "source_uri": context.sourceURI.toString(), "fipa": { "target": target, "propose": { ("content" if type(proposals) == bytes else None): proposals, ("proposals" if type(proposals) != bytes else None): { "objects": proposals, }, } } } }, conn=self.conn)
def send_decline(self, msg_id: int, dialogue_id: int, destination: str, target: int, context=uri.Context()): msg = Decline(msg_id, dialogue_id, destination, target, context) self._send(msg.to_pb())
def send_accept(self, msg_id: int, dialogue_id: int, destination: str, target: int, context=uri.Context()): msg = Accept(msg_id, dialogue_id, destination, target, context) self._send(msg.to_pb())
def send_message(self, msg_id: int, dialogue_id: int, destination: str, msg: bytes, context=uri.Context()) -> None: msg = Message(msg_id, dialogue_id, destination, msg, context) self._send(msg.to_pb())
def send_cfp(self, msg_id: int, dialogue_id: int, destination: str, target: int, query: CFP_TYPES, context=uri.Context()): msg = CFP(msg_id, dialogue_id, destination, target, query, context) self._send(msg.to_pb())
def break_fipa_START(self, data): entry_key = "{}:{}:{}".format( data.get('answer_id', -1), data.get('content', {}).get('dialogue_id', -1), data.get('content', {}).get('origin', -1), ) self._context_store[entry_key] = uri.Context() self._context_store[entry_key].update(data.get('target_uri', {}), data.get('source_uri', {}))
def send_propose(self, msg_id: int, dialogue_id: int, destination: str, target: int, proposals: PROPOSE_TYPES, context=uri.Context()): msg = Propose(msg_id, dialogue_id, destination, target, proposals, context) self._send(msg.to_pb())
def send_message(self, msg_id: int, dialogue_id: int, destination: str, msg: bytes, context=uri.Context()) -> None: """Send a simple message. See :func:`~oef.core.OEFCoreInterface.send_message`.""" self.logger_debug( "Agent {}: msg_id={}, dialogue_id={}, destination={}, msg={}". format(self.public_key, msg_id, dialogue_id, destination, msg)) self.output(data={ "msg_id": msg_id, "agent_uri": destination, "send_message": { "dialogue_id": dialogue_id, "destination": destination, "target_uri": context.targetURI.toString(), "source_uri": context.sourceURI.toString(), "content": msg } }, conn=self.conn)
def getContext(self, message_id: int, dialogue_id: int, origin: str): return self._context_store.get( "{}:{}:{}".format(message_id, dialogue_id, origin), uri.Context())