Пример #1
0
 public void Increment(string key, ThrottleType throttleType)
 {
     if (BotConfig.Instance.Throttles.TryGetValue(throttleType, out var throttle))
     {
         this.AddOrUpdate(key, throttle, true);
     }
 }
Пример #2
0
 public Throttle(ThrottleType type, params Connection[] connections)
 {
     this.type = type;
     cons = new List<Connection>(connections.Length);
     foreach (Connection con in connections)
     {
         Add(con);
     }
 }
Пример #3
0
        public bool IsThrottled(string key, ThrottleType throttleType)
        {
            if (BotConfig.Instance.Throttles.TryGetValue(throttleType, out var throttle))
            {
                return(this.AddOrUpdate(key, throttle, false).TimesInvoked > throttle.Limit);
            }

            return(false);
        }
Пример #4
0
 public Throttle(ThrottleType type, params Connection[] connections)
 {
     this.type = type;
     cons      = new List <Connection>(connections.Length);
     foreach (Connection con in connections)
     {
         Add(con);
     }
 }
Пример #5
0
 public ThrottleGroup(int maxBytesPerSecond, ThrottleType type, params Connection[] connections)
 {
     this.maxBytesPerSecond = maxBytesPerSecond;
     this.type = type;
     cons = new List<Connection>(connections.Length);
     foreach (Connection con in connections) {
         cons.Add(con);
         sentBytes += con.SentBytes;
         rcvdBytes += con.RcvdBytes;
     }
 }
Пример #6
0
 public ThrottleGroup(int maxBytesPerSecond, ThrottleType type, params Connection[] connections)
 {
     this.maxBytesPerSecond = maxBytesPerSecond;
     this.type = type;
     cons      = new List <Connection>(connections.Length);
     foreach (Connection con in connections)
     {
         cons.Add(con);
         sentBytes += con.SentBytes;
         rcvdBytes += con.RcvdBytes;
     }
 }