Source/NFX.Wave/Filters/SessionFilter.cs
/// <summary>
/// Override to get session object using whatever parameters are available in response context (i.e. a cookie),
/// or create a new one if 'onlyExisting'=false(default)
/// </summary>
Override to get session object using whatever parameters are available in response context ,
or create a new one if 'onlyExisting'=false(default)
Override to get session object using whatever parameters are available in response context or create a new one if ' onlyExisting ' = false ( default )
protected internal virtual void FetchExistingOrMakeNewSession(WorkContext work, bool onlyExisting = false)
      {
        if (work.Session!=null) return;
        WaveSession session = null;
        ulong sidSecret = 0;
        var sid = ExtractSessionID(work, out sidSecret);
        if (sid.HasValue)
        {
          session = App.ObjectStore.CheckOut(sid.Value) as WaveSession;
          if (session!=null && session.IDSecret!=sidSecret)
          {
            App.ObjectStore.UndoCheckout(sid.Value);
            session = null;
            if (Server.m_InstrumentationEnabled)
              Interlocked.Increment(ref Server.m_stat_SessionInvalidID);
          }
        }
        var foundExisting = true;
        if (session==null)
        {
          if (onlyExisting)
          {
            session = TryMakeSessionFromExistingLongTermToken(work);
            if (session==null) return;
          }
          if (session==null)
          {
            foundExisting = false;
            if (NetGate!=null && NetGate.Enabled)
               NetGate.IncreaseVariable(IO.Net.Gate.TrafficDirection.Incoming,
                                     work.EffectiveCallerIPEndPoint.Address.ToString(),
                                     NETGATE_NEWSESSION_VAR_NAME,
                                     1);
            session = MakeNewSession(work);
          }
        }
        if (foundExisting && Server.m_InstrumentationEnabled)
           Interlocked.Increment(ref Server.m_stat_SessionExisting);
        session.Acquire();
        if (work.GeoEntity!=null)
          session.GeoEntity = work.GeoEntity;
        work.m_Session = session;
        ApplicationModel.ExecutionContext.__SetThreadLevelSessionContext(session);
        work.SetAuthenticated(session.User.IsAuthenticated);
      }
protected internal virtual void FetchExistingOrMakeNewSession ( WorkContext work , bool onlyExisting = false ) { if ( work . Session != null ) return ; WaveSession session = null ; ulong sidSecret = 0 ; var sid = ExtractSessionID ( work , out sidSecret ) ; if ( sid . HasValue ) { session = App . ObjectStore . CheckOut ( sid . Value ) as WaveSession ; if ( session != null && session . IDSecret != sidSecret ) { App . ObjectStore . UndoCheckout ( sid . Value ) ; session = null ; if ( Server . m_InstrumentationEnabled ) Interlocked . Increment ( ref Server . m_stat_SessionInvalidID ) ; } } var foundExisting = true ; if ( session == null ) { if ( onlyExisting ) { session = TryMakeSessionFromExistingLongTermToken ( work ) ; if ( session == null ) return ; } if ( session == null ) { foundExisting = false ; if ( NetGate != null && NetGate . Enabled ) NetGate . IncreaseVariable ( IO . Net . Gate . TrafficDirection . Incoming , work . EffectiveCallerIPEndPoint . Address . ToString ( ) , NETGATE_NEWSESSION_VAR_NAME , 1 ) ; session = MakeNewSession ( work ) ; } } if ( foundExisting && Server . m_InstrumentationEnabled ) Interlocked . Increment ( ref Server . m_stat_SessionExisting ) ; session . Acquire ( ) ; if ( work . GeoEntity != null ) session . GeoEntity = work . GeoEntity ; work . m_Session = session ; ApplicationModel . ExecutionContext . __SetThreadLevelSessionContext ( session ) ; work . SetAuthenticated ( session . User . IsAuthenticated ) ; }
Override to get session object using whatever parameters are available in response context (i.e.
Override to get session object using whatever parameters are available in response context ( i . e .
//The secret password does not match //20160124 DKh to use long term tokens //if (onlyExisting) return;//do not create anything //do not create anything
work
WorkContext
onlyExisting
bool