Hmm..
Bei
INDY gibt es doch IdTCPClient.IOHandler.InputBufferIsEmpty
Ich hab nen Testtool gefunden, dort frage ich per Timer nach JSON Daten ab:
Delphi-Quellcode:
procedure TForm1.Timer1Timer(Sender: TObject);
var
ReceivedText: string;
begin
Timer1.Enabled := False;
try
with FIdTCPClient do
begin
if not Connected then Exit;
// read any data in
if IOHandler.InputBufferIsEmpty then
begin
IOHandler.CheckForDataOnSource(0);
IOHandler.CheckForDisconnect;
if IOHandler.InputBufferIsEmpty then Exit;
end;
// Wartet auf JSON...
IOHandler.WaitFor('{', False);
ReceivedText := IOHandler.WaitFor('}', True, True, IndyTextEncoding_UTF8);
Memo1.Lines.Add(ReceivedText);
// if not already, send streaming command
if not FSentStreamCommand then
begin
IOHandler.WriteLn('?WATCH={"enable":true,"json":true}');
FSentStreamCommand := True;
end;
end;
finally
if FIdTCPClient.Connected then
Timer1.Enabled := True;
end;
end;