コード例 #1
0
        /// <summary>
        /// Disconnects from IQFeed.
        /// </summary>
        public override async Task Disconnect()
        {
            client.Error          -= OnError;
            client.IntervalBar    -= OnIntervalBar;
            client.SymbolNotFound -= OnSymbolNotFound;
            client.System         -= OnSystemMessage;

            await client.UnwatchAllAsync();

            await client.DisconnectAsync();

            client = null;
        }
コード例 #2
0
        /// <summary>
        /// Connects to IQFeed.
        /// </summary>
        /// <param name="host">The IQFeed host to connect to.</param>
        /// <param name="port">The IQFeed port to connect to.</param>
        public override async Task Connect(
            string host, int port, CancellationToken token = default)
        {
            IPEndPoint ipEndPoint;

            try
            {
                ipEndPoint = new IPEndPoint(IPAddress.Parse(host), port);
            }

            // If we are given a domain, perform a DNS lookup to find the host
            catch (FormatException)
            {
                var ip = await GetIpAddress(host, token);

                ipEndPoint = new IPEndPoint(ip, port);
            }

            client = DerivativeClientFactory.CreateNew(ipEndPoint.Address.ToString(), port);

            await client.ConnectAsync();
        }