ReadByte() public method

Read one byte
Timeout has occurred
public ReadByte ( int millisecondsTimeout ) : byte
millisecondsTimeout int Timeout in milliseconds
return byte
示例#1
0
 public void ReadByte_NotOpened()
 {
     _stream = new SCPChannelStream();
     Assert.AreEqual("NotOpened", _stream.Status);
     Assert.Catch <SCPClientInvalidStatusException>(
         () => _stream.ReadByte(1000)
         );
 }
示例#2
0
        /// <summary>
        /// Read a byte and check the status code.
        /// </summary>
        /// <param name="stream">Channel stream</param>
        /// <exception cref="SCPClientException">Response was a warning or an error.</exception>
        private void CheckResponse(SCPChannelStream stream)
        {
            byte response = stream.ReadByte(_protocolTimeout);

            if (response == 0)
            {
                // OK
                return;
            }

            if (response == 1 || response == 2)
            {
                // Warning or Error
                // followed by a message which is terminated by LF
                byte[] messageData = stream.ReadUntil(LF, _protocolTimeout);
                string message     = _encoding.GetString(messageData, 0, messageData.Length - 1);
                throw new SCPClientException(message);
            }

            throw new SCPClientException("Invalid response");
        }
示例#3
0
        /// <summary>
        /// Read a byte and check the status code.
        /// </summary>
        /// <param name="stream">Channel stream</param>
        /// <exception cref="SCPClientException">Response was a warning or an error.</exception>
        private void CheckResponse(SCPChannelStream stream)
        {
            byte response = stream.ReadByte(_protocolTimeout);
            if (response == 0) {
                // OK
                return;
            }

            if (response == 1 || response == 2) {
                // Warning or Error
                // followed by a message which is terminated by LF
                byte[] messageData = stream.ReadUntil(LF, _protocolTimeout);
                string message = _encoding.GetString(messageData, 0, messageData.Length - 1);
                throw new SCPClientException(message);
            }

            throw new SCPClientException("Invalid response");
        }
示例#4
0
 public void ReadByte_Timeout()
 {
     Assert.Catch <SCPClientTimeoutException>(
         () => _stream.ReadByte(1000)
         );
 }
示例#5
0
 public void ReadByte_NotOpened()
 {
     _stream = new SCPChannelStream();
     Assert.AreEqual("NotOpened", _stream.Status);
     _stream.ReadByte(1000);
 }
示例#6
0
 public void ReadByte_NotOpened()
 {
     _stream = new SCPChannelStream();
     Assert.AreEqual("NotOpened", _stream.Status);
     _stream.ReadByte(1000);
 }
示例#7
0
 public void ReadByte_Timeout()
 {
     _stream.ReadByte(1000);
 }