I'm trying to determine the origin of the client IP within any Tcomponent based method of a VCL forms TCP datasnap server - without any channels (besides from the client having to send it). I also looked for a way to reference the server's connection info to retrieve the client's IP, but without success.
Was hoping to see procedure/function work something like the following:
procedure TServerMethods1.someTask(userId, taskId :integer; data:string);// can be a function
var
ip:string;
begin
ip := (ServerContainer1.TDSServer.GetThreadSession).GetData('RemoteIP');// client IP
// do stuff..
end;
TIA..
Based on your original question, and your subequent comments, this should answer your question.
procedure TServerContainer.DSServer1Connect(
DSConnectEventObject: TDSConnectEventObject);
var
user: String;
ClientInfo: TdbxClientInfo;
ipaddy: String;
begin
// note: this procedure gets called immediately AFTER DSAuthenticationManager1UserAuthenticate
user := TDSSessionManager.GetThreadSession.GetData('User');
ClientInfo := DSConnectEventObject.ChannelInfo.ClientInfo;
ipAddy := ClientInfo.IpAddress;
TDSSessionManager.GetThreadSession.PutData('ipaddy', ipAddy);
end;
procedure TServerMethods1.someTask(userId, taskId :integer; data:string);// can be a function
var
ip:string;
begin
ip := TDSSessionManager.GetThreadSession.GetData('ipaddy')
// do stuff..
end;