/// <summary> /// User put call on hold or retrieve /// </summary> /// <param name="session">session identification</param> public void OnUserHoldRetrieve(int session) { // check Hold or Retrieve IAbstractState state = this[session].State; if (state.Id == EStateId.ACTIVE) { this[session].State.holdCall(); } else if (state.Id == EStateId.HOLDING) { // execute retrieve // check if any ACTIVE calls if (this[EStateId.ACTIVE].Count > 0) { // get 1st and put it on hold IStateMachine sm = this[EStateId.ACTIVE][0]; if (!sm.IsNull) { sm.State.holdCall(); } // set Retrieve event pending for HoldConfirm _pendingAction = new PendingAction(EPendingActions.EUserHold, session); return; } this[session].State.retrieveCall(); } else { // illegal } }
public void onUserHoldRetrieve(int session) { IAbstractState state = this[session].State; if (state.Id == EStateId.ACTIVE) { this.getCall(session).State.holdCall(); } else if (state.Id == EStateId.HOLDING) { if (this.getNoCallsInState(EStateId.ACTIVE) > 0) { IStateMachine machine = ((List <IStateMachine>) this.enumCallsInState(EStateId.ACTIVE))[0]; if (!machine.IsNull) { machine.State.holdCall(); } this._pendingAction = new PendingAction(EPendingActions.EUserHold, session); } else { this[session].State.retrieveCall(); } } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { if ((this._parent.StateMachine == null)) { IStateMachine stateMachineCasted = item.As <IStateMachine>(); if ((stateMachineCasted != null)) { this._parent.StateMachine = stateMachineCasted; return; } } if ((this._parent.Source == null)) { IAbstractState sourceCasted = item.As <IAbstractState>(); if ((sourceCasted != null)) { this._parent.Source = sourceCasted; return; } } if ((this._parent.Target == null)) { IAbstractState targetCasted = item.As <IAbstractState>(); if ((targetCasted != null)) { this._parent.Target = targetCasted; return; } } }
/// <summary> /// Adds the given element to the collection /// </summary> /// <param name="item">The item to add</param> public override void Add(IModelElement item) { IAbstractState statesCasted = item.As <IAbstractState>(); if ((statesCasted != null)) { this._parent.States.Add(statesCasted); } }
/// <summary> /// Removes the given item from the collection /// </summary> /// <returns>True, if the item was removed, otherwise False</returns> /// <param name="item">The item that should be removed</param> public override bool Remove(IModelElement item) { IAbstractState abstractStateItem = item.As <IAbstractState>(); if (((abstractStateItem != null) && this._parent.States.Remove(abstractStateItem))) { return(true); } return(false); }
// returns ( (this |_| ias) > this ) i.e. whether ias had tainted variables that did not exist in this public bool JoinWith(IAbstractState ias) { TaintSet t = (TaintSet)ias; bool added = false; foreach (var v in t) { if (!Contains(v)) { this.Add(v); added = true; } } return(added); }
/// <summary> /// Call/Session constructor. Initializes call states, creates signaling proxy, initialize time, /// initialize timers. /// </summary> public CStateMachine() { // store manager reference... _manager = CCallManager.Instance; // create call proxy _sigProxy = _manager.StackProxy.createCallProxy(); // create media proxy for this call _mediaProxy = new Sipek.Sip.pjsipMediaPlayerProxy(); // 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 = 60000; // hardcoded to 60s _noreplyTimer.Elapsed = new TimerExpiredCallback(_noreplyTimer_Elapsed); //_releasedTimer = _manager.Factory.createTimer(); //_releasedTimer.Interval = 1000; // hardcoded to 1s //_releasedTimer.Elapsed = new TimerExpiredCallback(_releasedTimer_Elapsed); _noresponseTimer = _manager.Factory.CreateTimer(); _noresponseTimer.Interval = 60000; // hardcoded to 60s _noresponseTimer.Elapsed = new TimerExpiredCallback(_noresponseTimer_Elapsed); } }
/// <summary> /// User put call on hold or retrieve /// </summary> /// <param name="session">session identification</param> public void OnUserHoldRetrieve(int session) { // check Hold or Retrieve IAbstractState state = this[session].State; if (state.Id == EStateId.ACTIVE) { this[session].State.holdCall(); } else if (state.Id == EStateId.HOLDING) { // execute retrieve // check if any ACTIVE calls HoldActiveCalls(new PendingAction(EPendingActions.EUserHold, session)); this[session].State.retrieveCall(); } else { // illegal } }
// returns ( (this |_| ias) > this ) i.e. whether ias has dependencies that did not exists in this public bool JoinWith(IAbstractState state) { bool added = false; Dependencies d = (Dependencies)state; foreach (var v in d.Keys) { if (!ContainsKey(v)) { this[v] = new VarSet(d[v]); } else if (!this[v].IsSupersetOf(d[v])) { this[v].UnionWith(d[v]); } else { continue; } added = true; } return(added); }
/// <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(); }