Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TIdCmdTCPServer customised Reply
#1
I try to implement a very simple set-up. An IdCmdTCPServer and an IdTCPClient. From the Client I send a Cmd and in the Reply I want to get a value from the server.
On the client side I have (properly built it Try..Except, etc, what I do not include here):

Code:
Log(IntToStr(IdTCPClient1.SendCmd('AAA 1',[200])));
Log(IdTCPClient1.LastCmdResult.DisplayName);

where Log is a procedure to display a string.

On the server side I have (again properly built around):

Code:
procedure TMyIdCmdTCPServer.OnCommandAAA(ASender: TIdCommand);
begin
  Log('Raw Line ' + ASender.RawLine);
  ASender.Reply.Text.Text := 'DT= ' + DateTimeToStr(Now);
end;

After connecting I send the comand from the client. What I get is "200 Welcome", what is obviously the default welcome message. If I send the Cmd again, from the same connect-disconnect session, then I get the proper DT= reply, with the Time of the PREVIOUS call. I can repeat it many times. So it is clear that the Reply.Text is set, but only after the Reply is sent to the client. At the second Cmd it sends the Reply set at the first Cmd, etc.

If I disconnect and connect again, then it forgets the set Reply and goes back to the Welcome message (this part I feel normal).

Similarly if I send an unknown command multiple times, the first Reply is still 200 Welcome and only the second gives the unknown command error.

What do I do wrong? How can I customise the Reply AFTER the Cmd is received (so i know what the question is) but BEFORE it is sent back to the client?
Reply


Messages In This Thread
TIdCmdTCPServer customised Reply - by jollytall - 01-24-2019, 01:07 PM
RE: TIdCmdTCPServer customised Reply - by rlebeau - 01-24-2019, 09:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)