public void Run(params string[] addresses)
{
using (m_context = NetMQContext.Create())
{
var subscriber = Connect(addresses);
if (subscriber == null)
throw new Exception("cannot connect to eny of the endpoints");
// timeout timer, when heartbeat was not arrived for 5 seconds
m_timeoutTimer = new NetMQTimer(TimeSpan.FromSeconds(5));
m_timeoutTimer.Elapsed += (sender, args) =>
{
// timeout happend, first dispose existing subscriber
subscriber.Dispose();
m_poller.RemoveSocket(subscriber);
// connect again
subscriber = Connect(addresses);
if (subscriber == null)
throw new Exception("cannot connect to eny of the endpoints");
m_poller.AddSocket(subscriber);
};
m_poller = new Poller(subscriber);
m_poller.AddTimer(m_timeoutTimer);
m_poller.PollTillCancelled();
}
}