Пример #1
0
        private void but_SignOut_Click(object sender, EventArgs e)
        {
            ///*协议体*/
            //StringBuilder strBody = new StringBuilder();
            //strBody.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
            //strBody.Append("<User>[email protected]</User>");
            //strBody.Append("</Message>");
            ///*协议头*/
            //int len = strBody.ToString().Length;
            //string strheader = "";
            //strheader = GetAgreementHeader(1008, len);
            //string contentStr = strheader.ToString() + strBody.ToString();
            ///*发送指令*/
            //string sendStr = contentStr;
            //byte[] sendBytes = Encoding.GetEncoding("gb2312").GetBytes(sendStr);
            //int num = clientSocket.Send(sendBytes);
            ///*接收返回值*/
            //string recStr = "";
            //byte[] recBytes = new byte[4096];
            //int bytes = clientSocket.Receive(recBytes, recBytes.Length, 0);
            //recStr += Encoding.GetEncoding("gb2312").GetString(recBytes, 0, bytes);
            //txt_Recevicecontext.Text += recStr + "/n/r";
            SignOutParameter p = new SignOutParameter();

            p.UserUrl = "34020000003000000001@" + txtIp.Text.Trim();
            p.UserId  = "34020000003000000001";
            p.hostIP  = txtIp.Text.Trim();
            p.port    = 5060;
            bllCameraControl.SignOut(p);
        }
Пример #2
0
        /// <summary>
        /// 退出
        /// </summary>
        /// <param name="p">相机退出参数</param>
        /// <returns></returns>
        public string SignOut(SignOutParameter p)
        {
            if (clientSocket == null)
            {
                ConnectSocket(p.hostIP, p.port);
            }
            /*协议体*/
            StringBuilder strBody = new StringBuilder();

            strBody.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
            // strBody.Append("<User>[email protected]</User>");
            strBody.Append("<Message>");
            strBody.Append("<User>" + p.UserUrl + "</User>");
            strBody.Append("</Message>");
            /*协议头*/
            int    len       = strBody.ToString().Length;
            string strheader = "";

            strheader = GetAgreementHeader(1008, len);
            string contentStr = strheader.ToString() + strBody.ToString();
            /*发送指令*/
            string sendStr = contentStr;

            byte[] sendBytes = Encoding.GetEncoding("gb2312").GetBytes(sendStr);
            int    num       = clientSocket.Send(sendBytes);
            /*接收返回值*/
            string recStr = "";

            byte[] recBytes = new byte[4096];
            int    bytes    = clientSocket.Receive(recBytes, recBytes.Length, 0);

            recStr += Encoding.GetEncoding("gb2312").GetString(recBytes, 0, bytes);
            return(recStr);
        }