TsgcWSRateLimiter › Methods › IsMessageAllowed
Server hook: returns True if a message from IP passes rate limiting.
function IsMessageAllowed(const aIP: string; const aMessage: string = ''): Boolean;
| Name | Type | Description |
|---|---|---|
aIP | const string | IP address of the client sending the message. Used as the key for PerIP and burst protection. |
aMessage | const string | Optional message payload or endpoint path. Passed to the PerEndpoint wildcard matcher so per-endpoint rules can see the URL / command being invoked. Defaults to an empty string. |
Returns True if the message should be processed, False if it should be rejected. (Boolean)
Server-integration helper invoked automatically on every received message when the rate limiter is assigned to a server's RateLimiter property. Evaluates PerIP, PerEndpoint, PerAPIKey, PerUser, quotas and burst protection. Returns True immediately when Enabled is False. Use directly only from custom protocol code that is not covered by the built-in server integration.
// Manual gate inside a custom OnMessage handler
procedure TForm1.ServerMessage(Connection: TsgcWSConnection; const Text: string);
begin
if not sgcWSRateLimiter1.IsMessageAllowed(Connection.PeerIP, Text) then
begin
Connection.WriteData('Rate limited');
Exit;
end;
ProcessCommand(Connection, Text);
end;