public void Execute(string ipAddress)
{
Manager = new RedisManagerPool(ipAddress);
StartedAt = DateTime.UtcNow;
var q = new Timer { Interval = 1000 };
q.Elapsed += OnInterval;
q.Enabled = true;
using (PubSubServer = new RedisPubSubServer(Manager, Channel)
{
OnStart = () =>
{
Console.WriteLine("OnStart: #" + Interlocked.Increment(ref StartCount));
},
OnHeartbeatSent = () =>
{
Console.WriteLine("OnHeartbeatSent: #" + Interlocked.Increment(ref HeartbeatsSent));
},
OnHeartbeatReceived = () =>
{
Console.WriteLine("OnHeartbeatReceived: #" + Interlocked.Increment(ref HeartbeatsReceived));
},
OnMessage = (channel, msg) =>
{
Console.WriteLine("OnMessage: @" + channel + ": " + msg);
},
OnStop = () =>
{
Console.WriteLine("OnStop: #" + Interlocked.Increment(ref StopCount));
},
OnError = ex =>
{
Console.WriteLine("OnError: #" + Interlocked.Increment(ref ErrorCount) + " ERROR: " + ex);
},
OnFailover = server =>
{
Console.WriteLine("OnFailover: #" + Interlocked.Increment(ref FailoverCount));
},
OnDispose = () =>
{
Console.WriteLine("OnDispose: #" + Interlocked.Increment(ref DisposeCount));
},
OnUnSubscribe = channel =>
{
Console.WriteLine("OnUnSubscribe: #" + Interlocked.Increment(ref UnSubscribeCount) + " channel: " + channel);
},
})
{
Console.WriteLine("PubSubServer StartedAt: " + StartedAt.ToLongTimeString());
PubSubServer.Start();
"Press Enter to Quit...".Print();
Console.ReadLine();
Console.WriteLine("PubSubServer EndedAt: " + DateTime.UtcNow.ToLongTimeString());
Console.WriteLine("PubSubServer TimeTaken: " + (DateTime.UtcNow - StartedAt).TotalSeconds + "s");
}
}