public void writes_the_whole_message_to_the_given_buffer_starting_at_the_correct_offset() { var message = new FIXMessage(); var logon = "8=FIX.4.2|9=70|35=A|34=1|52=20170607-12:17:52.355|49=DAEV|56=TARGET|98=0|108=5|141=Y|10=231|".Replace("|", "\u0001"); var bytes = logon.AsBytes(); var target = new byte[100]; message .Parse(bytes, 0, bytes.Length) .WriteTo(target, 3); var result = System.Text.Encoding.ASCII.GetString(target); result.Should().Be("\0\0\0" + logon + "\0\0\0\0\0"); }
public FIXMessage small() => Message.Parse(Heartbeat, 0, Heartbeat.Length);
/// <summary> /// Function to process data off the tcp stream - called from the worker thread /// </summary> public void ReadStream() { try { MESSAGEFIX3Lib.FIXMessage msg = new FIXMessage(); char[] message = new char[1024]; while (m_bContinue) { int nSize = m_StreamIn.ReadBlock(message, 0, 1024); if (nSize <= 0) continue; #if DEBUG System.Diagnostics.Trace.WriteLine("In Buffer" + nSize); #endif m_sTCPBuffer.Append(message, 0, nSize); #if DEBUG System.Diagnostics.Trace.WriteLine(m_sTCPBuffer.ToString()); #endif bool bContinue = true; while(bContinue) { string sData = m_sTCPBuffer.ToString(); int nheader = sData.IndexOf("8="); int nTail = sData.IndexOf("10="); if (nTail <= 0) { bContinue = false; continue; } int nEnd = sData.IndexOf("!", nTail); int nEnd1 = sData.IndexOf("8=", nTail); if (nEnd1 == -1) { bContinue = false; } else { sData = sData.Substring(nheader, nEnd1 - nheader); #if DEBUG System.Diagnostics.Trace.WriteLine("Buffer Current" + m_sTCPBuffer.Length); #endif m_sTCPBuffer.Remove(0, nEnd1); #if DEBUG System.Diagnostics.Trace.WriteLine("Buffer Data Remainder" + m_sTCPBuffer.Length); #endif //find the specific string string sTemp = string.Empty; //parse fix messagge bool bSuccess = msg.Parse(sData, m_sDelimiter, false); if (bSuccess) { if (DataEvent != null) { DataEvent(this, new FIXMessageEventArgs(msg)); } } else { //Failed to parse data #if DEBUG System.Diagnostics.Trace.WriteLine("Parse Error = " + sTemp); #endif } //clear the object msg.Clear(); } } } } catch (Exception e) { //Log - raise an event if (DisconnectEvent != null) DisconnectEvent(new ErrorEventArgs(e)); } }