示例#1
0
        /// <summary>
        /// Called when [data received].
        /// </summary>
        /// <param name="args">The args.</param>
        protected virtual void OnDataReceived(NetworkData args)
        {
            var handler = this.DataReceived;

            if (handler != null)
            {
                handler(this, new EventArgs <NetworkData>(args));
            }
        }
示例#2
0
        protected override void OnDataReceived(NetworkData args)
        {
            base.OnDataReceived(args);

            // Queue this response to be processed
            ThreadPool.QueueUserWorkItem(data =>
            {
                try
                {
                    // Parse our message and fire our event
                    using (var stream = new MemoryStream(args.Buffer, 0, args.Length))
                    {
                        this.OnSsdpMessageReceived(new SsdpMessage(HttpMessage.Parse(stream), args.RemoteIPEndpoint));
                    }
                }
                catch (ArgumentException ex)
                {
                    System.Diagnostics.Trace.TraceError("Failed to parse SSDP response: {0}", ex.ToString());
                }
            });
        }
示例#3
0
        protected override void OnDataReceived(NetworkData args)
        {
            base.OnDataReceived(args);

            // Queue this response to be processed
            ThreadPool.QueueUserWorkItem(data =>
            {
                try
                {
                    // Parse our message and fire our event
                    var msg = SsdpMessage.Parse(args.Buffer, args.Length, args.LocalEndpoint, args.RemoteEndpoint);
                    this.OnSsdpMessageReceived(msg);
                }
                catch (ArgumentException ex)
                {
                    Trace.TraceError("Failed to parse SSDP response: {0}", ex.ToString());
                }
                catch (Exception exception)
                {
                    Trace.TraceError("Failed to parse SSDP response: {0}", exception.ToString());
                }
            });
        }
示例#4
0
 /// <summary>
 /// Called when [data received].
 /// </summary>
 /// <param name="args">The args.</param>
 protected virtual void OnDataReceived(NetworkData args)
 {
     var handler = this.DataReceived;
     if (handler != null)
         handler(this, new EventArgs<NetworkData>(args));
 }