Einzelnen Beitrag anzeigen

schwa226

Registriert seit: 4. Apr 2008
400 Beiträge
 
#2

Re: Indy Server -> Client Stream

  Alt 21. Jan 2010, 10:27
Ok, habe es nun so gelöst:

Delphi-Quellcode:
        if not MyIdTCPClient.IOHandler.InputBufferIsEmpty then
        begin

          if StreamComplete then
          begin

            fileStream := TMemoryStream.Create;
            TempStream := TMemoryStream.Create;

            MyIdTCPClient.IOHandler.InputBuffer.ExtractToStream(TempStream);
            TempStream.Seek(0, soFromBeginning);
            TempStream.Read(StreamSize, SizeOf(Int64));

            fileStream.CopyFrom(TempStream, TempStream.Size - SizeOf(Int64));

            if fileStream.Size >= StreamSize then
            begin
              EventCallbackProcedure(fileStream);
              FreeAndNil(TempStream);
              FreeAndNil(fileStream);
              StreamComplete := True;
            end
            else
              StreamComplete := False;

          end
          else begin
            TempStream.Clear;
            MyIdTCPClient.IOHandler.InputBuffer.ExtractToStream(TempStream);
            TempStream.Seek(0, soFromBeginning);
            fileStream.CopyFrom(TempStream, TempStream.Size);

            if fileStream.Size >= StreamSize then
            begin
              EventCallbackProcedure(fileStream);
              FreeAndNil(TempStream);
              FreeAndNil(fileStream);
              StreamComplete := True;
            end;

          end;
        end;
Delphi 2010, Update 4 & 5
  Mit Zitat antworten Zitat