[twsocket] HttpCli within a dynamic array?

Angus Robertson - Magenta Systems Ltd angus@magsys.co.uk
Wed, 28 Jun 2000 11:38 +0100 (BST)


> I can't make my own event handlers when
> I have the HttpCli components in an array.

The trick is identifying which instance of the component events come from, 
this is the concept.

Angus


with thttpC [item] do
begin
  Tag := item ;   // so we can identify which connection
  OnDocBegin := DocBegin ;
  OnDocData := DocData ;
  OnHeaderBegin := HeaderBegin ;
  OnHeaderData := HeaderData ;
  OnCommand := Command ;
  OnRequestDone := RequestDone ;
end ;

procedure TMainForm.Command (Sender: TObject; var S: String) ;
var
  AHttpC: THttpCli;
  item: integer ;
begin
  AHttpC:= Sender as THttpCli;
  Item := AHttpC.Tag;
  if DebugFlag then AddDebugLine (IntToStr (item) + '> ' + s) ;
end;