Ejemplo n.º 1
0
        private void Combo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SIPTools  sip  = new SIPTools();
            SipSocket temp = new SipSocket(testsocket, sip);
            string    seleRequest;

            seleRequest = Combo.SelectedValue.ToString().Substring(38);
            switch (seleRequest)
            {
            case "StartMediaReq":
                temp.SendRequest(InterfaceC.StartMediaReq("6101010000000000", "6101010000000001", "63", "1", "0", "", "", "1"));
                break;

            case "StopMediaReq":
                temp.SendRequest(InterfaceC.StopMediaReq("0000000000000000", "6101010000000001", "0"));
                break;

            case "QueryHistoryFiles":
                temp.SendRequest(InterfaceC.QueryHistoryFiles("0000000000000000", "6101010000000001", "0", "1111", "2015-03-22 12:22:33", "2015-03-22 12:42:33"));
                break;

            case "StartPlayBack":
                temp.SendRequest(InterfaceC.StartPlayBack("0000000000000000", "6101010000000001", "0", "2015-03-22 12:22:33", "2015-03-22 12:42:33", 0, "192.168.1.1", "15000", 1, 1));
                break;

            case "ControlFileBack":
                temp.SendRequest(InterfaceC.ControlFileBack("00000000000", "00038478", "UP", 0));
                break;

            case "StartHisLoad":
                temp.SendRequest(InterfaceC.StartHisLoad("0000000000000000", "6101010000000001", "0", "2015-03-22 12:22:33", "2015-03-22 12:42:33", 0, "192.168.1.1", "15000", 1, 1));
                break;

            case "ReqCamResState":
                string[] str = { "000000", "1111111", "222222" };
                temp.SendRequest(InterfaceC.ReqCamResState("0000000000000000", str, 1));
                break;

            case "GetUserCurState":
                temp.SendRequest(InterfaceC.GetUserCurState("0000000000000000", "6101010000000001"));
                break;

            case "SetUserCamManage":
                string[] cameId = { "00000", "111111" }, id = { "222222", "333333" };
                temp.SendRequest(InterfaceC.SetUserCamManage("0000000000000000", "6101010000000001", 0, "2015-03-22 12:22:33", "2015-03-22 12:42:33", "2015-03-22 11:42:33", cameId, 2, id, 2));
                break;

            case "AlarmResSubscribe":
                string[] type = { "666666", "4444444" }, id_0 = { "00000", "11111" };
                temp.SendRequest(InterfaceC.AlarmResSubscribe("0000000000000000", "6101010000000001", 0, id_0, type, 2));
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        void recvProc(IAsyncResult ar)//异步Receive
        {
            stateobject state = (stateobject)ar.AsyncState;
            XmlDocument Doc   = new XmlDocument();
            SipSocket   temp;

            if (state.isClosed)
            {
                return;
            }
            try
            {
                state.socket.BeginReceive(state.recv, 0, state.BufferSize, 0, new AsyncCallback(recvProc), state);
                int i = state.socket.EndReceive(ar);
                this.Dispatcher.BeginInvoke(new Action(() => Result.AppendText(Encoding.GetEncoding("GB2312").GetString(state.recv, 0, i))));
                SipSocket.Add(state.socket, new SIPTools(state.recv, i));
                temp = SipSocket.FindSipSocket(state.socket);
                string[] result;
                Doc = SIPTools.XmlExtract(recv, i);
                if (Doc == null)
                {
                    return;
                }
                if (InterfaceC.IsRequest(Doc))
                {
                    temp.SendResponse(InterfaceC.Request(Doc));
                }
                else
                {
                    result = InterfaceC.Response(Doc);
                    if (result != null)
                    {
                        SipSocket.InsertResult(state.socket, result);
                        for (int k = 0; k < result.Length; k++)
                        {
                            Console.WriteLine(result[k]);
                        }
                    }
                }
            }
            catch (SocketException e)
            {
                state.isClosed = true;
                state.socket.Dispose();
                Console.WriteLine(e.Message);
                return;
            }
            catch (XmlException e)
            {
                Console.WriteLine(e.Message);
                return;
            }
        }
Ejemplo n.º 3
0
        //static

        public static void Add(Socket socket, SIPTools sip)
        {
            foreach (SipSocket ss in sipsocket)
            {
                if (ss.socket.Equals(socket))
                {
                    return;
                }
            }
            SipSocket temp = new SipSocket(socket, sip);

            sipsocket.Add(temp);
        }
Ejemplo n.º 4
0
 public void SipInit(byte[] buffer, int length)
 {
     sip    = new SIPTools(buffer, length);
     result = new string[10];
 }
Ejemplo n.º 5
0
 public SipSocket(Socket skt, SIPTools s)
 {
     socket = skt;
     sip    = s;
 }