com.cycling74.net
Class UdpReceiver

java.lang.Object
  extended by com.cycling74.net.UdpReceiver
All Implemented Interfaces:
java.lang.Runnable

public class UdpReceiver
extends java.lang.Object
implements java.lang.Runnable

UDP receiver. An internal Callback is maintained from a specified method name and object. The specified method must take an array of Atoms as its only argument. When data is received, it is translated to an array of Atoms and passed to the specified method. When a UdpReceiver is no longer needed its close() method should be called.


Constructor Summary
UdpReceiver()
          Creates a UdpReceiver.
UdpReceiver(int port)
          Creates a UdpReceiver with specified port.
 
Method Summary
 void close()
          Should be called when the UdpReceiver is no longer needed.
 int getPort()
          Get the port.
 void run()
           
 void setActive(boolean b)
          Turns the UdpReceiver on or off.
 void setCallback(java.lang.Object toCallIn, java.lang.String methodName)
          Set the data receiving callback method.
 void setDebugString(java.lang.String s)
          Sets the debug string.
 void setPort(int port)
          Set the port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UdpReceiver

public UdpReceiver(int port)
Creates a UdpReceiver with specified port.

Parameters:
port - the port to listen to

UdpReceiver

public UdpReceiver()
Creates a UdpReceiver. Port must be specified before it will receive anything.

Method Detail

setPort

public void setPort(int port)
Set the port.

Parameters:
port - the port to listen to.

getPort

public int getPort()
Get the port.

Returns:
the port being listened to

setDebugString

public void setDebugString(java.lang.String s)
Sets the debug string.

Parameters:
s - the String to be output as part of the

setActive

public void setActive(boolean b)
Turns the UdpReceiver on or off.

Parameters:
b - true turns it on

run

public void run()
Specified by:
run in interface java.lang.Runnable

setCallback

public void setCallback(java.lang.Object toCallIn,
                        java.lang.String methodName)
Set the data receiving callback method. The method must take an array of Atoms as its only argument.

Parameters:
toCallIn - the object that contains the method
methodName - the name of the method to call

close

public void close()
Should be called when the UdpReceiver is no longer needed.