基本信息
源码名称:lumisoft 实例开发 抢号专用(电话外呼)
源码大小:0.99M
文件格式:.rar
开发语言:C#
更新时间:2015-03-11
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
lumisoft 实例开发 抢号专用



 

bool loginsta = false;
            string user = this._AccountUser.AccountID;
            string password = this._AccountUser.Password;
            string Domain = this._AccountUser.DomainName;
            int express = 60;
            string strHostName = Dns.GetHostName();  //得到本机的主机名
            IPHostEntry ipEntry = Dns.GetHostByName(strHostName); //取得本机IP
            string strAddr = ipEntry.AddressList[0].ToString(); //假设本地主机为单网卡

            if (this.m_pStack == null)
            {
                m_pStack = new SIP_Stack();
                //this.m_pStack.Dispose();
                m_pStack.UserAgent = "Szghe";
                m_pStack.BindInfo = new IPBindInfo[] { new IPBindInfo("", BindInfoProtocol.UDP, IPAddress.Any, m_SipPort) };
                m_pStack.Credentials.Add(new NetworkCredential(user, password, Domain));
                m_pStack.Error = new EventHandler<ExceptionEventArgs>(m_pStack_Error);
                m_pStack.RequestReceived = new EventHandler<SIP_RequestReceivedEventArgs>(m_pStack_RequestReceived);
                m_pStack.Start();
            }
            AbsoluteUri url = AbsoluteUri.Parse("sip:" user "@" strAddr ":7666");   //这个IP地址没用
            SIP_Uri serveruri = new SIP_Uri();
            serveruri.Host = this._AccountUser.DomainName;
            serveruri.Port = this._AccountUser.Port;
            string aro = user "@" serveruri.Host;
            serveruri.User = this._AccountUser.AccountID;     //没有作用?
            Registration = m_pStack.CreateRegistration(serveruri, aro, url, express);
            Registration.StateChanged = new EventHandler(Registration_StateChanged);
            Registration.Error = new EventHandler<SIP_ResponseReceivedEventArgs>(Registration_Error);
            Registration.BeginRegister(true);

            Thread.Sleep(400);
            if (Registration != null && Registration.State == SIP_UA_RegistrationState.Registered)
            {
                this.RegState = true;
                return true;
            }
            if (Registration != null && Registration.State != SIP_UA_RegistrationState.Registered)
            {
                Thread.Sleep(800);
                if (Registration != null && Registration.State == SIP_UA_RegistrationState.Registered)
                {
                    this.RegState = true;
                    return true;
                }
                else
                {
                    this.RegState = false;
                    LogFile.Write("SIP注册时发生错误 ", "Error");
                }
            }
            return loginsta;
        }
        void Registration_Error(object sender, SIP_ResponseReceivedEventArgs e)
        {
            SIP_Response ss = e.Response;
        }
        void Registration_StateChanged(object sender, EventArgs e)
        {
            string ss = e.ToString();
        }
        public bool UnRegServer()
        {
            bool RegResult = true;
            try
            {
                this.Registration.BeginUnregister(true);
                this.RegState = false;
            }
            catch (Exception ex)
            {
                LogFile.Write("注销SIP服务器失败:" ex.Message, "ERROR");
            }
            return RegResult;