Granados.Poderosa.SCP.SCPClient.CheckResponse C# (CSharp) Method

CheckResponse() private method

Read a byte and check the status code.
Response was a warning or an error.
private CheckResponse ( SCPChannelStream stream ) : void
stream SCPChannelStream Channel stream
return void
        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");
        }