Ignore:
Timestamp:
Aug 14, 2012, 10:31:30 AM (12 years ago)
Author:
chronos
Message:
  • Modified: PinConnection package now use for data parameters TListByte instead of TStream class contained in TemplateGenerics package. TStream have Position property which has no meaning for forwarding plain byte memory block. There is TBinarySerializer class used for serializing data instead of TStreamHelper class.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • PinConnection/UCommTCPClient.pas

    r339 r407  
    77uses
    88  Classes, SysUtils, blcksock, synsock, UCommPin, UCommon, UThreading,
    9   DateUtils;
     9  DateUtils, SpecializedList;
    1010
    1111type
     
    1919  public
    2020    Parent: TCommTCPClient;
    21     Stream: TMemoryStream;
     21    Stream: TListByte;
    2222    procedure Execute; override;
    2323    constructor Create(CreateSuspended: Boolean;
     
    3333    FOnReceiveData: TReceiveDataEvent;
    3434    FReceiveThread: TCommSocketReceiveThread;
    35     procedure ReceiveData(Sender: TCommPin; Stream: TStream);
     35    procedure ReceiveData(Sender: TCommPin; Stream: TListByte);
    3636    procedure SetActive(const AValue: Boolean);
    3737  public
     
    5353{ TCommTCPClient }
    5454
    55 procedure TCommTCPClient.ReceiveData(Sender: TCommPin; Stream:TStream);
     55procedure TCommTCPClient.ReceiveData(Sender: TCommPin; Stream: TListByte);
     56var
     57  Mem: TMemoryStream;
    5658begin
    5759  if FActive then begin
    58     Socket.SendStreamRaw(Stream);
     60    try
     61      Mem := TMemoryStream.Create;
     62      Stream.WriteToStream(Mem);
     63      Socket.SendStreamRaw(Mem);
     64    finally
     65      Mem.Free;
     66    end;
    5967  end;
    6068end;
     
    120128          RecvBuffer(Buffer, Length(Buffer));
    121129
    122           Stream.Size := Length(Buffer);
    123           Stream.Position := 0;
    124           Stream.Write(Buffer[0], Length(Buffer));
     130          Stream.Count := Length(Buffer);
     131          Stream.ReplaceBuffer(0, Pointer(Buffer)^, Length(Buffer));
    125132          Pin.Send(Stream);
    126133        end else InBufferUsed := 0;
     
    134141begin
    135142  inherited;
    136   Stream := TMemoryStream.Create;
     143  Stream := TListByte.Create;
    137144end;
    138145
Note: See TracChangeset for help on using the changeset viewer.