Question

I'm again in a situation where I've spend an obscene amount of time on trying to customize datasnap callback samples to my needs. I'm old school OOP programmer and have several very large Object hierakies in my "toolbox" PODO style :-) .. and having this great datasnap feature, I want to utilize the forces of the callback.

BUT - when I implement it ... it simply fails ... (FASTMM4 reports mem leaks).

Try and create 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 keep using TJSONValue ... But try and switch the commented code - and you will see what I mean.

I could of course change all my existing code to JSON ... but that is simply not acceptable.

Does anyone have any idea on how to use the BroadcastOBJECT or NotifyOBJECT ?

Regards Bjarne

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top