public bool AddAndCheck(Connection connection, double cost) { lock (_delays) { double delay; if (!_delays.TryGetValue(connection.Address, out delay)) { if (cost > 0) { _delays.Add(connection.Address, Math.Min(cost, DelayLimit)); } } else { _delays[connection.Address] = Math.Min(delay + cost, DelayLimit); } var shouldDelay = (delay + cost) >= DelayThreshold; if (shouldDelay) { connection.SendSysMessage("Too many requests are coming from your location and your request has been canceled. Please wait and try again in a few minutes."); } return(shouldDelay); } }
public void Send(string message) { if (IsWeb) { Connection.SendSysMessage(message); } else if (IsRoom) { Room.Send(message); } else if (IsPrivateChat) { PrivateChat.Send(message); } }
public bool AddAndCheck(Connection connection, double cost) { lock (_delays) { double delay; if (!_delays.TryGetValue(connection.Address, out delay)) { if (cost > 0) _delays.Add(connection.Address, Math.Min(cost, DelayLimit)); } else { _delays[connection.Address] = Math.Min(delay + cost, DelayLimit); } var shouldDelay = (delay + cost) >= DelayThreshold; if (shouldDelay) connection.SendSysMessage("Too many requests are coming from your location and your request has been canceled. Please wait and try again in a few minutes."); return shouldDelay; } }