Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
overriding session creation call
#1
Hi folks,

I am trying to override DoNewSession() event to write custom code on "/$/Start" call. 

What I am facing is that when DoNewSession event is not getting called when "/$/Start" call is received on server instead the thread directly goes to AfterDispatch event from HttpExecute()->DoCommandGet().

I have tried to override rather redefine BaseNewSession, BaseOnConfig, BaseBeforeDispatch but nothing worked.

My redefined functions are calling for other API calls but for /$/Start.

Any leads would help.

Here's the sample code:

Code:
procedure TIWServerController.IWServerControllerBaseNewSession(
  ASession: TIWApplication); 
var
  lRequest: THttpRequest;
  lSession: TIWUserSession;
  lPath: String;
begin
  //TODO only create this when new user is logging on

  ASession.Data := TIWUserSession.Create(nil, ASession);

  lPath := ASession.Request.PathInfo;

  if (lPath = '/$/start') or
    (ServerGlobals.SessionPaths.IndexOf(lPath) <> -1) then
  begin
    SetNewSessionInfo(ASession, ASession.Data); //custom function to fill session info
  end;
end;
My breakpoint doesn't hit here on /$/Start call.
Reply
#2
First things first: The event name is OnNewSession. DoNewSession() is a public method that triggers the event. As a general recommendation, there is no need to call or change DoNewSession() method in any way.

Now, the event OnNewSession is not triggered when receiving /$/Start request. The /$/Start request will trigger a different request to the application root URL (usually just "/") and this is the actual request that will create a new session and trigger the event.

Regarding your code: there is no need for any check in there. This event is only called once per session, when the session is created, regarldess of the PathInfo content. You just need to call SetNewSessionInfo() after ASession.Data has been assigned. It will just work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)