protected override bool TryParse(IpPacket packet, out IEnvelope envelope) { envelope = null; if (!packet.PacketHeader.DestinationIpAddress.Equals(this.ListenEndPoint.Address)) { return(false); } var upacket = packet.ToUdpDatagram(); var isValid = upacket.UdpDatagramHeader.DestinationPort == this.ListenEndPoint.Port; if (isValid) { envelope = new UdpEnvelope { OccurrenceTime = packet.ReceivedTime, ReceivedTime = packet.ReceivedTime, Payload = packet.PacketData.Array, PayloadInstance = upacket, }; } return(isValid); }
protected override bool TryParse(IpPacket packet, out IUdpDatagram result) { result = null; if (!packet.PacketHeader.DestinationIpAddress.Equals(this.ListenEndPoint.Address)) { return(false); } var upacket = packet.ToUdpDatagram(); var isValid = upacket.UdpDatagramHeader.DestinationPort == this.ListenEndPoint.Port; if (isValid) { result = upacket; } return(isValid); }