public StructuredShortcutConnectionOverlord(Node n)
{
_sync = new Object();
lock( _sync ) {
_node = n;
#if BRUNET_SIMULATOR
_rand = Node.SimulatorRandom;
#else
_rand = new Random();
#endif
_last_connection_time = DateTime.UtcNow;
/**
* Every heartbeat we assess the trimming situation.
* If we have excess edges and it has been more than
* _trim_wait_time heartbeats then we trim.
*/
_last_retry_time = DateTime.UtcNow;
_current_retry_interval = _DEFAULT_RETRY_INTERVAL;
/**
* Information related to the target selector feature.
* Includes statistics such as trim rate and connection lifetimes.
*/
_target_selector = new DefaultTargetSelector();
_last_optimize_time = DateTime.UtcNow;
_sum_con_lifetime = 0.0;
_start_time = DateTime.UtcNow;
_trim_count = 0;
_shortcuts = 0;
/*
* Register event handlers after everything else is set
*/
//Listen for connection events:
_node.ConnectionTable.DisconnectionEvent += DisconnectHandler;
_node.ConnectionTable.ConnectionEvent += ConnectHandler;
_node.HeartBeatEvent += CheckState;
_node.HeartBeatEvent += CheckConnectionOptimality;
}
}