Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Multimedia (https://www.delphipraxis.net/16-multimedia/)
-   -   Delphi flood text Protection (https://www.delphipraxis.net/182608-delphi-flood-text-protection.html)

drama22 4. Nov 2014 21:22

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:
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;
basically i have created a unit function called IsFlood and i adjust some visual alert to it here is my is flood unit

Delphi-Quellcode:
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.
but i cant detect the fast typing ,, what iam doing wrong any help ?

Sir Rufo 4. Nov 2014 22:17

AW: Delphi flood text Protection
 
What result do you expect from
Delphi-Quellcode:
IsFlood
and please show the line in code where you set this expected result.

drama22 4. Nov 2014 22:33

AW: Delphi flood text Protection
 
Zitat:

Zitat von Sir Rufo (Beitrag 1278700)
What result do you expect from
Delphi-Quellcode:
IsFlood
and please show the line in code where you set this expected result.

i didnt figure the result part i need help with it i was thinking to do somthing like that with is flood

Delphi-Quellcode:
  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;
but dont know how to detect the flood i use also in main form private declarations

Delphi-Quellcode:
    FloodpSay : integer;
    FloodClose : Integer;
but i cant figure what to do to detect the fast typing and thats what iam doing with the timer

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;

Sir Rufo 4. Nov 2014 23:21

AW: Delphi flood text Protection
 
Zitat:

Zitat von drama22 (Beitrag 1278701)
Zitat:

Zitat von Sir Rufo (Beitrag 1278700)
What result do you expect from
Delphi-Quellcode:
IsFlood
and please show the line in code where you set this expected result.

i didnt figure the result part i need help with it

You should have added this important information just the first post. We are not able to look into your brain and working crystal balls are very rare :glaskugel:

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:
IsFlood
return
Delphi-Quellcode:
true
.
Describe it as precise as possible otherwise we are not able to help.

BTW Did you got a solution for http://www.delphipraxis.net/182563-d...ml#post1278303

drama22 5. Nov 2014 00:01

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 09:52 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz