Selecting Messages¶
With PADE is possible to implement message filters in a simple way using the Filter class.
from pade.acl.filters import Filter
How to filter messages usinf filters module.¶
For example, in the following message:
from pade.acl.messages import ACLMessage
from pade.acl.aid import AID
message = ACLMessage(ACLMessage.INFORM)
message.set_protocol(ACLMessage.FIPA_REQUEST_PROTOCOL)
message.set_sender(AID('remetente'))
message.add_receiver(AID('destinatario'))
We can make this filter:
from pade.acl.filters import Filter
f.performative = ACLMessage.REQUEST
In a Ipython session it’s possible to see the filter action:
>> f.filter(message)
False
We can fit the filter to another condition:
f.performative = ACLMessage.INFORM
Placing again the filter in the message:
>> f.filter(message)
True