My bad!

I fixed it by moving the line to process the msg outside of the "strip out
the carriage return and line feed" loop:

Was:
procedure TfClientMain.ClientDataAvailable(Sender: TObject; Error: Word);
var
  iMsgCode, iMsgTableID: Integer;
begin
  with Sender as TTcpSrvClient do begin
    { Since we are using line mode, we will receive complete lines }
    RcvdLine := ReceiveStr;
    { Remove trailing CR/LF }
    while (Length(RcvdLine) > 0) and
          (RcvdLine[Length(RcvdLine)] in [#13, #10]) do begin
      RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);
      if Length(Trim(RcvdLine)) > 0 then begin
        iMsgCode := ExtractMsgCode(RcvdLine);
        if iMsgCode = 0 then
          Exit;
        ClientDM.InsertMessageReceived(iMsgCode, MSG_PROCESSED_NO,
RcvdLine);
        { Identify the ID just entered, so the Process() method will know
which
          record to update as either Processed or Unprocessable  }
        iMsgTableID :=
 
ClientDM.GetCurrentIdentityFieldForTable('MSGS_RECEIVED_FROM_REAL_TIME');
    ProcessMsgReceivedFromRealTime(iMsgCode, iMsgTableID, RcvdLine); //this
was being called after the #13 was stripped, and then AGAIN after the #10
was stripped
      end;
    end;
  end;
end;

Is:

procedure TfClientMain.ClientDataAvailable(Sender: TObject; Error: Word);
var
  iMsgCode, iMsgTableID: Integer;
begin
  with Sender as TTcpSrvClient do begin
    { Since we are using line mode, we will receive complete lines }
    RcvdLine := ReceiveStr;
    { Remove trailing CR/LF }
    while (Length(RcvdLine) > 0) and
          (RcvdLine[Length(RcvdLine)] in [#13, #10]) do begin
      RcvdLine := Copy(RcvdLine, 1, Length(RcvdLine) - 1);
      if Length(Trim(RcvdLine)) > 0 then begin
        iMsgCode := ExtractMsgCode(RcvdLine);
        if iMsgCode = 0 then
          Exit;
        ClientDM.InsertMessageReceived(iMsgCode, MSG_PROCESSED_NO,
RcvdLine);
        { Identify the ID just entered, so the Process() method will know
which
          record to update as either Processed or Unprocessable  }
        iMsgTableID :=
 
ClientDM.GetCurrentIdentityFieldForTable('MSGS_RECEIVED_FROM_REAL_TIME');
      end;
    end;
    ProcessMsgReceivedFromRealTime(iMsgCode, iMsgTableID, RcvdLine); //Now
all is sunshine and bliss
  end;
end; 

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited.   If you are not the intended
recipient, please contact the sender and delete the material from any
computer.
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to