|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectgraphServer.UDPReceiver
public class UDPReceiver
A UDPReceiver acts as a server where packets can be received and passed to objects which are interested in handling the packets the server receives.
UDPListener
Field Summary | |
---|---|
static int |
maxDataPackets
|
static int |
theport
|
static int |
timeBetween
|
Constructor Summary | |
---|---|
UDPReceiver()
Construct the UDPReceiver sets up the port, UDP socket and threads for handling incoming packets. |
|
UDPReceiver(int port)
Construct the UDPReceiver sets up the port, UDP socket and threads for handling incoming packets. |
Method Summary | |
---|---|
void |
addListener(UDPListener listener)
Adds a UDP Listener to the list of listeners. |
protected void |
consumeData()
Removes the first packet (earliest) from the list of received data and notifies any listeners of the packet. |
java.lang.String |
getDebugInfo()
Returns a String with debug information about the UDP Receiver. |
protected void |
notifyReceiveMessage(java.net.DatagramPacket packet)
Notifies all listeners on a new thread that a message has been received. |
protected void |
putData(java.net.DatagramPacket packet)
Puts the most recently received packet at the end of the receivedData list. |
void |
startReceiving()
Starts The thread listening to the UDP socket, and the thread which dispatches packets to any listeners. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int theport
public static final int timeBetween
public static final int maxDataPackets
Constructor Detail |
---|
public UDPReceiver() throws java.net.SocketException
java.net.SocketException
- If there was an error in creating the UDP socket.public UDPReceiver(int port) throws java.net.SocketException
port
- The Port for the socket to use.
java.net.SocketException
- If there was an error in creating the UDP socket.Method Detail |
---|
public void addListener(UDPListener listener)
listener
- The UDP Listener which will handle any incoming messages.UDPListener
protected void notifyReceiveMessage(java.net.DatagramPacket packet)
packet
- the packet to notify listeners about.UDPListener
public void startReceiving()
protected void putData(java.net.DatagramPacket packet)
packet
- Most recently received packet from the UDP socket.protected void consumeData()
public java.lang.String getDebugInfo()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |