Class MediaProxySession
java.lang.Object
java.lang.Thread
org.jivesoftware.openfire.mediaproxy.MediaProxySession
- All Implemented Interfaces:
Runnable
,DatagramListener
,ProxyCandidate
- Direct Known Subclasses:
RelaySession
A media proxy session enables two clients to exchange UDP traffic. Each client connects to
a UDP port and then the proxy is responsible for exchanging traffic. Each session uses
a total of four ports: two for traffic exchange, and two control ports.
- Author:
- Thiago Camargo
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.jivesoftware.openfire.mediaproxy.Channel
protected org.jivesoftware.openfire.mediaproxy.Channel
protected org.jivesoftware.openfire.mediaproxy.Channel
protected org.jivesoftware.openfire.mediaproxy.Channel
protected InetAddress
protected InetAddress
protected InetAddress
protected int
protected int
protected int
protected int
protected DatagramSocket
protected DatagramSocket
protected DatagramSocket
protected DatagramSocket
protected Thread
protected Thread
protected Thread
protected Thread
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAgentListener
(SessionListener sessionListener) Adds a listener for Session eventsvoid
Removes every Session events listenersboolean
datagramReceived
(DatagramPacket datagramPacket) Implement DatagramListener to timestamp last packet arrivedvoid
Dispatch Stop EventGet the agent creator.protected int
Obtain a free port with a nested control port we can use.getHostA()
Get the Host A IPgetHostB()
Get the Host B IPGet localhost of the Sessionint
Get the localport that listen for Host A Packetsint
Get the localport that listen for Host B PacketsgetPass()
Get the pass of this Session A pass can be used to authorize an Session modificationint
getPortA()
Get the Port A IPint
getPortB()
Get the Port B IPgetSID()
Get the ID of the Sessionlong
Get last packet arrived timestampvoid
removeAgentListener
(SessionListener sessionListener) Removes an Session events listenervoid
run()
Thread override methodvoid
sendFromPortA
(String host, int port) void
sendFromPortB
(String host, int port) void
setHostA
(InetAddress hostA) Set the Host A IPvoid
setHostB
(InetAddress hostB) Set the Host B IPvoid
setPortA
(int portA) Set port A valuevoid
setPortB
(int portB) Set port B valuevoid
Stop the SessionMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jivesoftware.openfire.mediaproxy.ProxyCandidate
start
-
Field Details
-
localAddress
-
hostA
-
hostB
-
portA
protected int portA -
portB
protected int portB -
localPortA
protected int localPortA -
localPortB
protected int localPortB -
socketA
-
socketAControl
-
socketB
-
socketBControl
-
channelAtoB
protected org.jivesoftware.openfire.mediaproxy.Channel channelAtoB -
channelAtoBControl
protected org.jivesoftware.openfire.mediaproxy.Channel channelAtoBControl -
channelBtoA
protected org.jivesoftware.openfire.mediaproxy.Channel channelBtoA -
channelBtoAControl
protected org.jivesoftware.openfire.mediaproxy.Channel channelBtoAControl -
threadAtoB
-
threadAtoBControl
-
threadBtoA
-
threadBtoAControl
-
-
Constructor Details
-
MediaProxySession
public MediaProxySession(String id, String creator, String localAddress, String hostA, int portA, String hostB, int portB, int minPort, int maxPort) Creates a new static UDP channel between Host A and Host B.- Parameters:
id
- of the Session (Could be a Jingle session ID)creator
- the session creator name or descriptionlocalAddress
- the localhost IP that will listen for UDP packetshostA
- the hostname or IP of the point A of the ChannelportA
- the port number point A of the ChannelhostB
- the hostname or IP of the point B of the ChannelportB
- the port number point B of the ChannelminPort
- the minimal port value to be used by the servermaxPort
- the maximun port value to be used by the server
-
-
Method Details
-
getFreePort
protected int getFreePort()Obtain a free port with a nested control port we can use.- Returns:
- A free port number.
-
getSID
Get the ID of the Session- Specified by:
getSID
in interfaceProxyCandidate
- Returns:
- the ID of the session
-
getPass
Get the pass of this Session A pass can be used to authorize an Session modification- Specified by:
getPass
in interfaceProxyCandidate
-
getCreator
Get the agent creator. This field is open to MediaProxy users and just can be set in constructor.- Returns:
- the session creator name or description
-
getTimestamp
public long getTimestamp()Get last packet arrived timestamp- Returns:
- TimeStamp in Millis
-
run
public void run()Thread override method -
stopAgent
public void stopAgent()Stop the Session- Specified by:
stopAgent
in interfaceProxyCandidate
-
getLocalhost
Get localhost of the Session- Specified by:
getLocalhost
in interfaceProxyCandidate
- Returns:
- the localhost of the session
-
getHostA
Get the Host A IP- Specified by:
getHostA
in interfaceProxyCandidate
- Returns:
- the host A ip
-
getHostB
Get the Host B IP- Specified by:
getHostB
in interfaceProxyCandidate
- Returns:
- the host B ip
-
setPortA
public void setPortA(int portA) Set port A value- Specified by:
setPortA
in interfaceProxyCandidate
- Parameters:
portA
- the port number for A
-
setPortB
public void setPortB(int portB) Set port B value- Specified by:
setPortB
in interfaceProxyCandidate
- Parameters:
portB
- the port number for B
-
setHostA
Set the Host A IP- Specified by:
setHostA
in interfaceProxyCandidate
- Parameters:
hostA
- the host for A
-
setHostB
Set the Host B IP- Specified by:
setHostB
in interfaceProxyCandidate
- Parameters:
hostB
- the host for B
-
getPortA
public int getPortA()Get the Port A IP- Specified by:
getPortA
in interfaceProxyCandidate
- Returns:
- the port for A
-
getPortB
public int getPortB()Get the Port B IP- Specified by:
getPortB
in interfaceProxyCandidate
- Returns:
- the port for B
-
getLocalPortA
public int getLocalPortA()Get the localport that listen for Host A Packets- Specified by:
getLocalPortA
in interfaceProxyCandidate
- Returns:
- the local port for A
-
getLocalPortB
public int getLocalPortB()Get the localport that listen for Host B Packets- Specified by:
getLocalPortB
in interfaceProxyCandidate
- Returns:
- the local port for B
-
sendFromPortA
- Specified by:
sendFromPortA
in interfaceProxyCandidate
-
sendFromPortB
- Specified by:
sendFromPortB
in interfaceProxyCandidate
-
datagramReceived
Implement DatagramListener to timestamp last packet arrived- Specified by:
datagramReceived
in interfaceDatagramListener
- Parameters:
datagramPacket
- the datagram packet- Returns:
- ?
-
addAgentListener
Adds a listener for Session events- Parameters:
sessionListener
- the sessionj listener to add
-
removeAgentListener
Removes an Session events listener- Parameters:
sessionListener
- the session listener to remove
-
clearAgentListeners
public void clearAgentListeners()Removes every Session events listeners -
dispatchAgentStopped
public void dispatchAgentStopped()Dispatch Stop Event
-