#1 2013-11-14 21:50:20

nirnir
Member
Registered: 2013-11-11
Posts: 66

using CurrentServiceContext.Factory.RestServer.SessionGetUser

sorry for my misunderstanding but I couldn't figure it by myself .
I want to retrieve the current thread user details in the context of sample 14  TServiceCalculator.add method (server side)
SessionGetUser is protected method and not accessible  and where do I take from the aSessionID parameter .

Offline

#2 2013-11-15 15:33:49

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: using CurrentServiceContext.Factory.RestServer.SessionGetUser

You are right.

TSQLRestServer.SessionGetUser method is now made public (e.g. when calling CurrentServiceContext.Factory.RestServer.SessionGetUser).
See http://synopse.info/fossil/info/7097ca9b63

Thanks for the feedback.

Offline

#3 2013-11-15 16:04:25

nirnir
Member
Registered: 2013-11-11
Posts: 66

Re: using CurrentServiceContext.Factory.RestServer.SessionGetUser

Thanks,
and aSessionID  is  TSQLRestClientURI(ServiceRunningContext.Factory.RestServer).SessionID   ?

Last edited by nirnir (2013-11-15 16:05:29)

Offline

#4 2013-11-16 11:40:07

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,206
Website

Re: using CurrentServiceContext.Factory.RestServer.SessionGetUser

No, here RestServer is a TSQLRestServer, not a TSQLRestClientURI!!!
Never typecast like this in your code.

You should better write instead:

(ServiceRunningContext.Factory.RestServer as TSQLRestClientURI).SessionID

you would have an explicit casting error at run-time, whereas your TSQLRestClientURI() will force the casting with no check, so would lead into random issues.

In your case, you can use ServiceContext.Request.Session - as stated by the documentation of ServiceContext.Request.

And in fact, you have a reference to the server instance at ServiceContext.Request.Server, which should be = to ServiceRunningContext.Factory.RestServer.

Offline

Board footer

Powered by FluxBB