Typed Message Sample
Source code
using System;
using System.Text;
using OnixS.SimpleBinaryEncoding.Templates;
using OnixS.SimpleBinaryEncoding.Trading;
namespace OnixS.SimpleBinaryEncoding.TypedMessages
{
class Program
{
static void Main()
{
try
{
TemplateLibrary.LicenseStore = "../../../../../license";
var buffer = new MemoryPointer(new byte[65536]);
{
Negotiate500 negotiate = new(buffer, true)
{
HMACSignature = "HMAC",
AccessKeyID = "AccessKey",
UUID = 1,
RequestTimestamp = (ulong)(DateTime.UtcNow.Ticks - new DateTime(1970, 1, 1).Ticks) * 1000000 / TimeSpan.TicksPerMillisecond,
Session = "ABC",
Firm = "ABCDE"
};
WriteToConsole("Encoded message", negotiate);
}
{
Negotiate500 negotiate = new(buffer);
WriteToConsole("Decoded message", negotiate);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Console.WriteLine("Done.");
}
private static void WriteToConsole(string prefix, Negotiate500 negotiate)
{
Console.WriteLine(@$"
{prefix}:
{negotiate}
hmacSignature={negotiate.HMACSignature},
accessKeyID={negotiate.AccessKeyID},
UUID={negotiate.UUID},
requestTimestamp={negotiate.RequestTimestamp},
session={negotiate.Session},
firm={negotiate.Firm}
Memory region: {Encoding.Default.GetString(negotiate.Buffer[..negotiate.MessageLength])}
");
}
}
}