/// <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)); } }
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()); } }); }
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()); } }); }
/// <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)); }