Example #1
0
        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();
        }