

using HelloWorld;

string brokerHost = "localhost";

string queueName = "task_queue";

using var sender = new Sender(brokerHost, "user", "password", queueName);

using var receiver1 = new Receiver(brokerHost, "user", "password", queueName);
using var receiver2 = new Receiver(brokerHost, "user", "password", queueName);

receiver1.AddMessageHandler(text => {
    Console.WriteLine($"[1] Received Message from rabbit: {text}");
    int dots = text.Split('.').Length - 1;
    Thread.Sleep(dots * 1000);
    Console.WriteLine($"[1] Done Message: {text}");
});
receiver2.AddMessageHandler(text => {
    Console.WriteLine($"[2] Received Message from rabbit: {text}");
    int dots = text.Split('.').Length - 1;
    Thread.Sleep(dots * 1000);
    Console.WriteLine($"[2] Done Message: {text}");
});


for (int i = 0; i < 5; i++)
{
    var message = $"Message number {i}{string.Join("", Enumerable.Range(0, i).Select(x=>"."))}";
    Console.WriteLine($"Send Message to rabbit: {message}");
    sender.SendMessageToQueue(message);
}



while (true) ;