Atavism Version 2018.1AGIS API

atavism.msgsys
Class MessageTrigger

java.lang.Object
  extended by atavism.msgsys.MessageTrigger
Direct Known Subclasses:
PerceptionTrigger

public abstract class MessageTrigger
extends java.lang.Object

Run code on publisher when message matches our subscription. Sub-class to implement your own behavior.

Message triggers are associated with a specific subscription. The trigger is instantiated (via marshalling) on each publisher. When the publisher sends a message matching the subscription, the subscription's trigger is run. First, match(atavism.msgsys.Message) is called to determine if the trigger should be run. If match() returns true, then trigger() is run with the message and matching filter.

Sub-classes should use Java keyword "transient" for data members that should not be copied from subscriber to publisher.


Constructor Summary
MessageTrigger()
          No-arg constructor required for marshalling.
 
Method Summary
 boolean match(Message message)
          True if the trigger should be run for this message.
abstract  void setFilter(IFilter filter)
          Set the trigger's filter.
abstract  void trigger(Message message, IFilter filter, MessageAgent agent)
          Called when message matches the filter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageTrigger

public MessageTrigger()
No-arg constructor required for marshalling.

Method Detail

setFilter

public abstract void setFilter(IFilter filter)
Set the trigger's filter. Required on sub-classes.


match

public boolean match(Message message)
True if the trigger should be run for this message. MessageTrigger.match() always returns true. Over-ride to select which messages to pass to trigger(atavism.msgsys.Message, atavism.msgsys.IFilter, atavism.msgsys.MessageAgent).


trigger

public abstract void trigger(Message message,
                             IFilter filter,
                             MessageAgent agent)
Called when message matches the filter. Required on sub-classes. It is OK to modify message, but the trigger must not "re-send" the message; do not use message in calls to MessageAgent.sendBroadcast() and similar calls. It is OK to modify filter. The message is not re-matched if the message or filter are modified.

Use great care when designing MessageTriggers.

Parameters:
message - The matched message.
filter - The matched filter, the same as passed to setFilter().
agent - The local message agent.


Copyright © 2018 Dragonsan Studios Sp. z o.o.