summaryrefslogtreecommitdiff
path: root/code/common/RequestHandler.cs
blob: 3e7a66b7db705f6fca5b47ba07c344204755486f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Reflection;
using System.Threading;
using common.messages;

namespace common
{
    public class RequestHandler : AbstractHandler<Message>
    {
        ServiceBus bus;

        public RequestHandler(ServiceBus bus)
        {
            this.bus = bus;
        }

        public override void handle(Message item)
        {
            //Console.Clear();
            "received {0} from {1} {2}".log(item.message, item.source, DateTime.Now);
            //Thread.Sleep(5000);
            //Console.In.ReadLine();
            var source = Assembly.GetEntryAssembly().GetName().Name;
            "sending  {0} from {1} {2}".log(item.message.Equals("ping") ? "pong" : "ping", source, DateTime.Now);
            bus.publish<Message>(x =>
            {
                x.message = item.message.Equals("ping") ? "pong" : "ping";
                x.source = source;
            });
        }
    }
}