public class DynamicAddressChannel extends Object implements Runnable, DatagramListener
Modifier and Type | Field and Description |
---|---|
protected byte[] |
buf |
protected DatagramSocket |
dataSocket |
protected boolean |
enabled |
protected InetAddress |
host |
protected DatagramPacket |
packet |
protected int |
port |
Constructor and Description |
---|
DynamicAddressChannel(DatagramSocket dataSocket,
InetAddress host,
int port)
Default Channel Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(DatagramListener datagramListener)
Adds a DatagramListener to the Channel
|
void |
cancel() |
boolean |
datagramReceived(DatagramPacket datagramPacket)
Implement DatagramListener method.
|
InetAddress |
getHost()
Get the host that the packet will be sent to.
|
int |
getPort()
Get the port that the packet will be sent to.
|
void |
relayPacket(DatagramPacket packet) |
void |
removeListener(DatagramListener datagramListener)
Remove a DatagramListener from the Channel
|
void |
removeListeners()
Remove every Listeners
|
void |
run()
Thread override method
|
protected void |
setHost(InetAddress host)
Set the host that the packet will be sent to.
|
protected void |
setPort(int port)
Set the port that the packet will be sent to.
|
protected byte[] buf
protected DatagramSocket dataSocket
protected DatagramPacket packet
protected boolean enabled
protected InetAddress host
protected int port
public DynamicAddressChannel(DatagramSocket dataSocket, InetAddress host, int port)
dataSocket
- datasocket to used to send and receive packetshost
- default destination host for received packetsport
- default destination port for received packetspublic boolean datagramReceived(DatagramPacket datagramPacket)
datagramReceived
in interface DatagramListener
datagramPacket
- the received packetpublic InetAddress getHost()
protected void setHost(InetAddress host)
public int getPort()
protected void setPort(int port)
port
- public void addListener(DatagramListener datagramListener)
datagramListener
- public void removeListener(DatagramListener datagramListener)
datagramListener
- public void removeListeners()
public void cancel()
public void relayPacket(DatagramPacket packet)
Copyright © 2003-2008 Jive Software.