com.cycling74.net
Class TcpReceiver

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

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

TCP 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 TcpReceiver is no longer needed its close() method should be called. created on 24-May-2004


Constructor Summary
TcpReceiver()
          Creates a TcpReceiver.
TcpReceiver(int port)
          Creates a TcpReceiver with specified port.
TcpReceiver(int port, java.lang.Object toCallIn, java.lang.String methodName)
          Creates a TcpReceiver with specified port, receiving method name, and containing object.
 
Method Summary
 void close()
          Must be called when the TcpReceiver is no longer needed.
 int getPort()
          Gets the port.
 void run()
           
 void setActive(boolean b)
          Turns the receiver on or off.
 void setCallback(java.lang.Object toCallIn, java.lang.String methodName)
          Sets the receiving callback.
 void setDebugString(java.lang.String debugString)
          Set the name of 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

TcpReceiver

public TcpReceiver(int port,
                   java.lang.Object toCallIn,
                   java.lang.String methodName)
Creates a TcpReceiver with specified port, receiving method name, and containing object.

Parameters:
port - the port over which to receive data
toCallIn - the object tnat contains the receivnig method
methodName - the name of the receiving method

TcpReceiver

public TcpReceiver()
Creates a TcpReceiver. Port, receiving method name and containing object must be specified before anything will happen.


TcpReceiver

public TcpReceiver(int port)
Creates a TcpReceiver with specified port. A receiving method name and containing object must be specified before anything will happen.

Parameters:
port -
Method Detail

setActive

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

Parameters:
b - true turns it on

setDebugString

public void setDebugString(java.lang.String debugString)
Set the name of the debug string.

Parameters:
debugString - this String will be part of the message printed to the Max window in the event of a networking failure.

setPort

public void setPort(int port)
Set the port.

Parameters:
port - the port to receive data over

getPort

public int getPort()
Gets the port.

Returns:
the port data is being received over

close

public void close()
Must be called when the TcpReceiver is no longer needed. Should probably be called from your notifyDeleted() method.


run

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

setCallback

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

Parameters:
toCallIn - object that contains the receiving method.
methodName - name of the method to receive data