org.elkoserver.foundation.net
Class ConnectionBase

java.lang.Object
  extended by org.elkoserver.foundation.net.ConnectionBase
All Implemented Interfaces:
Connection
Direct Known Subclasses:
HTTPSessionConnection, RTCPSessionConnection, TCPConnection

public abstract class ConnectionBase
extends Object
implements Connection

Base class providing common internals implementation for various types of Connection objects.


Field Summary
protected static Object theCloseMarker
          Token to put on send queue to signal close of connection.
 
Constructor Summary
protected ConnectionBase(NetworkManager mgr)
          Constructor.
 
Method Summary
protected  void connectionDied(Throwable reason)
          Cope with loss of a connection.
protected  void enqueueHandlerFactory(MessageHandlerFactory handlerFactory)
          Enqueue a task to invoke a message handler factory to produce a message handler for this connection.
protected  void enqueueReceivedMessage(Object message)
          Enqueue a received message for processing.
 int id()
          Identify this connection for logging purposes.
 void setDebugMode(boolean mode)
          Turn on or off debug features on this connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.elkoserver.foundation.net.Connection
close, sendMsg
 

Field Detail

theCloseMarker

protected static final Object theCloseMarker
Token to put on send queue to signal close of connection.

Constructor Detail

ConnectionBase

protected ConnectionBase(NetworkManager mgr)
Constructor.

Parameters:
mgr - Network manager for this server.
Method Detail

connectionDied

protected void connectionDied(Throwable reason)
Cope with loss of a connection.

Parameters:
reason - Throwable describing why the connection died.

id

public int id()
Identify this connection for logging purposes.

Specified by:
id in interface Connection
Returns:
this connection's ID number.

enqueueReceivedMessage

protected void enqueueReceivedMessage(Object message)
Enqueue a received message for processing.

Parameters:
message - The received message.

enqueueHandlerFactory

protected void enqueueHandlerFactory(MessageHandlerFactory handlerFactory)
Enqueue a task to invoke a message handler factory to produce a message handler for this connection.

Parameters:
handlerFactory - Provider of a message handler to process messages received on this connection.

setDebugMode

public void setDebugMode(boolean mode)
Turn on or off debug features on this connection. This is an empty implementation so that subclasses only need to implement this feature if they wish to.

Specified by:
setDebugMode in interface Connection
Parameters:
mode - If true, turn debug mode on; if false, turn it off.