示例#1
0
        void Logout()
        {
            try
            {
#if USE_AHEAD_VOIP
                if (ocx != null)
                {
                    ocx.LXSipUnregister();
                    ocx = null;
                }
#else
                if (m_connection != null)
                {
                    m_connection.Send("103/{0}/|", m_agent); //退出登录
                    m_connection.Dispose();
                    m_connection = null;
                    //清理现场  //add by niwz 2018.03.13
                    if (frmDialup != null)
                    {
                        frmDialup.Dispose();
                        frmDialup = null;
                    }
                    //
                    if (frmWay != null)
                    {
                        frmWay.Dispose();
                        frmWay = null;
                    }
                    m_cur_joincaller   = string.Empty;
                    m_caller_muted     = false;
                    m_joincaller_muted = false;
                }
#endif
                //
                TuneControl(false);
            }
            catch { }
        }
示例#2
0
        void Login()
        {
#if USE_AHEAD_VOIP
            //if (ocx != null)
            //    return;
#else
            if (m_connection != null)
            {
                m_connection.Close();
                m_connection = null;
            }
#endif
            try
            {
                ShowStatus("正在登录");
                string serverIp = tb_ipaddress.Text;
                int    port     = int.Parse(tb_port.Text);
                string passwd   = tb_password.Text;
#if USE_AHEAD_VOIP
                int iRet = ocx.LXSipRegister(0, serverIp, serverIp, port, m_agent, m_agent, passwd);
                ocx.OnLXVoipMsg += Ocx_OnLXVoipMsg;
                if (iRet == DevOK)
                {
                    //启动Http监听服务,供页面调用软外拨功能
                    _server.Open(null);
                    ShowStatus("空闲");
                }
                else
                {
                    if (iRet == -12)
                    {
                        ShowStatus("连接失败");
                    }
                    //登录失败
                    TuneControl(false);
                }
#else
                TcpClient clnt = new TcpClient();
                clnt.Connect(serverIp, port);
                m_connection             = new LXTcpConnection(clnt);
                m_connection.OnReceived += OnReceivedData;
                m_connection.OnOpened   += (c) =>
                {
                    ShowStatus("已连接");
                    //发送登录信息
                    c.Send("102/{0}/{1}/{2}////|", m_agent, m_employee, passwd);
                    //启动Http监听服务,供页面调用软外拨功能
                    _server.Open(null);
                };
                m_connection.OnClosed += (c) =>
                {
                    ShowStatus("连接断开");
                    _server.Close();
                    TuneControl(false);
                    TuneQueueInfo(false);
                };
                m_connection.Open(null);
#endif
            }
            catch (Exception ex)
            {
                LogHelper.Write("ConnectHost", ex);
                ShowStatus("连接失败");
                if (this.InvokeRequired)
                {
                    this.BeginInvoke(new MethodInvoker(Show));
                }
                else
                {
                    this.Show();
                }
                TuneControl(false);
            }
        }