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();
        }
Example #2
0
        public bool Divert(string callid, string caller)
        {
            TapiCall    call    = null;
            TapiAddress address = GetAddress(caller);
            bool        success = false;

            if (address != null)
            {
                foreach (TapiCall tc in address.Calls)
                {
                    if (tc.Id.ToString() == callid)
                    {
                        call = tc;
                        break;
                    }
                }
                if (call != null)
                {
                    log.Debug("Divert call " + callid + " from " + caller);
                    try
                    {
                        call.Drop();
                        success = true;
                    }
                    catch (Exception e)
                    {
                        log.Debug("Unable to drop call, " + e.Message);
                    }
                }
            }
            return(success);
        }
Example #3
0
        public bool HangUp(string caller, string callid)
        {
            TapiCall    call    = null;
            TapiAddress address = GetAddress(caller);
            bool        success = false;

            if (address != null)
            {
                foreach (TapiCall tc in address.Calls)
                {
                    if (tc.Id.ToString() == callid)
                    {
                        call = tc;
                        break;
                    }
                }
                if (call != null)
                {
                    log.Debug("Hanging up call " + callid + " from " + caller);
                    call.Drop();
                    success = true;
                }
            }
            return(success);
        }
Example #4
0
        private void ActiveCallForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                _call.Drop();
            }
            catch
            {
            }

            _call.Line.CallInfoChanged  -= OnCallInfoChange;
            _call.Line.CallStateChanged -= OnCallStateChange;

            try
            {
                _call.Dispose();
            }
            catch
            {
            }
        }