Ejemplo n.º 1
0
        public void Transfer(string number)
        {
            Action method = new Action(() =>
            {
                string num = Globals.NormalizeTelNumber(number);
                if (number.Length >= 9 && Settings.Prefix0)
                {
                    num = "0" + num;
                }
                IStateMachine call;
                if (CallManager.getNoCallsInState(EStateId.ACTIVE) > 0)
                {
                    call = CallManager.getCallInState(EStateId.ACTIVE);
                }
                else
                {
                    call = CallManager.getCallInState(EStateId.INCOMING);
                }
                ICallProxyInterface proxy = StackProxy.createCallProxy();
                proxy.SessionId           = call.Session;
                if (call.StateId == EStateId.ACTIVE)
                {
                    proxy.holdCall();
                    proxy.xferCall(num);
                }
                else
                {
                    CallManager.onUserTransfer(call.Session, num);
                }
            });

            if (this.InvokeRequired)
            {
                this.Invoke((MethodInvoker) delegate { method(); });
            }
            else
            {
                method();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="callId"></param>
        /// <param name="callState"></param>
        private void OnCallStateChanged(int callId, ESessionState callState, string info)
        {
            if (callState == ESessionState.SESSION_STATE_INCOMING)
            {
                IStateMachine incall = Factory.createStateMachine();
                // couldn't create new call instance (max calls?)
                if (incall.IsNull)
                {
                    // check if CFB, activate redirection
                    if (Config.CFBFlag == true)
                    {
                        // get stack proxy
                        ICallProxyInterface proxy = StackProxy.createCallProxy();
                        // assign callid to the proxy...
                        //proxy.SessionId = callId;
                        proxy.serviceRequest((int)EServiceCodes.SC_CFB, Config.CFBNumber);
                        return;
                    }
                }
                // save session parameters
                incall.Session = callId;

                // check if callID already exists!!!
                if (CallList.ContainsKey(callId))
                {
                    // shouldn't be here
                    // release the call
                    CallList[callId].State.endCall();
                    return;
                }
                // add call to call table
                _calls.Add(callId, incall);

                return;
            }

            IStateMachine call = this[callId];

            if (call.IsNull)
            {
                return;
            }

            switch (callState)
            {
            case ESessionState.SESSION_STATE_CALLING:
                //sm.getState().onCalling();
                break;

            case ESessionState.SESSION_STATE_EARLY:
                call.State.onAlerting();
                break;

            case ESessionState.SESSION_STATE_CONNECTING:
                call.State.onConnect();
                break;

            case ESessionState.SESSION_STATE_DISCONNECTED:
                call.State.onReleased();
                break;
            }
        }