TAstaClientSocket.SendCodedStream


Applies to
TAstaClientSocket

 

Declaration
procedure SendCodedStream(MsgID: Integer; MS: TMemoryStream);

 

Description
The SendCodedStream compliments the
SendCodedMessage method. It can be used to send streams to the server and then the server can respond with a custom action. The following code demonstrates the usage.

 

The client sends a message to the server.

procedure TForm1.Button1Click(Sender: TObject);

begin

  AstaClientSocket1.SendCodedMessage(2000, '');

end;

 

The server responds by loading a memo into a stream and sending it to the client.

 

procedure TForm1.AstaServerSocket1CodedMessage(Sender: TObject;
  MsgID: Integer; Msg:
string);

var

  MS : TMemoryStream;

begin

  case MsgID of

    2000: begin

            MS := TMemoryStream.Create;

            mSelectSend.Lines.SaveToStream(MS);

            AstaServerSocket1.SendCodedStream(2000, MS);

            MS.Free;

          end;

  end;

end;

 

The client receives the stream and displays it in a memo and saves it to a file.

 

procedure TForm1.AstaClientSocket1CodedStream(Sender: TObject;
  MsgID: Integer; MS: TMemoryStream);

begin

  case MsgID of

    2000: begin

            mFileFromServer.Lines.Clear;

            mFileFromServer.Lines.LoadFromStream(MS);

            mFileFromServer.Lines.SaveToFile('ATGTestFile.Txt');

          end;

  end;

end;

 

 



ASTA Overview TAstaClientSocket.RequestUtilityInfo TAstaClientSocket.SendGetCodedParamList