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(); }
public static void start() { // Console.ReadLine(); while (true) { // { if (_mgr.Initialize()) { // _mgr.NewCall += NewCall; // _mgr.LineChanged += LineChanged; // _mgr.CallInfoChanged += CallInfoChanged; // _mgr.CallStateChanged += CallStateChanged; TapiLine line = _mgr.GetLineByName("EXTENSION 200 Keyset", false); if (line != null) { try { // //line.Monitor(); Console.WriteLine("Line: {0} opened!", line.Name); line.NewCall += new EventHandler <NewCallEventArgs>(NewCall); ; line.Changed += new EventHandler <LineInfoChangeEventArgs>(Changed); line.CallInfoChanged += new EventHandler <CallInfoChangeEventArgs>(CallInfoChanged); line.CallStateChanged += new EventHandler <CallStateEventArgs>(CallStateChanged); line.AddressChanged += new EventHandler <AddressInfoChangeEventArgs>(AddressChanged); line.Monitor(); // line.Open(line.Capabilities.MediaModes); Console.WriteLine("Monitoring Started!"); } catch (TapiException e) { Console.WriteLine(e); throw; } _mgr.Shutdown(); } } } }