im working on Fast Protocol, so im reseving UDP package and i need to resolve.
here is some example
<template id="65" name="Sample">
<uInt32 name="SenderCompID" id="49"/>
<byteVector name="PacketSeqNum"/>
<byteVector name="SendingTime"/>
</template>
this is the sample file.
using OpenFAST.Template;
using OpenFAST.Template.Types;
using OpenFAST.Template.Operators;
using OpenFAST;
using OpenFAST.Codec;
OpenFAST.Context _context = new OpenFAST.Context();
public void OpenFastX(byte[] bMCXPckt)
{
try
{
MemoryStream ms = new MemoryStream(bMCXPckt);
BinaryReader br = new BinaryReader(ms, Encoding.ASCII);
MessageTemplate message = new MessageTemplate("Sample", new Field[]
{
new Scalar("SenderCompID",FastType.U32,Operator.Copy,ScalarValue.Undefined,false),
new Scalar("PacketSeqNum",FastType.ByteVector,Operator.Copy,ScalarValue.Undefined,false),
new Scalar("SendingTime",FastType.ByteVector,Operator.Copy,ScalarValue.Undefined,false),
});
_context.RegisterTemplate(65, message);
Log.Process("Template Registered");
var decoder = new FastDecoder(_context, new BufferedStream(ms, 65535));
Log.Process("Decoder -: " + decoder.ReadMessage().GetInt(49).ToString());
}
catch (Exception ex)
{
Log.Error(ex.Message + Environment.NewLine + ex.StackTrace.ToString());
}
}
getting exception -> "An error while decoding Sample"