I'm running some Datasnap tests with REST and json.
There in Unit ServerMethods, which Delphi itself creates, has the "ReverseString" function, but well, how do I know who sent it?
I would like to keep a log of information from the clients who called this method.
I know it could be passed as a parameter, but it would be the responsibility of the client to pass this information to me, which I do not want, let's say the method would be public and several clients would be triggering this information. I can easily lose this control, if I do not get the information directly by the control of the server.
I found on the web, that in the ServerConteiner unit, has a "DSServer" object, this object has an event called "OnConnect", so it can get the following sa data:
Procedure TServerContainer1.DSServer1Connect (
DSConnectEventObject: TDSConnectEventObject);
Begin
DSConnectEventObject.ChannelInfo.ClientInfo.IpAddress;
DSConnectEventObject.ChannelInfo.ClientInfo.ClientPort;
DSConnectEventObject.ChannelInfo.ClientInfo.Protocol;
DSConnectEventObject.ChannelInfo.ClientInfo.AppName;
End;
But I am not able to find how there in ServerMethods.ReverseString I can get this data ...
I believe that the processing is in thread on the server, so I can not pass this value as global, because it can pick up information from other simultaneous connections.
In the method, ReverseString, I tried as follows:
Var
ADSServerClass: TDSServerClass;
Begin
ADSServerClass: = TDSServerClass (GetOwner);
TDSServer (ADSServerClass.Server). ???
// I got to the server, but I can not find it, and I do not know if it is this way to find the data of who is requesting me to execute the ReverseString
End;