Ejemplo n.º 1
0
 /// <summary>
 /// Change state
 /// </summary>
 /// <param name="state">instance of state to change to</param>
 private void ChangeState(IAbstractState state)
 {
   _state.OnExit();
   _state = state;
   _state.OnEntry();
 }
Ejemplo n.º 2
0
    /// <summary>
    /// Call/Session constructor. Initializes call states, creates signaling proxy, initialize time,
    /// initialize timers.
    /// </summary>
    /// <param name="manager">reference to call manager</param>
    public CStateMachine()
    {
      // store manager reference...
      _manager = CCallManager.Instance;

      // create call proxy
      _sigProxy = _manager.StackProxy.createCallProxy();

      // initialize call states
      _stateIdle = new CIdleState(this);
      _stateAlerting = new CAlertingState(this);
      _stateActive = new CActiveState(this);
      _stateCalling = new CConnectingState(this);
      _stateReleased = new CReleasedState(this);
      _stateIncoming = new CIncomingState(this);
      _stateHolding = new CHoldingState(this);
      _stateTerminated = new CTerminatedState(this);
      // change state
      _state = _stateIdle;
      
      // initialize data
      Time = DateTime.Now;
      Duration = TimeSpan.Zero;

      // Initialize timers
      if (null != _manager)
      { 
        _noreplyTimer = _manager.Factory.createTimer();
        _noreplyTimer.Interval = 15000; // hardcoded to 15s
        _noreplyTimer.Elapsed = new TimerExpiredCallback(_noreplyTimer_Elapsed);

        _releasedTimer = _manager.Factory.createTimer();
        _releasedTimer.Interval = 5000; // hardcoded to 5s
        _releasedTimer.Elapsed = new TimerExpiredCallback(_releasedTimer_Elapsed);

        _noresponseTimer = _manager.Factory.createTimer();
        _noresponseTimer.Interval = 60000; // hardcoded to 60s
        _noresponseTimer.Elapsed = new TimerExpiredCallback(_noresponseTimer_Elapsed);

      }
    }