Пример #1
0
        public void Start()
        {
            _log.SetSession();
            _log.WriteInfo("Starting");

            var config = (BotcoinConfigSection)ConfigurationManager.GetSection("botcoin");

            _tcp.StartServer("127.0.0.1", config.FindConnectionElement("DbGateway").Port);

            _tcp.StartListener(_log.Service,
                               bytes => _msgHandling.MessageHandler(bytes),
                               (ns, bytes) =>
            {
                if (bytes != null)
                {
                    ns.Write(bytes, 0, bytes.Length);
                }
            },
                               data =>
            {
                data.SessionId = _log.SessionId;
                _dbRepo.WriteServiceEvent(data);
            });

            _log.WriteInfo("Started");
        }
Пример #2
0
        private void CreateConnection(CurrencyName instrument)
        {
            var config     = (BotcoinConfigSection)ConfigurationManager.GetSection("botcoin");
            var connection = config.FindConnectionElement("RestScheduler");
            var strAddr    = String.Format(connection.DomainName, instrument.ToString().ToLower());
            var ipAddr     = Dns.GetHostEntry(strAddr).AddressList.Where(a => a.AddressFamily == AddressFamily.InterNetwork).First();

            _log.WriteInfo(String.Format("{0} subscribed", instrument.ToString()));
            _connections.Add(new Tuple <CurrencyName, IPEndPoint>(instrument, new IPEndPoint(ipAddr, connection.Port)));
        }