The chat rate of one session (RFC section 3.8): a token bucket.
More...
#include </__w/project-rtype/project-rtype/server/include/rtype/rate_limit.hpp>
|
| using | Clock = std::chrono::steady_clock |
| | Clock of the refills.
|
| |
|
| bool | allow (Clock::time_point now) noexcept |
| | Counts a message and tells whether it may be relayed.
|
| |
|
| static constexpr std::uint32_t | burst = 5 |
| | Messages a session may send at once.
|
| |
| static constexpr std::chrono::seconds | refill {1} |
| | Time for one message to come back.
|
| |
The chat rate of one session (RFC section 3.8): a token bucket.
A session sends burst messages at once, then gets one more back every refill, up to burst kept. A message refused does not count. Not thread-safe.
◆ Clock
◆ allow()
| bool rtype::ChatRate::allow |
( |
Clock::time_point |
now | ) |
|
|
noexcept |
Counts a message and tells whether it may be relayed.
- Parameters
-
| now | Current time, never earlier than the previous call's. |
- Returns
false if the session is over the rate: the message is a flood.
◆ burst
| constexpr std::uint32_t rtype::ChatRate::burst = 5 |
|
staticconstexpr |
Messages a session may send at once.
◆ refill
| constexpr std::chrono::seconds rtype::ChatRate::refill {1} |
|
staticconstexpr |
Time for one message to come back.
The documentation for this class was generated from the following file: