anon.client
Class DummyTrafficControlChannel

java.lang.Object
  extended by anon.client.AbstractChannel
      extended by anon.client.AbstractControlChannel
          extended by anon.client.DummyTrafficControlChannel
All Implemented Interfaces:
java.lang.Runnable, java.util.Observer

public class DummyTrafficControlChannel
extends AbstractControlChannel
implements java.lang.Runnable, java.util.Observer

This is the implementation for the dummy traffic interval timeout.


Field Summary
private  boolean m_bRun
          Stores whether the internal thread shall work (true) or come to the end (false).
private  java.lang.Object m_internalSynchronization
           
private  long m_interval
          Stores the dummy traffic interval in milliseconds.
private  java.lang.Thread m_threadRunLoop
          Stores the instance of the internal dummy traffic thread.
 
Constructor Summary
DummyTrafficControlChannel(Multiplexer a_multiplexer, IServiceContainer a_serviceContainer)
          Creates a new DummyTrafficControlChannel instance.
 
Method Summary
protected  void processPacketData(byte[] a_packet)
          This method is called by the multiplexer, if a packet is received on the dummy-traffic control channel.
 void run()
          This is the implementation for the dummy traffic thread.
 void setDummyTrafficInterval(int a_interval)
          Changes the dummy traffic interval.
private  void start()
          Starts the internal dummy traffic thread, if it is not already running.
 void stop()
          Holds the internal dummy traffic thread.
 void update(java.util.Observable a_observer, java.lang.Object a_argument)
          This is the Observer implementation.
 
Methods inherited from class anon.client.AbstractControlChannel
getServiceContainer, processReceivedPacket, sendRawMessage
 
Methods inherited from class anon.client.AbstractChannel
createEmptyMixPacket, deleteChannel, multiplexerClosed, sendPacket
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_bRun

private volatile boolean m_bRun
Stores whether the internal thread shall work (true) or come to the end (false).


m_threadRunLoop

private java.lang.Thread m_threadRunLoop
Stores the instance of the internal dummy traffic thread.


m_interval

private long m_interval
Stores the dummy traffic interval in milliseconds. After that interval of inactivity (no traffic) on the connection, a dummy packet is sent.


m_internalSynchronization

private java.lang.Object m_internalSynchronization
Constructor Detail

DummyTrafficControlChannel

public DummyTrafficControlChannel(Multiplexer a_multiplexer,
                                  IServiceContainer a_serviceContainer)
Creates a new DummyTrafficControlChannel instance. The dummy traffic interval is set to -1 (dummy traffic disabled) and the internal thread isn't started. a_multiplexer The multiplexer the new DummyTrafficControlChannel instance belongs to.

Method Detail

run

public void run()
This is the implementation for the dummy traffic thread.

Specified by:
run in interface java.lang.Runnable

stop

public void stop()
Holds the internal dummy traffic thread. This method blocks until the internal thread has come to the end.


update

public void update(java.util.Observable a_observer,
                   java.lang.Object a_argument)
This is the Observer implementation. If a packet is sent or received on the connection, we get a notification from the multiplexer. When we get that notification the dummy traffic timer can be reset. The next dummy traffic packet is generated after the next timeout of the dummy traffic timer if we don't get another notification in the meantime.

Specified by:
update in interface java.util.Observer
Parameters:
a_observer - The observed object (Multiplexer).
a_argument - The notification (PacketProcessedEvent).

setDummyTrafficInterval

public void setDummyTrafficInterval(int a_interval)
Changes the dummy traffic interval.

Parameters:
a_interval - The new dummy traffic interval in milliseconds or -1, if dummy traffic shall be disabled.

processPacketData

protected void processPacketData(byte[] a_packet)
This method is called by the multiplexer, if a packet is received on the dummy-traffic control channel. All received packets are simply ignored.

Specified by:
processPacketData in class AbstractControlChannel
Parameters:
a_packet - The data within the received packet (should be random bytes).

start

private void start()
Starts the internal dummy traffic thread, if it is not already running.