예제 #1
0
        /// <summary>
        /// Creates a new session.
        /// </summary>
        /// <param name="configuration">The session configuration</param>
        /// <param name="clock">The session clock</param>
        /// <param name="transport">The session transport</param>
        /// <param name="logger">The session logger</param>
        /// <param name="bufferSize">The buffersize to use for buffering</param>
        /// <param name="maxMessageLength">The maximum supported length of a fix message</param>
        /// <param name="maxMessageFields">The maximum supported number of fields in a fix message</param>
        public Session(Configuration configuration, IClock clock, ITransport transport, ILogger logger, int bufferSize, int maxMessageLength, int maxMessageFields)
        {
            Clock         = clock;
            Logger        = logger;
            Configuration = configuration;

            Channel = new Channel(transport, bufferSize);

            State = new State
            {
                InboundSeqNum       = configuration.InboundSeqNum,
                OutboundSeqNum      = configuration.OutboundSeqNum,
                InboundTimestamp    = clock.Time,
                OutboundTimestamp   = clock.Time,
                HeartbeatInterval   = TimeSpan.FromSeconds(configuration.HeartbeatInterval * 1.0),
                HeartbeatTimeoutMin = TimeSpan.FromSeconds(configuration.HeartbeatInterval * 1.2),
                HeartbeatTimeoutMax = TimeSpan.FromSeconds(configuration.HeartbeatInterval * 2.0)
            };

            if (Logger != null)
            {
                Channel.Inbound  = Logger.Inbound;
                Channel.Outbound = Logger.Outbound;
            }

            Inbound = new FIXMessage(maxMessageLength, maxMessageFields)
            {
                Clock = Clock
            };
            Outbound = new FIXMessageWriter(maxMessageLength)
            {
                Clock = Clock
            };
        }
예제 #2
0
        private void Send(string messageType, FIXMessageWriter message, long seqNum)
        {
            message.Prepare(Configuration.Version, messageType, seqNum, Clock.Time, Configuration.Sender, Configuration.Target);

            Channel.Write(message);

            State.OutboundTimestamp = Clock.Time;

            Sent?.Invoke(this, message);
        }
예제 #3
0
        public void Send(string messageType, FIXMessageWriter message)
        {
            var state = State;

            message.Prepare(Configuration.Version, messageType, state.OutboundSeqNum, Clock.Time, Configuration.Sender, Configuration.Target);

            Channel.Write(message);

            state.OutboundSeqNum++;
            state.OutboundTimestamp = Clock.Time;

            Sent?.Invoke(this, message);
        }
예제 #4
0
 /// <summary>
 /// Writes a message to the transport.
 /// </summary>
 /// <param name="message">The message to write.</param>
 public void Write(FIXMessageWriter message)
 {
     Transport.Write(message.Buffer, 0, message.Length);
     Outbound?.Invoke(message.Buffer, 0, message.Length);
 }