コード例 #1
0
 private void OnDataReceived(byte[] data, IPEndPoint sender)
 {
     try
     {
         SoapMessage <WSD.ProbeType> probe = SoapBuilder.ParseMessage <WSD.ProbeType>(data, null);
         if (OnProbeReceived != null)
         {
             DiscoverProbeEventArgs args = new DiscoverProbeEventArgs();
             args.Sender = sender;
             args.Probe  = probe.Object;
             OnProbeReceived(this, args);
             if (args.Response != null)
             {
                 XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces();
                 namespaces.Add("dn", DiscoveryUtils.ONVIF_NETWORK_WSDL_URL);
                 DiscoveryHeaderBuilder header = new DiscoveryHeaderBuilder();
                 header.OrigingMessageId = GetMessageId(probe.Header);
                 byte[] response = SoapBuilder.BuildMessage(args.Response, Encoding.UTF8, header, namespaces);
                 Send(response);
             }
         }
     }
     catch
     {
     }
 }
コード例 #2
0
        protected static void OnProbeReceive(object sender, DiscoverProbeEventArgs e)
        {
            Console.WriteLine(string.Format("Probe received from {0}", e.Sender.ToString()));
            DiscoveryServer  server  = sender as DiscoveryServer;
            ProbeMatchesType matches = server.BuildProbeMatches(e.Probe);

            e.Response = matches;
        }