Delphi datasnap callback - BroadCast question

I am again in a situation where I spent foul time trying to configure datasnap callback patterns for my needs. I am an old OOP programmer for schoolchildren and I have some very large hierakies objects in my PODO tool style :-) .. and having this great datasnap function, I want to use callback forces.

BUT - when I implement it ... it just fails ... (FASTMM4 reports memory leaks).

Try creating a simple VCL datasnap server - TCP. And add a button and this source ...

procedure TForm1.Button1Click(Sender: TObject);
var
//  AObject : TObject;
  aJSONVal : TJSONValue;
begin
//  AObject := TObject.Create;
//  ServerContainer1.DSServer1.BroadcastObject('SomeChannel','SomeCallbackID', AObject);
//  AObject.Free;

  aJSONVal := TJSONObject.Create;
  ServerContainer1.DSServer1.BroadcastMessage('SomeChannel','SomeCallbackID',aJSONVal);
  // aJSONVal.Free; // Mat pointed out that this is done by the broadcast.
end;

It will work - as long as you continue to use TJSONValue ... But try switching the commented code - and you will see what I mean.

I could, of course, change all existing code to JSON ... but this is simply unacceptable.

- , BroadcastOBJECT NotifyOBJECT?

+3
2

:. , , , :

Delphi XE: (ms-help://embarcadero.rs_xe/vcl/DSServer.TDSServer.BroadcastObject.html):

BroadcastObject (const ChannelName: String; const CallbackId: String; const Msg: TObject): boolean; ;

. CallbackId.

, 3 - ?

0

, Notify Broadcast, . "AObject.Free"; "aJSONVal.Free;". , .

, Broadcasted . , Broadcast , .

, ,

Mat

+2

All Articles