示例#1
0
        public CallAnalysis Dial(string number, int answeringMachineLengthInMilliseconds)
        {
            if (_stopped)
            {
                ResetAndThrowStop();
            }
            if (_hungup)
            {
                ResetAndThrowHangup();
            }

            var phone = Phone.GetPhone(number);

            if (phone == null)
            {
                return(CallAnalysis.NoAnswer);
            }
            var result = phone.Dial(this);

            if (result == CallAnalysis.AnsweringMachine || result == CallAnalysis.Connected)
            {
                _status = LineStatusTypes.Connected;
            }
            return(result);
        }
示例#2
0
 private void Reset()
 {
     _hungup  = false;
     _stopped = false;
     _digits  = new List <char>();
     _status  = LineStatusTypes.OnHook;
 }
示例#3
0
        public void WaitRings(int rings)
        {
            _status   = LineStatusTypes.AcceptingCalls;
            _ringsGot = 0;

            lock (_lockObject)
            {
                while (true)
                {
                    if (_stopped)
                    {
                        ResetAndThrowStop();
                    }
                    if (_hungup)
                    {
                        _ringsGot = 0;
                        Reset();
                        _status = LineStatusTypes.AcceptingCalls;
                    }
                    if (_ringsGot >= rings)
                    {
                        _status = LineStatusTypes.Connected;
                        // tell the thread that called sendRing method that it is ok to continue
                        AllDone.Set();
                        return;
                    }

                    // tell the thread that called sendRing method that it is ok to continue
                    AllDone.Set();

                    Monitor.Wait(_lockObject); // wait indefinetly
                }
            }
        }
示例#4
0
 private void ResetAndThrowHangup()
 {
     Reset();
     _status = LineStatusTypes.OnHook;
     throw new HangupException();
 }
示例#5
0
 public void TakeOffHook()
 {
     _status = LineStatusTypes.OffHook;
 }
示例#6
0
 // tell listeners that the software has manually hung up the phone
 public void Hangup()
 {
     _status = LineStatusTypes.OnHook;
     DispatchHangupEvent(); // tell virtual phone that the program performed a hangup
 }