예제 #1
0
        internal override void OnConnected()
        {
            Console.WriteLine("connected");
            base.OnConnected();

            var msg = new FixMessage(ID, 'A');

            msg.Header.Add(52, DateTime.UtcNow.ToString(FixSettings.DateTimeFormat));
            msg.Add(98, "0");
            msg.Add(108, "30");

            SendAsync(msg);
        }
예제 #2
0
        private void OnMessageInternal(FixMessage msg)
        {
            var field = msg.Header[Tags.MsgType] as FixField <char>;

            switch (field.Value)
            {
            case '0':
                var hb = new FixMessage(ID, '0');
                hb.Header.Add(52, DateTime.UtcNow.ToString(FixSettings.DateTimeFormat));
                SendAsync(hb);
                break;

            case '1':
                var testAck = new FixMessage(ID, '0');
                testAck.Header.Add(52, DateTime.UtcNow.ToString(FixSettings.DateTimeFormat));
                testAck.Add(msg[Tags.TestReqID]);
                SendAsync(testAck);
                break;

            case '2':
                throw new NotImplementedException();

            case '3':
                break;

            case '4':
                throw new NotImplementedException();

            case '5':
                _transport.DisconnectAsync();
                break;

            case 'A':
                ID       = new SessionIdentity(msg.Header[Tags.BeginString].AsString(), msg.Header[Tags.SenderCompID].AsString(), msg.Header[Tags.TargetCompID].AsString());
                RevertID = new SessionIdentity(msg.Header[Tags.BeginString].AsString(), msg.Header[Tags.TargetCompID].AsString(), msg.Header[Tags.SenderCompID].AsString());
                //HeartbeatInterval = msg[Tag]

                var logon = new FixMessage(RevertID, 'A');
                logon.Header.Add(52, DateTime.UtcNow.ToString(FixSettings.DateTimeFormat));
                logon.Add(98, "0");
                logon.Add(108, "30");
                SendAsync(logon);
                break;

            default:
                // non session level message
                _application.OnMessage(msg);
                break;
            }
        }