Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.




ID: 28625, DataSnap XE2 - Unified Connection Monitoring Sample Component

by Mathew DeLong Email: Anonymous


New component for listening to HTTP and TCP/IP connections/disconnections on a DataSnap TDSServer.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 1.0  to 1.0 1027 downloads
Copyright: Open Source or other


Terms of use: Embarcadero use at your own risk disclaimer


Size: 285,814 bytes
Updated on Tue, 15 Nov 2011 06:11:23 GMT
Originally uploaded on Tue, 15 Nov 2011 06:11:19 GMT
SHA1 Hash: 84EE1D389A65F9E06AD4BE5D03F72A3A0F9ABB6C
MD5 Hash: 028AB3B358FED1ACA4EBD48253EEF8A3

    Explore the files in this upload

Description
The TDSServerConnectionMonitor, once installed into your IDE, can be found on the Tool Palette under the ‘DataSnap Server’ heading. You can add this component to a form with a TDSServer instance on it, or on another form with access to a TDSServer instance. In order for the component to become active, you must call ‘Start’ on it. This is done (instead of starting by default) to insure that all components have been registered with the TDSServer instance before registering with it. You can call Stop on the component if you want it to stop firing events.

The component exposes a Server property, which must be set. This must be the TDSServer instance to listen on. It also exposes three events: OnConnnect, OnDisconnect and OnHTTPTrace.

The OnConnect event lets you know of any TCP/IP, HTTP (tunnel) or HTTP (REST) connection. The connection for TCP/IP is the connection itself. For HTTP, the connection is the session. When the session is created, the connection is established, and when the session is closed, the connection is seen as being terminated. This doesn’t account for any attempted HTTP requests that fail after connection to the server, but before successfully getting to the authentication step. (such as requests using expired session IDs.)

The item passed to the OnConnect event will contain a connection (TDSMonitoredConnection) which specifies the connection information, such as Client IP, Session ID, protocol and the date the connection was created. If the protocol is TCP/IP (pTCPIP) then you can cast this instance to TDSTCPMonitoredConnection, and get additional information specific to TCP. However, this should not be required.

The OnDisconnect event simply notifies you of the connections which are closing. The event is passed an item containing the connection being closed. This will be the same connection object that was passed to OnConnect.

The OnHTTPTrace event notifies you of any HTTP request, and the response being returned. Unless the request was for file dispatching (or some Non DataSnap-REST request) the event item will contain a Connection. The one exception is for the last request of an HTTP Tunnel connection as it is closing. If the connection isn’t specified, it will be set to nil. In the event you also get access to the HTTP Request and HTTP Response being sent.

The TDSServerConnectionMonitor component also has a couple additional public methods (aside from start and Stop) of interest: ForEachConnection and GetConnectionForSession.

ForEachConnection allows you to iterate over each connection in a thread-safe way.

GetConnectionForSession allows you to get a connection (TDSMonitoredConnection) for a specific sessionId (Session.SessionName.) It returns nil if no connection can be found with the given Session ID.

There is also the ConnectionCount property, which returns the number of connections currently registered with the component.

The TDSMonitoredConnection class has a "Close" procedure on it. This procedure will close the connection in a way appropriate to which type of connection it is. For TCP/IP, it will call into the TCP channel and close it. For HTTP, the session will be closed through the session manager.

See the README file in the download for more information, and details on the sample projects included.

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC04