DataSnap.SessionStore Sample

From Appmethod Code Examples
Jump to: navigation, search

This sample shows how to store TObject instances in a session. You can then use the stored objects in later server method invocations.

Location

You can find the Session Store Object sample project at:

Description

The Session Store Object sample demonstrates:

  • How to store TObject instances in a session.
  • How you can then use the stored objects in later server method invocations.

How to Use the Sample

  1. Navigate to Start | Programs | Appmethod 1.14 | Samples, go to Object Pascal\DataSnap\SessionStoreObject, and open SessionStoreObject.dproj.
  2. Build SessionStoreObject.dproj.
  3. Select Run > Run or press F9 to run the sample.
  4. Open the URL from the first text field of the server in a browser.
  5. Go back to the server and notice that there is now a URL in the second text field.
  6. Open the URL from the second text field of the server in your browser.
  7. Note what the browser returns.

Files

File Contains

SSOServerContainer

The server container that holds the DataSnap Server components.

SSOServerMethodsUnit

The server methods container holding source code for the server methods used in the Session Store Object sample.

SessionStoreObject

The project itself.

SessionStoreObjectUI

The main form that constitutes the user interface for the Session Store Object sample.

Classes

  • TMySessionClass implements the Session Store Object itself.
  • TServerMethods1 implements the server methods available for the Session Store Object sample.
  • TForm3 is the main form that handles all controls.

Implementation

  • The URL of the first text field that you open in your browser invokes the StoreObject server method, creating a new instance of TMySessionClass with some values stored in it.
  • The URL of the second text field invokes the GetObject server method, passing in the id of the object and returning the values stored within the stored object.
  • The SSOServerContainer.dfm form contains a session store object server (TDSServer component), a session store object proxy generator (TDSProxyGenerator component), a session store object metadata provider (TDSCustomProxyGenerator.MetaDataProvider component), a session store object HTTP service (TDSHTTPService component), a session store object server class (TDSServerClass component), and a session store object file dispatcher (TDSHTTPServiceFileDispatcher component).

Uses

See Also