/// <summary> /// Returns every character including the terminator /// </summary> /// <returns>All the digits in the buffer including terminators</returns> public string FlushDigitBuffer() { if (_stopped) { ResetAndThrowStop(); } return(Dialogic.FlushDigitBuffer(_devh)); }
public void Close() { if (_status != LineStatusTypes.OnHook) { Hangup(); } Dialogic.Close(_devh); }
public void WaitRings(int rings) { if (_stopped) { ResetAndThrowStop(); } _status = LineStatusTypes.AcceptingCalls; Dialogic.WaitRings(_devh, rings); _status = LineStatusTypes.Connected; if (_stopped) { ResetAndThrowStop(); } }
public void AddCustomTone(CustomTone tone) { if (tone.ToneType == CustomToneType.Single) { // TODO } else if (tone.ToneType == CustomToneType.Dual) { Dialogic.AddDualTone(_devh, tone.Tid, tone.Freq1, tone.Frq1Dev, tone.Freq2, tone.Frq2Dev, tone.Mode); } else if (tone.ToneType == CustomToneType.DualWithCadence) { Dialogic.AddDualToneWithCadence(_devh, tone.Tid, tone.Freq1, tone.Frq1Dev, tone.Freq2, tone.Frq2Dev, tone.Ontime, tone.Ontdev, tone.Offtime, tone.Offtdev, tone.Repcnt); } Dialogic.DisableTone(_devh, tone.Tid); }
public void RecordToFile(string filename, int timeoutMilliseconds) { if (_stopped) { ResetAndThrowStop(); } try { Dialogic.RecordToFile(_devh, filename, "0123456789#*abcd", _currentXpb, timeoutMilliseconds); } catch (StopException) { ResetAndThrowStop(); } catch (HangupException) { ResetAndThrowHangup(); } }
public void PlayFile(string filename) { if (_stopped) { ResetAndThrowStop(); } try { Dialogic.PlayFile(_devh, filename, "0123456789#*abcd", _currentXpb); } catch (StopException) { ResetAndThrowStop(); } catch (HangupException) { ResetAndThrowHangup(); } }
/// <summary> /// Keep prompting for digits until number of digits is pressed or a terminator digit is pressed. /// </summary> /// <param name="numberOfDigits">Maximum number of digits allowed in the buffer.</param> /// <param name="terminators">Terminators</param> /// <returns>Returns the digits pressed not including the terminator if there was one</returns> public string GetDigits(int numberOfDigits, string terminators) { if (_stopped) { ResetAndThrowStop(); } try { var answer = Dialogic.GetDigits(_devh, numberOfDigits, terminators); return(StripOffTerminator(answer, terminators)); } catch (StopException) { ResetAndThrowStop(); } catch (HangupException) { ResetAndThrowHangup(); } return(null); // will never get here }
public CallAnalysis Dial(string number, int answeringMachineLengthInMilliseconds) { if (_stopped) { ResetAndThrowStop(); } TakeOffHook(); Logger.Debug("Line is now off hook"); var dialToneTid = VoiceProperties.Current.DialTone.Tid; var noFreeLineTid = VoiceProperties.Current.NoFreeLineTone.Tid; var dialToneEnabled = false; if (VoiceProperties.Current.PreTestDialTone) { Logger.Debug("We are pre-testing the dial tone"); dialToneEnabled = true; Dialogic.EnableTone(_devh, dialToneTid); var tid = Dialogic.ListenForCustomTones(_devh, 2); if (tid == 0) { Logger.Debug("No tone was detected"); Dialogic.DisableTone(_devh, dialToneTid); Hangup(); return(CallAnalysis.NoDialTone); } } var index = number.IndexOf(','); if (VoiceProperties.Current.CustomOutboundEnabled && index != -1) { Logger.Debug("Custom dial-9 logic"); var prefix = number.Substring(0, index); number = number.Substring(index + 1).Replace(",", ""); // there may be more than one comma if (!dialToneEnabled) { Dialogic.EnableTone(_devh, dialToneTid); } Dialogic.EnableTone(_devh, noFreeLineTid); // send prefix (usually a 9) Dialogic.Dial(_devh, prefix); // listen for tones var tid = Dialogic.ListenForCustomTones(_devh, 2); Dialogic.DisableTone(_devh, dialToneTid); Dialogic.DisableTone(_devh, noFreeLineTid); if (tid == 0) { Hangup(); return(CallAnalysis.NoDialTone); } if (tid == noFreeLineTid) { Hangup(); return(CallAnalysis.NoFreeLine); } } else { if (dialToneEnabled) { Dialogic.DisableTone(_devh, dialToneTid); } } Logger.Debug("about to dial: {0}", number); var result = Dialogic.DialWithCpa(_devh, number, answeringMachineLengthInMilliseconds); Logger.Debug("CallAnalysis is: {0}", result.ToString()); if (result == CallAnalysis.Stopped) { ResetAndThrowStop(); } if (result == CallAnalysis.AnsweringMachine || result == CallAnalysis.Connected) { _status = LineStatusTypes.Connected; } else { Hangup(); } return(result); }
public void TakeOffHook() { _status = LineStatusTypes.OffHook; Dialogic.TakeOffHook(_devh); }
public void Hangup() { _status = LineStatusTypes.OnHook; Dialogic.Hangup(_devh); }
public void EnableTone(int tid) { Dialogic.EnableTone(_devh, tid); }
public void DisableTone(int tid) { Dialogic.DisableTone(_devh, tid); }
public void DeleteCustomTones() { Dialogic.DeleteTones(_devh); Dialogic.InitCallProgress(_devh); AddSpecialCustomTones(); }
public void Stop() { _stopped = true; Dialogic.Stop(_devh); }