org.lastbamboo.common.stun.server
Class AbstractStunServer

java.lang.Object
  extended by org.lastbamboo.common.stun.server.AbstractStunServer
All Implemented Interfaces:
EventListener, StunServer, org.littleshoot.mina.common.IoServiceListener
Direct Known Subclasses:
TcpStunServer, UdpStunServer

public abstract class AbstractStunServer
extends Object
implements StunServer, org.littleshoot.mina.common.IoServiceListener

Implementation of a STUN server.


Field Summary
protected  org.littleshoot.mina.filter.codec.ProtocolCodecFactory codecFactory
           
protected  org.littleshoot.mina.common.IoHandler ioHandler
           
protected  String threadName
           
 
Constructor Summary
AbstractStunServer(org.littleshoot.mina.filter.codec.ProtocolCodecFactory codecFactory, org.littleshoot.mina.common.IoHandler ioHandler, String threadName)
          Creates a new STUN server.
 
Method Summary
protected abstract  void bind(InetSocketAddress bindAddress)
           
 InetSocketAddress getBoundAddress()
          Gets the address the server is bound to.
 void serviceActivated(org.littleshoot.mina.common.IoService service, SocketAddress serviceAddress, org.littleshoot.mina.common.IoHandler handler, org.littleshoot.mina.common.IoServiceConfig config)
           
 void serviceDeactivated(org.littleshoot.mina.common.IoService service, SocketAddress serviceAddress, org.littleshoot.mina.common.IoHandler handler, org.littleshoot.mina.common.IoServiceConfig config)
           
 void sessionCreated(org.littleshoot.mina.common.IoSession session)
           
 void sessionDestroyed(org.littleshoot.mina.common.IoSession session)
           
 void start()
          Starts the server on the default STUN port.
 void start(InetSocketAddress bindAddress)
          Starts the server, binding to the specified address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.lastbamboo.common.stun.server.StunServer
addIoServiceListener, close
 

Field Detail

threadName

protected final String threadName

codecFactory

protected final org.littleshoot.mina.filter.codec.ProtocolCodecFactory codecFactory

ioHandler

protected final org.littleshoot.mina.common.IoHandler ioHandler
Constructor Detail

AbstractStunServer

public AbstractStunServer(org.littleshoot.mina.filter.codec.ProtocolCodecFactory codecFactory,
                          org.littleshoot.mina.common.IoHandler ioHandler,
                          String threadName)
Creates a new STUN server.

Parameters:
codecFactory - The factory for creating STUN codecs.
ioHandler - The IO handler, often a demuxing handler that demultiplexes STUN with the media protocol.
threadName - The name of the thread to use.
Method Detail

start

public void start()
           throws IOException
Description copied from interface: StunServer
Starts the server on the default STUN port.

Specified by:
start in interface StunServer
Throws:
IOException - If we cannot bind to the port.

start

public void start(InetSocketAddress bindAddress)
           throws IOException
Description copied from interface: StunServer
Starts the server, binding to the specified address. If the argument is null, this will choose an available port to bind to.

Specified by:
start in interface StunServer
Parameters:
bindAddress - The address to bind to.
Throws:
IOException - If we cannot bind to the specified address, even when this is null and we choose it randomly.

bind

protected abstract void bind(InetSocketAddress bindAddress)
                      throws IOException
Throws:
IOException

getBoundAddress

public InetSocketAddress getBoundAddress()
Description copied from interface: StunServer
Gets the address the server is bound to.

Specified by:
getBoundAddress in interface StunServer
Returns:
The address the server is bound to.

serviceActivated

public void serviceActivated(org.littleshoot.mina.common.IoService service,
                             SocketAddress serviceAddress,
                             org.littleshoot.mina.common.IoHandler handler,
                             org.littleshoot.mina.common.IoServiceConfig config)
Specified by:
serviceActivated in interface org.littleshoot.mina.common.IoServiceListener

serviceDeactivated

public void serviceDeactivated(org.littleshoot.mina.common.IoService service,
                               SocketAddress serviceAddress,
                               org.littleshoot.mina.common.IoHandler handler,
                               org.littleshoot.mina.common.IoServiceConfig config)
Specified by:
serviceDeactivated in interface org.littleshoot.mina.common.IoServiceListener

sessionCreated

public void sessionCreated(org.littleshoot.mina.common.IoSession session)
Specified by:
sessionCreated in interface org.littleshoot.mina.common.IoServiceListener

sessionDestroyed

public void sessionDestroyed(org.littleshoot.mina.common.IoSession session)
Specified by:
sessionDestroyed in interface org.littleshoot.mina.common.IoServiceListener


Copyright © 2013 LittleShoot. All Rights Reserved.