protected virtual async Task OnStopping()
 {
     _timer.Stop();
     await _messageBus.PublishAsync(
         PeerServiceStatusMessage.Create(PeerServiceStatus.Offline, Info)
         );
 }
        protected virtual async Task OnStarted()
        {
            await _messageBus.SubscribeAsync <PeerServiceStatusMessage>(msg =>
            {
                var info = msg.GetInfo();

                if (msg.Status == PeerServiceStatus.Online)
                {
                    var expiry = DateTime.Now.AddSeconds(30);

                    if (_peers.ContainsKey(info.Name))
                    {
                        var peer = _peers[info.Name];

                        if (peer.Expiry < DateTime.Now)
                        {
                            Logger.Debug($"Reconnected peer service, {info.Name} to {Info.Name}");
                        }
                        _peers[info.Name].Expiry = expiry;
                    }
                    else
                    {
                        _peers[info.Name] = new PeerServiceInfo
                        {
                            Info   = info,
                            Expiry = expiry
                        };
                        Logger.Debug($"Registered peer service, {info.Name} to {Info.Name}");
                    }
                }
                else
                {
                    _peers.Remove(info.Name);
                    Logger.Debug($"Removed peer service, {info.Name} from {Info.Name}");
                }
            });

            var createMessage =
                new Func <PeerServiceStatusMessage>(() =>
                                                    PeerServiceStatusMessage.Create(PeerServiceStatus.Online, Info)
                                                    );

            _timer = new Timer
            {
                Interval  = 15000,
                AutoReset = true
            };
            _timer.Elapsed += async(sender, args) => await _messageBus.PublishAsync(createMessage());

            _timer.Start();

            await _messageBus.PublishAsync(createMessage());
        }