I am working on a chat application with Indy 10 in Delphi 7. Now, on the client side, Indy does not have an OnDataReceived or OnRead event, so how can I receive text from the server to the client?
I did try to use the OnWork event with a timer, but my timer is not woking.
Here are the codes for OnWork and TTimer that I used:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if zb_FDataReceived then
begin
ShowMessage('Timer triggered!');
ClientOutput.Lines.Add('Server: ' + zb_FReceivedData);
zb_FDataReceived := False;
end;
end;
procedure TForm1.IdTime1Work(ASender: TObject; AWorkMode: TWorkMode;
AWorkCount: Integer);
begin
if zb_FDataReceived then
begin
ShowMessage('Timer triggered!');
ClientOutput .Lines.Add('Server: ' + zb_FReceivedData);
zb_FDataReceived := False;
end;
end;
zb_FDataReceivedset? It's missing in the your code example. Also why would you output'Timer triggered!'whenTForm1.IdTime1Work()cannot be a timer event? If it should execute the same code then you should just callself.Timer1Timer( ASender );.