Class DynamicAddressChannel
java.lang.Object
org.jivesoftware.openfire.mediaproxy.DynamicAddressChannel
- All Implemented Interfaces:
Runnable,DatagramListener
Listen packets from defined dataSocket and send packets to the defined host.
But also provides a mechanism to dynamic bind host and port implementing DatagramListener methods to
change the host and port values according to the received packets.
- Author:
- Thiago Camargo
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]protected DatagramSocketprotected booleanprotected InetAddressprotected DatagramPacketprotected int -
Constructor Summary
ConstructorsConstructorDescriptionDynamicAddressChannel(DatagramSocket dataSocket, InetAddress host, int port) Default Channel Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(DatagramListener datagramListener) Adds a DatagramListener to the Channelvoidcancel()booleandatagramReceived(DatagramPacket datagramPacket) Implement DatagramListener method.getHost()Get the host that the packet will be sent to.intgetPort()Get the port that the packet will be sent to.voidrelayPacket(DatagramPacket packet) voidremoveListener(DatagramListener datagramListener) Remove a DatagramListener from the ChannelvoidRemove every Listenersvoidrun()Thread override methodprotected voidsetHost(InetAddress host) Set the host that the packet will be sent to.protected voidsetPort(int port) Set the port that the packet will be sent to.
-
Field Details
-
buf
protected byte[] buf -
dataSocket
-
packet
-
enabled
protected boolean enabled -
host
-
port
protected int port
-
-
Constructor Details
-
DynamicAddressChannel
Default Channel Constructor- Parameters:
dataSocket- datasocket to used to send and receive packetshost- default destination host for received packetsport- default destination port for received packets
-
-
Method Details
-
datagramReceived
Implement DatagramListener method. Set the host and port value to the host and port value from the received packet.- Specified by:
datagramReceivedin interfaceDatagramListener- Parameters:
datagramPacket- the received packet- Returns:
- ?
-
getHost
Get the host that the packet will be sent to.- Returns:
- remote host address
-
setHost
Set the host that the packet will be sent to.- Parameters:
host- the host to send the packet to
-
getPort
public int getPort()Get the port that the packet will be sent to.- Returns:
- The remote port number
-
setPort
protected void setPort(int port) Set the port that the packet will be sent to.- Parameters:
port- the port to send the packet to
-
addListener
Adds a DatagramListener to the Channel- Parameters:
datagramListener- the listener to add
-
removeListener
Remove a DatagramListener from the Channel- Parameters:
datagramListener- the listener to remove
-
removeListeners
public void removeListeners()Remove every Listeners -
cancel
public void cancel() -
run
public void run()Thread override method -
relayPacket
-