In this Delphi Labs episode we are focusing on different options for licecycle of DataSnap server methods instances running inside a DataSnap server.
In the previous part of this lab we have used Delphi XE to build a DataSnap VCL Forms app server and client application. The server method instance has got an overridden constructor where its private FID is initialized with a generated GUID and "GetId" server method is implemented to be able to uniquely identify a server methods instance on the client. The client app has a button and a label where the value of server method instance ID is displayed. At the end we see that with default DSServerClass.LifeCycle value of "Session" every connected client has its own server methods instance inside the server application.
In this second part of the lifecycle demo we are extending both server and client applications. In the server we are adding two new TDSServerClass components with other possible values for lifecycle: server and invocation. Implementations of all three server classes are identical and they provide "GetID" server method that returns an instance GUID value and let us identify instances inside the server. The client interface is extended and DataSnap proxies are regenerated. At the end of the demo we verify that server method instances are global to all clients, session instances are unique per client and invocation instances created and destroyed on the fly.
The source code for this demo is available at http://cc.embarcadero.com/item/28199 and whitepaper at http://edn.embarcadero.com/delphi
Have fun Delphi programming!
Simply clear and get to the point , job well done. Thanks
vitisanity 8 months ago
thank you!
xr1140 1 year ago