I have this TCPServerExecute
event that I want to stop from executing after I manually disconnect the connection with the client :
procedure TMainForm.TCPServerExecute(AContext: TIdContext);
var
TCPClient : TIdTCPClient;
begin
try
TCPClient := nil;
try
TCPClient := TIdTCPClient.Create(nil);
if aConditionIsMet then begin
AContext.Connection.IOHandler.WriteLn('Disconnected from server.');
AContext.Connection.Disconnect;
Exit;
end;
finally
FreeAndNil(TCPClient);
end;
except on e : Exception do
begin
MainForm.Log('error in Execute=' + e.Message);
end;
end;
end;
and at client side everything's fine but on server-side I loop through TCPServerExecute infinitely. What am I doing wrong and how can I stop TCPServerExecute
from executing after I type AContext.Connection.Disconnect
?