本文整理匯總了C#中QuickFix.Message類的典型用法代碼示例。如果您正苦於以下問題:C# Message類的具體用法?C# Message怎麽用?C# Message使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Message類屬於QuickFix命名空間,在下文中一共展示了Message類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CheckSumTest
public void CheckSumTest()
{
string str1 = "8=FIX.4.2\x01" + "9=45\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01" +
"52=20000426-12:05:06\x01" + "56=ISLD\x01";
int chksum = 0;
foreach (char c in str1)
chksum += (int)c;
chksum %= 256;
str1 += "10=218\x01"; // checksum field
Message msg = new Message();
try
{
msg.FromString(str1, true, null, null, _defaultMsgFactory);
}
catch (InvalidMessage e)
{
Assert.Fail("Unexpected exception (InvalidMessage): " + e.Message);
}
Assert.That(msg.CheckSum(), Is.EqualTo(chksum));
}
示例2: MakeMessage
public void MakeMessage(Message m, string fix)
{
idx = 0; prevIdx = 0;
// Handle first field differently, no SOH at start.
StringField sf = new StringField(0);
idx = fix.IndexOf('\x01');
if (idx != -1)
{
field = fix.Substring(prevIdx, (idx - prevIdx));
tagIndex = field.IndexOf('=');
sf.Tag = IntParse(field.Substring(0, tagIndex));
sf.Obj = field.Substring(tagIndex + 1);
m.setField(sf);
}
else return;
while (idx != -1)
{
prevIdx = idx;
idx = fix.IndexOf('\x01', prevIdx + 1);
if (idx == -1) break;
StringField sf2 = new StringField(0);
field = fix.Substring(prevIdx + 1, (idx - prevIdx) - 1);
tagIndex = field.IndexOf('=');
sf2.Tag = IntParse(field.Substring(0, tagIndex));
sf2.Obj = field.Substring(tagIndex + 1);
m.setField(sf2);
}
}
示例3: Create
public Message Create(string beginString, string msgType)
{
IMessageFactory f = null;
// FIXME: This is a hack. FIXT11 could mean 50 or 50sp1 or 50sp2.
// We need some way to choose which 50 version it is.
// Choosing 50 here is not adequate.
if (beginString.Equals(FixValues.BeginString.FIXT11))
{
if (!Message.IsAdminMsgType(msgType))
f = _factories[FixValues.BeginString.FIX50];
}
if(f != null)
return f.Create(beginString, msgType);
if (_factories.ContainsKey(beginString) == false)
{
Message m = new Message();
m.Header.SetField(new StringField(QuickFix.Fields.Tags.MsgType, msgType));
return m;
}
f = _factories[beginString];
return f.Create(beginString, msgType);
}
示例4: TestParsePerformance
public void TestParsePerformance()
{
string fix = GenRandomFIXString();
HiPerfTimer timer = new HiPerfTimer();
timer.Start();
const int numMsgs = 50000;
for (int i = 0; i < numMsgs; i++)
{
Message m = new Message();
MakeMessage(m, fix);
}
timer.Stop();
Console.WriteLine("Total per second: " + ((1 / timer.Duration) * numMsgs).ToString());
// Test message creation latency.
timer.Start();
Message newMsg = new Message();
MakeMessage(newMsg, fix);
timer.Stop();
Console.WriteLine(
String.Format("Latency for parsing one FIX message in microseconds: {0}", (timer.Duration * 1000000).ToString()));
}
示例5: ToAdmin
public void ToAdmin(Message message, SessionID sessionID)
{
if (message.Header.GetField(Tags.MsgType) == MsgType.LOGON)
{
message.SetField(new QuickFix.Fields.Username("batman"));
message.SetField(new QuickFix.Fields.Password("gotham123"));
}
}
示例6: Crack
public void Crack(Message message, SessionID sessionID)
{
Type messageType = message.GetType();
MethodInfo handler = null;
if (_handlerMethods.TryGetValue(messageType, out handler))
handler.Invoke(this, new object[] { message, sessionID });
else
throw new UnsupportedMessageType();
}
示例7: FromApp
public void FromApp(Message message, SessionID sessionID)
{
OnMessage(message, sessionID);
string msgType = message.Header.GetString(Tags.MsgType);
switch (msgType) {
case "8":
OnExecutionReport((QuickFix.FIX42.ExecutionReport)message);
break;
}
}
示例8: fromAdmin
public void fromAdmin(Message message, SessionID sessionID)
{
if (!isTimerAdjusted)
{
SendingTime sendingTime = new SendingTime();
message.getHeader().getField(sendingTime);
Utils.AdjustTime(sendingTime.getValue());
isTimerAdjusted = true;
}
}
示例9: fromApp
public void fromApp(Message message, SessionID sessionID)
{
try
{
crack(message, sessionID);
}
catch (UnsupportedMessageType exception)
{
Console.WriteLine("fromApp " + exception);
Console.WriteLine("fromApp " + message);
}
}
示例10: FromApp
public void FromApp(Message message, SessionID sessionID)
{
string msgType = message.Header.GetString(Tags.MsgType);
switch (msgType) {
case "V":
OnMessage(((QuickFix.FIX42.MarketDataRequest)message), sessionID);
break;
case "D":
OnMessage(((QuickFix.FIX42.NewOrderSingle)message), sessionID);
break;
}
}
示例11: Build
internal Message Build()
{
Message message = _msgFactory.Create(_beginString, _msgType.Obj);
message.FromString(
_msgStr,
_validateLengthAndChecksum,
_sessionDD,
_appDD,
_msgFactory);
_message = message;
return _message;
}
示例12: FromApp
public void FromApp(Message message, SessionID sessionID)
{
try
{
Crack(message, sessionID);
}
catch (Exception ex)
{
string s = "==Cracker exception==\n";
s += ex.ToString() + "\n";
s += ex.StackTrace;
Puts(s);
}
}
示例13: FromApp
public void FromApp(Message message, SessionID sessionID)
{
Console.WriteLine("IN: " + message.ToString());
try
{
Crack(message, sessionID);
}
catch (Exception ex)
{
Console.WriteLine("==Cracker exception==");
Console.WriteLine(ex.ToString());
Console.WriteLine(ex.StackTrace);
}
}
示例14: Create
public Message Create(string beginString, string msgType)
{
// TODO: if FIXT11 and non-admin message, use FIX50
if (_factories.ContainsKey(beginString) == false)
{
Message m = new Message();
m.Header.SetField(new StringField(QuickFix.Fields.Tags.MsgType, msgType));
return m;
}
IMessageFactory f = _factories[beginString];
return f.Create(beginString, msgType);
}
示例15: fromAdmin
public override void fromAdmin(Message message, SessionID sessionID)
{
base.fromAdmin(message, sessionID);
if ((message is QuickFix42.Logout || message is QuickFix42.Reject) && message.isSetField(QuickFix.Text.FIELD))
{
Console.WriteLine(message.getString(QuickFix.Text.FIELD));
}
if (message is QuickFix42.Logout)
{
Disconnect();
}
}