You are not logged in.
Pages: 1
Hi AB.
how do I know who is making a call within an interface member?
Let me explain:
TServiceCalculator.Add function (n1, n2: integer): integer;
begin
// HERE!. Log ip, username of caller
result: = n1 + n2;
end;
Thanks
Offline
AFAIK you can do this
var
context: TServiceRunningContext;
user: Integer;
Begin
context := CurrentServiceContext;
user := context.Request.SessionUser;
End;
Regards
Offline
Indeed.
Or you can use directly the ServiceContext threadvar, but it would be a less efficient than a local copy.
For instance:
var
context: PServiceRunningContext;
RemoteIP: RawUTF8;
begin
context := @ServiceContext;
RemoteIP := FindIniNameValue(pointer(context.Request.Call.InHead),'REMOTEIP: ');
end;
See the documentation about ServiceContext threadvar, and in the SAD pdf.
Also note that a lot of information is already logged, including authenticated session, and IP of the caller.
I've just added Remote IP and Connection ID fields so that you can write now:
var context: PServiceRunningContext;
begin
context := @ServiceContext;
writeln(context.Request.SessionRemoteIP);
end;
Offline
You are magic
Offline
Pages: 1