delphiserializationdelphi-7remobjects

Delphi 7 remobjects - serialize a component


I have a client-server application built in Delphi 7 and RemObjects SDK. Messages between client and server are binary (http://wiki.remobjects.com/wiki/BinMessage). My questions are: 1) if I fill with data a TDataSet/TDataSource and sent them from client to server, on the server component's DataSet will contain the data? the data should remain persistent no? 2) I've tried to send the component through RemObjects, encapsulated in a TROBinaryMemoryStream descendant class, but without succes

class definition

  TRODataSource=class(TROBinaryMemoryStream)
   private
     FNameDS:String;
     FDS:TDataSource;
     procedure SetName(aValue:String);
     procedure SetDS(aValue:TDataSource);
  public
   published
    property Name:String read FNameDS write SetName;
    property DataSource:TDataSource read FDS write SetDS;
  end;

method which send the datasource

function foo(aDataSource: TDataSource):integer;
var
  wStream:TRODataSource;
begin
 wStream:=TRODataSource.Create;
 wStream.Name:='TEST';
 wStream.DataSource:=aDataSource;
 try
  Result:=(RORemoteService as ISvc..).foo1(wstream);//method existing on the server will //return how many records are in the dataset
 finally
  freeandnil(wstream);
 end;
end;

any answer will be apreciated.

LE: it seems that only classes descendants of the TROComplexType can be serialized http://wiki.remobjects.com/wiki/Remote_Object_Allocation_and_Serialization. But I'm not sure if I can not serialize a component on a stream.


Solution

  • When you have your component serialized to a stream (see my other post), you can use the "Binary" type to send the stream from the server to client (and reverse): http://wiki.remobjects.com/wiki/TROBinaryMemoryStream_Class

    Or just send it as a string :-). No need to override TROBinaryMemoryStream!