new EventFilter(type, criteria, priorityopt)
Creates a new filter for an event. The filter is a simple detecter for a single set of criteria, but can be chained
together into a firewall-like set of policies as a EventListener filterList
.
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
type |
"allow" | "deny" | Whether this filter is allowing or denying a specific event. |
||||||||||||||||||||||||||
criteria |
object | An Object describing the filter rules Properties
|
||||||||||||||||||||||||||
priority |
number |
<optional> |
100 | The priority of this specific filter. Not useful for a single filter,
but used as part of an EventListener |
Properties:
Name | Type | Description |
---|---|---|
allow |
boolean |
|
deny |
boolean |
|
priority |
number | The relative priority of this filter. Used when part of a EventListener |
criteria |
object | The original criteria object passed to the constructor |
Methods
-
static buildTestFn(criteria) → {function}
-
Builds a test function for the specified criteria
Parameters:
Name Type Description criteria
object The criteria object. See EventFilter constructor for details.
Returns:
function -A function that recieves a single EventBase parameter and returns
true
if the event matches the criteria,false
otherwise -
allowEvent(event) → {boolean}
-
Indicates whether this event should be allowed or not
Parameters:
Name Type Description event
boolean The event to evaluate against the criteria
Returns:
boolean -Returns
true
if the event matches the criteria and should be allowed,false
otherwise -
denyEvent(event) → {boolean}
-
Indicates whether this event should be denied or not
Parameters:
Name Type Description event
boolean The event to evaluate against the criteria
Returns:
boolean -Returns
true
if the event matches the criteria and should be denied,false
otherwise -
matchEvent(event) → {boolean}
-
Indicates whether the event matches the criteria or not
Parameters:
Name Type Description event
EventBase The event to evaluate against the criteria
Returns:
boolean -Returns
true
if the specified event matches the criteria specified in the constructor,false
otherwise