|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object groupmgmt.impl.BeaconReceiver
The BeaconReceiver class; Listens for MemberBeacons and notifies the registered BeaconListeners via a BeaconEvent.
Based on the beacon package by Ali Hazemi.
BeaconServer
,
BeaconEvent
Nested Class Summary | |
private class |
BeaconReceiver.BeaconEventQueue
Private Thread class to do the notifying. |
private class |
BeaconReceiver.ReceiverListener
Private Thread class to do the listening. |
Field Summary | |
private BeaconReceiver.BeaconEventQueue |
beaconEventQueue
A separate thread to notify listeners of the BeaconEvents. |
private java.util.Vector |
beaconListeners
A Vector list of the BeaconListeners to notify of new beacons. |
private java.net.InetAddress |
localHost
Reference to this host's address, used to check if a beacon is our own or from another host. |
private java.net.InetAddress |
mcastAddress
The multicast address to listen to. |
private int |
mcastPort
The multicast port to listen to. |
private java.net.MulticastSocket |
mSocket
The multicast socket used to broadcast the beacons. |
private boolean |
receiveOwn
Determines whether this receiver should receive its own beacons. |
private BeaconReceiver.ReceiverListener |
receiverThread
The thread that listens on the multicast address for incoming beacons. |
private boolean |
started
Keeps track of whether this BeaconReceiver has started. |
Constructor Summary | |
BeaconReceiver(java.net.InetAddress mcastAddress,
int mcastPort)
Creates a BeaconReceiver that does not receive its own beacons. |
|
BeaconReceiver(java.net.InetAddress mcastAddress,
int mcastPort,
boolean receiveOwn)
Create a BeaconReceiver. |
Method Summary | |
void |
addBeaconListener(BeaconListener beaconListener)
Add a BeaconListener to be notified of new BeaconEvents. |
java.net.InetAddress |
getMcastAddress()
Accessor to the multicast address. |
int |
getMcastPort()
Accessor to the multicast port. |
private void |
log(java.lang.String msg)
For testing. |
BeaconEvent |
makeBeaconEvent(MemberBeacon beacon)
Allows construction of a new BeaconEvent whose source is the BeaconReceiver class. |
void |
notifyBeaconListeners(BeaconEvent evt)
Notifies listeners of a BeaconEvent |
void |
removeBeaconListener(BeaconListener beaconListener)
Stop sending BeaconEvents to a BeaconListener. |
void |
start()
Starts this beacon receiver. |
void |
stop()
Stops this beacon reciever from receiving beacons. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private BeaconReceiver.ReceiverListener receiverThread
private java.util.Vector beaconListeners
private java.net.InetAddress mcastAddress
private int mcastPort
private java.net.InetAddress localHost
private java.net.MulticastSocket mSocket
private boolean receiveOwn
private boolean started
private BeaconReceiver.BeaconEventQueue beaconEventQueue
Constructor Detail |
public BeaconReceiver(java.net.InetAddress mcastAddress, int mcastPort, boolean receiveOwn)
mcastAddress
- The multicast address to listen for beacons on.mcastPort
- The port to listen for beacons on.receiveOwn
- True if this receiver should notify Listeners of
beacons sent from this host.public BeaconReceiver(java.net.InetAddress mcastAddress, int mcastPort)
Method Detail |
public java.net.InetAddress getMcastAddress()
public int getMcastPort()
public void addBeaconListener(BeaconListener beaconListener)
beaconListener
- The listener to be notified.public void removeBeaconListener(BeaconListener beaconListener)
public void notifyBeaconListeners(BeaconEvent evt)
evt
- The BeaconEvent to send out.public BeaconEvent makeBeaconEvent(MemberBeacon beacon)
beacon
- The beacon to be encapsulated in the event.
public void start()
public void stop()
private void log(java.lang.String msg)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |