summaryrefslogtreecommitdiff
path: root/code/common/RequestHandler.cs
blob: 416988e74f0bb876d432d3fa9b70c6be03fe069e (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
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)
        {
            "received from {0}: {1} {2}".log(item.source, item.message, DateTime.Now);
            Thread.Sleep(5000);
            bus.publish<Message>(x =>
            {
                x.message = item.message.Equals("ping") ? "pong" : "ping";
                x.source = Assembly.GetEntryAssembly().GetName().Name;
            });
        }
    }
}