using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TradeIdeas.TIQData
{
public class ConnectionMaster : IDisposable
{
///
/// This is what automatically reconnects, when required.
///
private ConnectionLifeCycle _connectionLifeCycle;
///
/// This lets you set the username and related items for the connection.
///
public LoginManager LoginManager { get; private set; }
///
/// This provides ping statistics, if required.
/// This is sometimes required to keep the connection alive.
///
public PingManager PingManager { get; private set; }
///
/// This is a convenent way to send messages. It helps manage retries, among
/// other things.
///
public SendManager SendManager { get; private set; }
///
/// This provides limited access to the connection life cycle. The main program
/// can use this to offer connection instructions or to monitor the status of the
/// connection.
///
public ConnectionBase ConnectionBase { get { return _connectionLifeCycle; } }
public TraditionalAlertsManager TraditionalAlertsManager { get; private set; }
///
/// Constructor for the connection master.
///
public ConnectionMaster()
{
_connectionLifeCycle = new ConnectionLifeCycle();
// Initialize the login manager before anything else so it will be the first
// one to get callbacks from the connection life cycle. We want to send the
// login command first, before any other commands.
LoginManager = new LoginManager(_connectionLifeCycle);
PingManager = new PingManager(_connectionLifeCycle);
SendManager = new SendManager(_connectionLifeCycle);
TraditionalAlertsManager = new TraditionalAlertsManager(_connectionLifeCycle);
}
///
/// Throw away the resources. Can't use this object again after this.
/// It is safe to call this more than once.
///
public void Dispose()
{
if (null != _connectionLifeCycle)
_connectionLifeCycle.Dispose();
//SoftReset();
// Calling SoftReset from the GUI lead to a deadlock. The thread will
// disconnect the socket soon enough, and that's all we really need.
}
///
/// The destructor calls Dispose().
///
~ConnectionMaster()
{
Dispose();
}
}
}