static void Main(string[] args) { TapiManager z = new TapiManager("SimpleCall"); z.Initialize(); TapiLine[] phone = z.Lines; TapiLine line = phone[16]; Console.WriteLine(line); line.Open(MediaModes.Modem); Console.WriteLine(line.Capabilities.MediaModes); }
private void _btnStartStop_Click(object sender, EventArgs e) { TapiLine line = CurrentLine; if (line.IsOpen) { line.Close(); ChangeButtonStates(); } else { try { line.Open(line.Capabilities.MediaModes); } catch (TapiException) { line.Open(MediaModes.DataModem); } ChangeButtonStates(); } }
static void RunCommTest() { TapiManager mgr = new TapiManager("EnumDevices"); mgr.Initialize(); foreach (TapiLine lineEx in mgr.Lines) { Console.WriteLine(lineEx.Name); } TapiLine line = mgr.GetLineByName("Conexant D110 MDC V.92 Modem", true); if (line != null) { line.Open(MediaModes.DataModem); TapiCall call = line.Addresses[0].MakeCall("2145551212"); Console.WriteLine(call.GetCommDevice()); try { using (FileStream fs = call.GetCommStream()) { byte[] data = ASCIIEncoding.ASCII.GetBytes("Hello"); fs.Write(data, 0, data.Length); using (StreamReader sr = new StreamReader(fs)) { Console.WriteLine(sr.ReadToEnd()); } } call.Drop(); } catch (Exception ex) { call.Drop(); while (ex != null) { Console.WriteLine("{0}", ex.ToString()); ex = ex.InnerException; } } } else { Console.WriteLine("Not found."); } Console.ReadLine(); mgr.Shutdown(); }
//line 2 private void button2_Click(object sender, EventArgs e) { try { objLine2 = (TapiLine)comboBox2.SelectedItem; if (objLine2 == null) { throw new NullReferenceException("LINE IS NULL"); } if (objLine2.IsOpen) { throw new ArgumentOutOfRangeException("Already Monitoring Line"); } objLine2.RingsToAnswer = 0; objLine2.Open(true, null); AddToLog("Started monitoring line " + objLine2.Name); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void buttonDial_Click(object sender, EventArgs e) { startConference = false; timer1.Enabled = false; try { if (!String.IsNullOrEmpty(_internalAgentPhone)) { line = TapiApp.Lines.SingleOrDefault(q => q.Name.Contains(_internalAgentPhone)); } else { line = TapiApp.Lines.SingleOrDefault(q => q.Name.Contains(comboBoxLine.Text)); } if (line == null) { return; } if (!line.IsOpen) { line.Open(false, CallHandler); } line.DisconnectOnBusy = true; line.NoAnswerTimeout = 15; ActiveCall = line.Dial(txtPhone1.Text, false); string msg = String.Format("شماره گیری {0} بر روی خط '{1}'", txtPhone2.Text, line.Name); AddToLog(msg); bool completed = false; while (!completed) { Application.DoEvents(); if (ActiveCall.State == TapiCallState.Connected) { ActiveCall.Hold(); TapiCall consulationCall = line.Dial(txtPhone2.Text.Trim(), false); while (!completed) { if (consulationCall.State == TapiCallState.Connected) { ActiveCall.CompleteTransfer(consulationCall, false); ActiveCall.Disconnect(); completed = true; } else if (consulationCall.State == TapiCallState.Disconnected) { completed = true; Application.Exit(); } } } else if (ActiveCall.State == TapiCallState.Disconnected) { completed = true; Application.Exit(); } } } catch (TapiException exc) { MessageBox.Show(exc.Message, "TapiException!", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Exception!", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } }
/* rock'n roll */ public void startSession() { App.log("TAPI - Start session"); if (!App.Setup.IsTapiSessionActive) { App.Setup.IsTapiSessionActive = true; if (currentLine != null) { if (currentLine.IsOpen) { App.log("TAPI line is already open. There is no need to open it!"); } else { bool hasBeenOpened = false; try { currentLine.Open(currentLine.Capabilities.MediaModes); App.log(String.Format("Opened TAPI line '{0}' (MediaModes)", currentLine.Name)); hasBeenOpened = true; } catch (TapiException te) { App.log(te.Message); } catch (Exception ex) { App.log(ex.Message); } if (!hasBeenOpened) { App.log("Unable to open line in Capabilities MediaModes - attempt to open line in MediaModes.DataModem"); try { currentLine.Open(MediaModes.DataModem); App.log(String.Format("Opened TAPI line '{0}' (alternative DataModem)", currentLine.Name)); hasBeenOpened = true; } catch (TapiException te) { App.log(te.Message); } catch (Exception ex) { App.log(ex.Message); } } if (hasBeenOpened) { refreshStateFlags(); if (currentLine.IsOpen) { App.log(String.Format("Current line object 'IsOpen' state is '{0}'", currentLine.IsOpen)); } } else { App.log("TAPI line couldn't been opened."); } } } else { App.log("Current line object is null"); } } else { App.log("Session was marked as already active!"); } }