Delphi XE2 DataSnap Server - Log client connection user/properties

I'm building an XE2 DataSnap server which will serve connections from REST clients. My DSServerClass LifeCycle property is set to 'Invocation'. What I want to do is to log the details of all client connections to the server, including the following details : username, IP address, protocol, application name. I can currently get these details using the following events :

DSAuthenticationManager - UserAuthenticate() : username, protocol (using the standard parameters passed in)

DSServer - Connect() : protocol, IP address, application name (using DSConnectEventObject.ChannelInfo.ClientInfo)

What I want to do is just log once for all details, but it seems I can't get all the details I need in one event. I tried using a shared private variable in the class but as expected this gave inconsistent results - the wrong IP address against the wrong username. Is there another way to achieve what I want?



You can use TDSServer.OnConnect event (which is called after TDSAuthenticationManager.OnUserAuthenticate). There you have access to ChannelInfo.ClientInfo as you've discovered and also ConnectProperties from which you can read property values like this:

  Scheme := ConnectProperties.Values[TDBXPropertyNames.DSAuthenticationScheme];
  UserName := ConnectProperties.Values[TDBXPropertyNames.DSAuthenticationUser];
  Password := ConnectProperties.Values[TDBXPropertyNames.DSAuthenticationPassword];

procedure TServerContainer1.DSServer1Connect(DSConnectEventObject: TDSConnectEventObject);
  Form1.Memo1.Lines.Add(Format('Conn->UserName=%s, Password=%s', [
  // 取 Client 端的IP 和 Port
  Form1.Memo1.Lines.Add('IP =' + DSConnectEventObject.ChannelInfo.ClientInfo.IpAddress + ':'
    + DSConnectEventObject.ChannelInfo.ClientInfo.ClientPort);

Need Your Help

Rails 3.2 and phonegap

ruby-on-rails ruby-on-rails-3 jquery-mobile mobile cordova

I have a rails application currently running ,I want to make a mobile application for it ,I don't want to learn objective-c or java ,I read many articles about phonegap and how I can use it to make a

RTMP streaming with OSMF - AS3

actionscript-3 osmf

New to OSMF and trying to play a streaming mp4 on our limelight server. According to this tutorial, you simply pass the RTMP lin...