NCSA Portfolio
Class MulticastHandler


public class MulticastHandler
extends Handler
implements java.lang.Runnable

A MulticastHandler sends data to a multicast group. The specified Customer object receives data on that multicast group. The Customer is then responsible for dealing with the incoming data. Usage:

Transform3d transform = InterestingObject.getTransform();
TransformGroupCustomer cust = new TransformGroupCustomer(transform);
MulticastHandler multi = new MulticastHandler("", 3120, cust);
multi.transmit(buf, len);
In the example above, we wish to send transform information out on a multicast group, and have all other MulticastHandlers listening on the subnet on port 3120 to set the Transform3D for the object InterestingObject when they receive data.

This is used to allow multiple applications working on a subnet to share the same movements. When one application changes a transform and transmits it, all the other applications will change their transforms to match. This object is generally used when many transformations are happening and the user wishes to have continuously updating displays on all subscribed devices.

See Also:

Constructor Summary
MulticastHandler(java.lang.String subnet, int port, Customer c)
          Create a MulticastHandler
Method Summary
 void begin()
          Initialize the multicast socket, and start the receiving thread.
 void end()
          Stop the receiving thread, and leave the multicast group
 void run()
          The main thread loop that receives incoming data
 void setLoopback(boolean loopback)
          Sets the loopback.
 void transmit(byte[] buf, int len)
          Send data to the multicast group.
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public MulticastHandler(java.lang.String subnet,
                        int port,
                        Customer c)
Create a MulticastHandler
subnet - The multicast subnet to broadcast data
port - The subnet's port to use.
c - The Customer which handles incoming data
Method Detail


public void setLoopback(boolean loopback)
Sets the loopback. If false we don't receive messages we sent.
loopback - Whether we want to see stuff we sent or not.


public void begin()
Initialize the multicast socket, and start the receiving thread.
begin in class Handler


public void end()
Stop the receiving thread, and leave the multicast group
end in class Handler


public void transmit(byte[] buf,
                     int len)
Send data to the multicast group. The data sent is from buffer elements 0 through len.
transmit in class Handler
buf - The outgoing data buffer
len - The length of data to send.


public void run()
The main thread loop that receives incoming data
Specified by:
run in interface java.lang.Runnable

NCSA Portfolio

NCSA Portfolio, Copyright 1997-1999, National Center for Supercomputing Applications, University of Illinois Urbana-Champaign, All Rights Reserved