private void btnInit_Click(object sender, EventArgs e) { try { pmAgent.strSoftPhoneNum = this.txtSoftPhoneNum.Text; pmAgent.strLeftPhoneNum = this.txtLeftHandleNum.Text; pmAgent.strRightPhoneNum = this.txtRightHandleNum.Text; pmAgent.strSoftPhonePwd = this.txtSoftPhonePwd.Text; string[] strTemp = this.txtSipServerIP.Text.ToString().Split(':'); strSipServerIP = strTemp[0]; if (strTemp.Length > 1) { if (strTemp[1] == "") { nSipPort = 5060; } else { nSipPort = DispatchClient.Base.atoi(strTemp[1]); } } if (strSipServerIP == "") { strSipServerIP = strDispatchServerIP; } pmPhone.strSipServerIP = strSipServerIP; pmPhone.nServerPort = nSipPort; pmPhone.nLocalPort = 6060; pmPhone.strLocalIP = this.txtLocalIP.Text; if (!pmPhone.IsRegistered && (pmAgent.nStatus == e_Status.nLogin))//注册 { SIPPhoneSDK.SDKInit(pmPhone.strLocalIP, pmPhone.nLocalPort); LoadDevices(); pmPhone.IsRegistered = SIPPhoneSDK.Regist(pmPhone.strSipServerIP + ":" + pmPhone.nServerPort, pmAgent.strSoftPhoneNum, pmAgent.strSoftPhonePwd); if (pmPhone.IsRegistered) { this.Invoke((EventHandler)(delegate { this.btnInit.Text = "注销"; })); } string strInfo = String.Format("DTC->DTS; KEY=REGISTERSOFTPHONE; SOFTPHONENUM={0}; RESULT={1};", pmAgent.strSoftPhoneNum, pmPhone.IsRegistered.ToString()); ShowDebugInfo(strInfo); } else//注销 { SIPPhoneSDK.UnRegist(); SIPPhoneSDK.SDKDestory(); this.Invoke((EventHandler)(delegate { this.btnInit.Text = "注册"; pmPhone.IsRegistered = false; })); } } catch (System.Exception ex) { ShowDebugInfo(ex.ToString()); } }
private void AllClear() { this.EmployeeTree.Nodes.Clear(); this.RadioTree.Nodes.Clear(); this.VideoDeviceTree.Nodes.Clear(); this.VideoEmployeeTree.Nodes.Clear(); if (Base.g_GroupNum_IsLoaded != null) { Base.g_GroupNum_IsLoaded.Clear(); } Base.g_VideoTreeRootNode = null; if (pmPhone.IsRegistered) { SIPPhoneSDK.UnRegist(); pmPhone.IsRegistered = false; } }