![]() |
Delphi flood text Protection
hi i decided to add some flood protection to my chat application so i do something like this
Delphi-Quellcode:
begin
if IsFlood then begin ShowInfo('Anti-Flood', 20); Exit; end; end;
Delphi-Quellcode:
basically i have created a unit function called IsFlood and i adjust some visual alert to it here is my is flood unit
procedure TMAIN.ShowInfo(Text: string; Waiting: Integer);
var Rect: TRect; begin GetWindowRect(self.Smilebtn.Handle, Rect); with pnlFlood do begin Caption := ' ' + Text + ' '; Width := self.Canvas.TextWidth(Text) + 40; Left := weblog.Left + 1; Top := weblog.Height - Height; if TB1.Visible then Top := Top-TB1.Height else Top := Top+TB1.Height; Visible := True; FloodpSay := 0; msgTmr.Enabled := True; end; FloodClose := Waiting; end;
Delphi-Quellcode:
but i cant detect the fast typing ,, what iam doing wrong any help ?
unit checkFlood;
interface uses Windows; function IsFlood:Boolean; var LastFloodTime : Integer; floods:integer; implementation function IsFlood:Boolean; var i, x : integer; begin Result := False; i := trunc(GetTickCount/2); x := trunc((i - LastFloodTime)/4); Result := False; if x < //detect flood// then Result := True; LastFloodTime := i; end; end. |
AW: Delphi flood text Protection
What result do you expect from
Delphi-Quellcode:
and please show the line in code where you set this expected result.
IsFlood
|
AW: Delphi flood text Protection
Zitat:
Delphi-Quellcode:
but dont know how to detect the flood i use also in main form private declarations
function IsFlood:Boolean;
var i, x : integer; begin Result := False; i := trunc(GetTickCount/2); x := trunc((i - LastFloodTime)/4); Result := False; if x < //detect flood// then Result := True; LastFloodTime := i;
Delphi-Quellcode:
but i cant figure what to do to detect the fast typing and thats what iam doing with the timer
FloodpSay : integer;
FloodClose : Integer;
Delphi-Quellcode:
procedure Tmain.msgTmrTimer(Sender: TObject);
begin msgTmr.Enabled := False; FloodpSay := FloodpSay + 1; if FloodpSay > FloodClose then begin pnlFlood.Visible := False; FloodpSay := 0; end; if FloodpSay <> 0 then msgTmr.Enabled := True; end; |
AW: Delphi flood text Protection
Zitat:
Also you did not describe what you are really want. Yes, detect flooding ... nice :roll: Describe your definition of flooding and under what circumstances should the function
Delphi-Quellcode:
return
IsFlood
Delphi-Quellcode:
.
true
Describe it as precise as possible otherwise we are not able to help. BTW Did you got a solution for ![]() |
AW: Delphi flood text Protection
ok , now i have chat application and possibly the client are sending messages to each others , so he type his message and press on send button to send his message if he press the send button repeatedly his message will flood The text box so i think about it and i thought that i have to adjust when he click on send button and pause send operation if his click on send button Too fast , maybe my implementation was very wrong for this purpose
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 13:16 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz