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); }
private void Reset() { _hungup = false; _stopped = false; _digits = new List <char>(); _status = LineStatusTypes.OnHook; }
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 } } }
private void ResetAndThrowHangup() { Reset(); _status = LineStatusTypes.OnHook; throw new HangupException(); }
public void TakeOffHook() { _status = LineStatusTypes.OffHook; }
// 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 }