private void OnProcessData(byte[] buffer, int offset, int count) { this.Reader.WriteData(buffer, offset, count); var lineData = new LineData(null, string.Empty, null); while (lineData != null) // ignoring empty lines { lineData = this.Reader.ReadLine(); if (lineData != null) { if (lineData.Line.Length > 0) { var lineEvent = new RawLineReceivedEventArgs(lineData); var handleRawLine = ((Action <RawLineReceivedEventArgs>) this.HandleRawLine); handleRawLine.BeginInvoke(lineEvent, handleRawLine.EndInvoke, null); } if (lineData.Line.Length == 0) { Debug.Assert(false); // Temp breakpoint } } } }
private LineData FinishLineData() { var id = new RawLineId(this.idByteList.ToArray()); this.idByteList.Clear(); this.readId = true; if (this.lineBuilder == null) { return(new LineData(null, "", null)); } this.lineBuilder.Position = 0; using (var reader = new StreamReader(this.lineBuilder, this.encoding)) { string line = reader.ReadToEnd(); string[] splits = line.Split(' '); if (splits.Length > 3 && splits[splits.Length - 2] == "RAWDATA") { if (!long.TryParse(splits[splits.Length - 1], out this.readBytes)) { this.readBytes = 0; throw new FormatException(string.Format("Invalid bytecount {0}", splits[splits.Length - 1])); } Logger.WriteLine("Received Message with {0} bytes", TraceEventType.Information, this.readBytes); this.tempLine = new LineData( id, string.Join(" ", splits.Take(splits.Length - 2) #if NET2 .ToArray() #endif ), new RawDataStream(1024 * 4, this.readBytes)); this.lineBuilder.Dispose(); this.lineBuilder = null; if (this.readBytes < 0) { throw new FormatException("Invalid byte layout format (invalid readbytes value)"); } return(this.tempLine); } this.lineBuilder = null; return(new LineData(id, line, null)); } }
private void OnProcessData(byte[] buffer, int offset, int count) { this.Reader.WriteData(buffer, offset, count); var lineData = new LineData(null, string.Empty, null); while (lineData != null) // ignoring empty lines { lineData = this.Reader.ReadLine(); if (lineData != null) { if (lineData.Line.Length > 0) { var lineEvent = new RawLineReceivedEventArgs(lineData); var handleRawLine = ((Action<RawLineReceivedEventArgs>)this.HandleRawLine); handleRawLine.BeginInvoke(lineEvent, handleRawLine.EndInvoke, null); } if (lineData.Line.Length == 0) { Debug.Assert(false); // Temp breakpoint } } } }
private LineData FinishLineData() { var id = new RawLineId(this.idByteList.ToArray()); this.idByteList.Clear(); this.readId = true; if (this.lineBuilder == null) { return new LineData(null, "", null); } this.lineBuilder.Position = 0; using (var reader = new StreamReader(this.lineBuilder, this.encoding)) { string line = reader.ReadToEnd(); string[] splits = line.Split(' '); if (splits.Length > 3 && splits[splits.Length - 2] == "RAWDATA") { if (!long.TryParse(splits[splits.Length - 1], out this.readBytes)) { this.readBytes = 0; throw new FormatException(string.Format("Invalid bytecount {0}", splits[splits.Length - 1])); } Logger.WriteLine("Received Message with {0} bytes", TraceEventType.Information, this.readBytes); this.tempLine = new LineData( id, string.Join(" ", splits.Take(splits.Length - 2) #if NET2 .ToArray() #endif ), new RawDataStream(1024 * 4, this.readBytes)); this.lineBuilder.Dispose(); this.lineBuilder = null; if (this.readBytes < 0) { throw new FormatException("Invalid byte layout format (invalid readbytes value)"); } return this.tempLine; } this.lineBuilder = null; return new LineData(id, line, null); } }