Esempio n. 1
0
 public ConnectedClient(ClientConfig cfg, IConnector connector)
 {
     _cfg            = cfg;
     _messageBuilder = new MessageBuilder(cfg);
     _connection     = new DurableConnection(new InitializingConnector(connector, (session, cancel) =>
     {
         session.Send(_messageBuilder.Logon());
         if (!(session.Receive(cancel).Result is Mantle.Fix44.Logon))
         {
             throw new UnexpectedMessageReceived("Expected Logon");
         }
         if (_cfg.MarketDataSymbols != null)
         {
             foreach (string symbol in _cfg.MarketDataSymbols)
             {
                 session.Send(_messageBuilder.MarketDataRequest(symbol, MessageBuilder.MarketDataType.Order));
                 session.Send(_messageBuilder.MarketDataRequest(symbol, MessageBuilder.MarketDataType.Trade));
             }
         }
     }));
     _messagePump = new MessagePump(
         _connection,
         (msg, sessionID) => _scheduler.Schedule(
             () => OnMessage(msg.Visit(new MessageDecoder(sessionID, _cfg.Extensions)))));
     _watchdog = new ConnectionWatchdog(_connection, _scheduler, _messageBuilder);
 }
Esempio n. 2
0
 public ConnectionWatchdog(DurableConnection connection, Scheduler scheduler, MessageBuilder messageBuilder)
 {
     _connection     = connection;
     _scheduler      = scheduler;
     _messageBuilder = messageBuilder;
     _hearBeatPeriod = TimeSpan.FromSeconds(messageBuilder.Config.HeartBtInt);
     Reschedule();
 }