Esempio n. 1
0
        /// <summary>
        /// Enqueues the <paramref name="command"/> to be sent over Telnet to the IGS SERVER,
        /// then asynchronously receives the entirety of the server's response to this command.
        /// </summary>
        /// <param name="command">The command to send over Telnet.</param>
        /// <returns></returns>
        internal async Task <IgsResponse> MakeRequestAsync(string command)
        {
            IgsRequest request = new IgsRequest(command);

            _outgoingRequests.Enqueue(request);
            ExecuteRequestFromQueue();
            IgsResponse lines = await request.GetAllLines();

            lock (_mutex)
            {
                _requestInProgress = null;
            }
            ExecuteRequestFromQueue();
            return(lines);
        }
Esempio n. 2
0
        /// <summary>
        /// The returned task waits until the IGS SERVER sends all the response data to our command, terminated by a prompt line, and then
        /// it returns this data as a <see cref="List{T}"/>.
        /// </summary>
        public async Task <IgsResponse> GetAllLines()
        {
            IgsResponse lines = new IgsResponse();

            while (true)
            {
                IgsLine line = await IncomingLines.ReceiveAsync();

                if (ForgottenForever)
                {
                    throw new System.Exception("If this happens, we should examine this in detail.");
                }
                if (line.Code == IgsCode.Prompt)
                {
                    break;
                }
                lines.Add(line);
            }
            return(lines);
        }