Openfire 3.6.0 Javadoc

org.jivesoftware.openfire.mediaproxy
Class MediaProxySession

java.lang.Object
  extended by java.lang.Thread
      extended by org.jivesoftware.openfire.mediaproxy.MediaProxySession
All Implemented Interfaces:
Runnable, DatagramListener, ProxyCandidate
Direct Known Subclasses:
RelaySession

public abstract class MediaProxySession
extends Thread
implements ProxyCandidate, DatagramListener

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
protected  org.jivesoftware.openfire.mediaproxy.Channel channelAtoB
           
protected  org.jivesoftware.openfire.mediaproxy.Channel channelAtoBControl
           
protected  org.jivesoftware.openfire.mediaproxy.Channel channelBtoA
           
protected  org.jivesoftware.openfire.mediaproxy.Channel channelBtoAControl
           
protected  InetAddress hostA
           
protected  InetAddress hostB
           
protected  InetAddress localAddress
           
protected  int localPortA
           
protected  int localPortB
           
protected  int portA
           
protected  int portB
           
protected  DatagramSocket socketA
           
protected  DatagramSocket socketAControl
           
protected  DatagramSocket socketB
           
protected  DatagramSocket socketBControl
           
protected  Thread threadAtoB
           
protected  Thread threadAtoBControl
           
protected  Thread threadBtoA
           
protected  Thread threadBtoAControl
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
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.
 
Method Summary
 void addAgentListener(SessionListener sessionListener)
          Adds a listener for Session events
 void clearAgentListeners()
          Removes every Session events listeners
 boolean datagramReceived(DatagramPacket datagramPacket)
          Implement DatagramListener to timestamp last packet arrived
 void dispatchAgentStopped()
          Dispatch Stop Event
 String getCreator()
          Get the agent creator.
protected  int getFreePort()
          Obtain a free port with a nested control port we can use.
 InetAddress getHostA()
          Get the Host A IP
 InetAddress getHostB()
          Get the Host B IP
 InetAddress getLocalhost()
          Get localhost of the Session
 int getLocalPortA()
          Get the localport that listen for Host A Packets
 int getLocalPortB()
          Get the localport that listen for Host B Packets
 String getPass()
          Get the pass of this Session A pass can be used to authorize an Session modification
 int getPortA()
          Get the Port A IP
 int getPortB()
          Get the Port B IP
 String getSID()
          Get the ID of the Session
 long getTimestamp()
          Get last packet arrived timestamp
 void removeAgentListener(SessionListener sessionListener)
          Removes an Session events listener
 void run()
          Thread override method
 void sendFromPortA(String host, int port)
           
 void sendFromPortB(String host, int port)
           
 void setHostA(InetAddress hostA)
          Set the Host A IP
 void setHostB(InetAddress hostB)
          Set the Host B IP
 void setPortA(int portA)
          Set port A value
 void setPortB(int portB)
          Set port B value
 void stopAgent()
          Stop the Session
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jivesoftware.openfire.mediaproxy.ProxyCandidate
start
 

Field Detail

localAddress

protected InetAddress localAddress

hostA

protected InetAddress hostA

hostB

protected InetAddress hostB

portA

protected int portA

portB

protected int portB

localPortA

protected int localPortA

localPortB

protected int localPortB

socketA

protected DatagramSocket socketA

socketAControl

protected DatagramSocket socketAControl

socketB

protected DatagramSocket socketB

socketBControl

protected DatagramSocket 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

protected Thread threadAtoB

threadAtoBControl

protected Thread threadAtoBControl

threadBtoA

protected Thread threadBtoA

threadBtoAControl

protected Thread threadBtoAControl
Constructor Detail

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 description
localAddress - the localhost IP that will listen for UDP packets
hostA - the hostname or IP of the point A of the Channel
portA - the port number point A of the Channel
hostB - the hostname or IP of the point B of the Channel
portB - the port number point B of the Channel
minPort - the minimal port value to be used by the server
maxPort - the maximun port value to be used by the server
Method Detail

getFreePort

protected int getFreePort()
Obtain a free port with a nested control port we can use.

Returns:
A free port number.

getSID

public String getSID()
Get the ID of the Session

Specified by:
getSID in interface ProxyCandidate
Returns:
the ID of the session

getPass

public String getPass()
Get the pass of this Session A pass can be used to authorize an Session modification

Specified by:
getPass in interface ProxyCandidate

getCreator

public String 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

Specified by:
run in interface Runnable
Overrides:
run in class Thread

stopAgent

public void stopAgent()
Stop the Session

Specified by:
stopAgent in interface ProxyCandidate

getLocalhost

public InetAddress getLocalhost()
Get localhost of the Session

Specified by:
getLocalhost in interface ProxyCandidate
Returns:
the localhost of the session

getHostA

public InetAddress getHostA()
Get the Host A IP

Specified by:
getHostA in interface ProxyCandidate
Returns:
the host A ip

getHostB

public InetAddress getHostB()
Get the Host B IP

Specified by:
getHostB in interface ProxyCandidate
Returns:
the host B ip

setPortA

public void setPortA(int portA)
Set port A value

Specified by:
setPortA in interface ProxyCandidate
Parameters:
portA - the port number for A

setPortB

public void setPortB(int portB)
Set port B value

Specified by:
setPortB in interface ProxyCandidate
Parameters:
portB - the port number for B

setHostA

public void setHostA(InetAddress hostA)
Set the Host A IP

Specified by:
setHostA in interface ProxyCandidate
Parameters:
hostA - the host for A

setHostB

public void setHostB(InetAddress hostB)
Set the Host B IP

Specified by:
setHostB in interface ProxyCandidate
Parameters:
hostB - the host for B

getPortA

public int getPortA()
Get the Port A IP

Specified by:
getPortA in interface ProxyCandidate
Returns:
the port for A

getPortB

public int getPortB()
Get the Port B IP

Specified by:
getPortB in interface ProxyCandidate
Returns:
the port for B

getLocalPortA

public int getLocalPortA()
Get the localport that listen for Host A Packets

Specified by:
getLocalPortA in interface ProxyCandidate
Returns:
the local port for A

getLocalPortB

public int getLocalPortB()
Get the localport that listen for Host B Packets

Specified by:
getLocalPortB in interface ProxyCandidate
Returns:
the local port for B

sendFromPortA

public void sendFromPortA(String host,
                          int port)
Specified by:
sendFromPortA in interface ProxyCandidate

sendFromPortB

public void sendFromPortB(String host,
                          int port)
Specified by:
sendFromPortB in interface ProxyCandidate

datagramReceived

public boolean datagramReceived(DatagramPacket datagramPacket)
Implement DatagramListener to timestamp last packet arrived

Specified by:
datagramReceived in interface DatagramListener
Parameters:
datagramPacket -
Returns:
?

addAgentListener

public void addAgentListener(SessionListener sessionListener)
Adds a listener for Session events

Parameters:
sessionListener -

removeAgentListener

public void removeAgentListener(SessionListener sessionListener)
Removes an Session events listener

Parameters:
sessionListener -

clearAgentListeners

public void clearAgentListeners()
Removes every Session events listeners


dispatchAgentStopped

public void dispatchAgentStopped()
Dispatch Stop Event


Openfire 3.6.0 Javadoc

Copyright © 2003-2008 Jive Software.