public void PurgeTimeouts() { lock (LockObject) { var array = new ReplyWait[_internal.Count]; _internal.Values.CopyTo(array, 0); foreach (var replyWait in array) { if (!replyWait.IsTimeout) { Logger.Verbose("Timeout message attempt {0} for {1} sent to {2} correlation {3}", replyWait.Attempts, replyWait.Package.EndPoint, replyWait.Sent.ToLocalTime(), replyWait.CorrelationId); continue; } if (replyWait.Attempts++ >= 3) { _internal.Remove(replyWait.CorrelationId); PeerInfo peerInfo; if (_peerList.TryGet(replyWait.Package.EndPoint, out peerInfo)) { _peerList.Punish(peerInfo.BotId); } } else { replyWait.Sent = DateTimeProvider.UtcNow; Logger.Verbose("Retrying message attempt {0} for {1} sent to {2} correlation {3}", replyWait.Attempts, replyWait.Package.EndPoint, replyWait.Sent.ToLocalTime(), replyWait.CorrelationId); _messageSender.Send(replyWait.Package.EndPoint, replyWait.Package.Data); } } } }
public void Handle(BotMessage message) { _peerList.Punish(message.Header.BotId); }