CgwMonitorManage.T28181.SipStackAdapter.StartKeepalive C# (CSharp) Method

StartKeepalive() public method

sip保活
public StartKeepalive ( string serverID, string localID ) : void
serverID string
localID string
return void
        public void StartKeepalive(string serverID, string localID)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: T28181VideoMonitor.StartConnectRegisterSip().");
            EM_SIP_RESULT iRet = EM_SIP_RESULT.RET_FAILURE;
            //初始话定时器
            this.keepLiveTimer.AutoReset = true;
            this.keepLiveTimer.Elapsed += new System.Timers.ElapsedEventHandler((x, y)
                =>
                {
                    //sip保活,deviceID为用户名
                    string strBody = @"<?xml version='1.0'?><Notify><CmdType>Keepalive</CmdType><SN>" + KeepaliveSN + "</SN><DeviceID>" + localID + "</DeviceID><Status>OK</Status></Notify>";
                    KeepaliveSN++;
                    iRet = SipSDKInterface.SIP_SDK_MESSAGE(serverID, strBody);
                    if (iRet != EM_SIP_RESULT.RET_SUCCESS)
                    {
                        logEx.Warn("SipStackAdapter.Keepalive Failed");
                        //保活失败,重新注册. zWX231378 .2015/6/24
                        SIP_SDK_REGISTER();
                    }
                    else
                    {
                        logEx.Trace("SipStackAdapter.Keepalive Success");
                    }
                });
            //保活时间为10秒
            this.keepLiveTimer.Interval = CgwConst.Thread_Sleep_Time * 10;
            keepLiveTimer.Start();
        }