|
|||||||||
Home >> All >> edu >> mit >> media >> hive >> [ agent overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |
edu.mit.media.hive.agent
Class EventSendingHelper

java.lang.Objectedu.mit.media.hive.agent.EventSendingHelper
- All Implemented Interfaces:
- edu.mit.media.hive.support.async.AsyncResultListener
- public class EventSendingHelper
- extends java.lang.Object
- implements edu.mit.media.hive.support.async.AsyncResultListener
- extends java.lang.Object
Helper class for EventSendingAgent interface; agent implementations
can delegate methods to this class.
This class maintains a list of listeners for events, as well as a
count of events it has sent. When broadcastEvent
is
called by the client, the EventSendingHelper delivers the message
to all current listeners. By default these messages are sent
asynchronously.
Please be careful if creating Hive objects to send by hand -- use
the getCount() method in this object to determine the value that
the count field in the HiveEvent constructor can use. This is not
the recommended way to send events -- it is preferred programmers
use the Object methods instead unless they need to send custom
HiveEvents
Field Summary | |
protected AgentImpl |
agent
Agent we're helping |
protected java.util.Hashtable |
agentsToEventMaskWrappers
|
private int |
count
Count of events we've broadcast. |
protected java.util.Vector |
localListeners
List of listeners (type Agent) we're sending events to. |
protected edu.mit.media.hive.cell.Cell |
myCell
Cell we're on |
protected java.util.Vector |
remoteListeners
List of listeners (type Agent) we're sending events to. |
private boolean |
sendSync
Should we send synchronously? |
Constructor Summary | |
EventSendingHelper(AgentImpl agentHelped,
edu.mit.media.hive.cell.Cell server)
Construct a helper for an event sending agent to delegate to. |
Method Summary | |
void |
addListener(EventReceivingAgent newListener)
Add a listener to the list. |
void |
addListener(EventReceivingAgent newListener,
long eventMask)
Add a listener to ourselves, but only send them events that correspond to a certain event mask |
void |
asyncFinished(edu.mit.media.hive.support.async.AsyncResult ar)
Used for a call back from the AsyncResult when it has a result. |
void |
broadcastEvent(java.lang.Object data)
Helper method to send event data to all remoteListeners. |
void |
broadcastEventLocally(java.lang.Object data)
This broadcasts this event only to the local listenres |
void |
broadcastEventRemotely(java.lang.Object data)
This broadcasts this event only to the remote remoteListeners |
void |
broadcastEventTo(edu.mit.media.hive.event.HiveEvent event,
java.util.Vector recipients)
If you are broadcasting a specific event, it is possible that the event was constructed with an event mask -- if you are using the vectors that we are keeping, then we need to check to see whether we should be filtering this event |
void |
broadcastEventTo(java.lang.Object data,
java.util.Vector recipients)
This broadcasts a specific piece of data to a list of specific remoteListeners This method does not check the event mask of the agents which will possible receive it because we are sending out a hive event with an unspecified event mask, so all listeners will get it |
int |
getEventCount(Agent sender)
Get a count of how many events have fired. |
java.util.Vector |
getListeners()
return the list of agent subscribing to us -- i'm not clear what is the difference beteween this and getSubscribers() |
java.util.Vector |
getLocalListeners()
return the list of all the subscribers which are local to me (on the same cell) |
java.util.Vector |
getRemoteListeners()
return a list of all the subsribers which are remote to me (not on the same cell as me) |
boolean |
isSynchronous()
Are events currently being sent synchronously? |
void |
removeListener(EventReceivingAgent sender)
Remove a listener from the event queue. |
void |
sendEventToAgent(java.lang.Object data,
EventReceivingAgent recipient)
Helper method to send event data to a particular agent. |
protected void |
sendHiveEventToAgent(edu.mit.media.hive.event.HiveEvent event,
EventMaskWrapper emw)
This will do a test on the hive event and the event mask wrapper to make sure the event mask will let through the event before sending |
void |
sendHiveEventToAgent(edu.mit.media.hive.event.HiveEvent eventObject,
EventReceivingAgent recipient)
Method used to send a HiveEvent to a particular receiver. |
void |
setSynchronous(boolean sync)
Set the mode of event delivery (synchronous or asynchronous). |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
agent
protected AgentImpl agent
- Agent we're helping
myCell
protected edu.mit.media.hive.cell.Cell myCell
- Cell we're on
remoteListeners
protected java.util.Vector remoteListeners
- List of listeners (type Agent) we're sending events to.
localListeners
protected java.util.Vector localListeners
- List of listeners (type Agent) we're sending events to.
agentsToEventMaskWrappers
protected java.util.Hashtable agentsToEventMaskWrappers
count
private int count
- Count of events we've broadcast.
sendSync
private boolean sendSync
- Should we send synchronously?
Constructor Detail |
EventSendingHelper
public EventSendingHelper(AgentImpl agentHelped, edu.mit.media.hive.cell.Cell server)
- Construct a helper for an event sending agent to delegate to.
Method Detail |
getListeners
public java.util.Vector getListeners()
- return the list of agent subscribing to us -- i'm not clear
what is the difference beteween this and getSubscribers()
getRemoteListeners
public java.util.Vector getRemoteListeners()
- return a list of all the subsribers which are remote to me (not
on the same cell as me)
getLocalListeners
public java.util.Vector getLocalListeners()
- return the list of all the subscribers which are local to me
(on the same cell)
addListener
public void addListener(EventReceivingAgent newListener)
- Add a listener to the list. EventSendingAgents can delegate to
this method to us.
addListener
public void addListener(EventReceivingAgent newListener, long eventMask)
- Add a listener to ourselves, but only send them events that
correspond to a certain event mask
removeListener
public void removeListener(EventReceivingAgent sender)
- Remove a listener from the event queue. EventSendingAgents can
delegate to this method to us
getEventCount
public int getEventCount(Agent sender)
- Get a count of how many events have fired. EventSendingAgents
can delegate to this method to us. This is not guaranteed to
be an exact count -- only that the count is increasing.
broadcastEvent
public void broadcastEvent(java.lang.Object data)
- Helper method to send event data to all remoteListeners. This
method sends events asynchronously, if this.isAsynchronous().
This means that event delivery is not guaranteed. For more
details, see server.AsyncSender.
broadcastEventRemotely
public void broadcastEventRemotely(java.lang.Object data)
- This broadcasts this event only to the remote remoteListeners
broadcastEventLocally
public void broadcastEventLocally(java.lang.Object data)
- This broadcasts this event only to the local listenres
broadcastEventTo
public void broadcastEventTo(java.lang.Object data, java.util.Vector recipients)
- This broadcasts a specific piece of data to a list of specific
remoteListeners
This method does not check the event mask of the agents which
will possible receive it because we are sending out a hive
event with an unspecified event mask, so all listeners will get
it
broadcastEventTo
public void broadcastEventTo(edu.mit.media.hive.event.HiveEvent event, java.util.Vector recipients)
- If you are broadcasting a specific event, it is possible that
the event was constructed with an event mask -- if you are
using the vectors that we are keeping, then we need to check to
see whether we should be filtering this event
sendEventToAgent
public void sendEventToAgent(java.lang.Object data, EventReceivingAgent recipient)
- Helper method to send event data to a particular agent. This
method sends events asynchronously, if this.isAsynchronous().
This means that event delivery is not guaranteed. For more
details, see server.AsyncSender.
sendHiveEventToAgent
protected void sendHiveEventToAgent(edu.mit.media.hive.event.HiveEvent event, EventMaskWrapper emw)
- This will do a test on the hive event and the event mask
wrapper to make sure the event mask will let through the event
before sending
sendHiveEventToAgent
public void sendHiveEventToAgent(edu.mit.media.hive.event.HiveEvent eventObject, EventReceivingAgent recipient)
- Method used to send a HiveEvent to a particular receiver.
This is the guts of event transmission, handles asynchronous messages
and error conditions.
setSynchronous
public void setSynchronous(boolean sync)
- Set the mode of event delivery (synchronous or asynchronous).
Asynchronous events are more efficient and more robust, but are
also inherently unreliable.
isSynchronous
public boolean isSynchronous()
- Are events currently being sent synchronously?
asyncFinished
public void asyncFinished(edu.mit.media.hive.support.async.AsyncResult ar)
- Description copied from interface:
edu.mit.media.hive.support.async.AsyncResultListener
- Used for a call back from the AsyncResult when it has a result.
This is the same method whether or not it is an exception or a
regular result
- Specified by:
asyncFinished
in interfaceedu.mit.media.hive.support.async.AsyncResultListener
|
|||||||||
Home >> All >> edu >> mit >> media >> hive >> [ agent overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: ![]() ![]() ![]() |
DETAIL: FIELD | CONSTR | METHOD |