namespace Renci.SshNet.Messages.Transport
{
///
/// Represents SSH_MSG_DEBUG message.
///
[Message("SSH_MSG_DEBUG", 4)]
public class DebugMessage : Message
{
private byte[] _message;
private byte[] _language;
///
/// Gets a value indicating whether the message to be always displayed.
///
///
/// true if the message always to be displayed; otherwise, false.
///
public bool IsAlwaysDisplay { get; private set; }
///
/// Gets debug message.
///
public string Message
{
get { return Utf8.GetString(_message, 0, _message.Length); }
}
///
/// Gets message language.
///
public string Language
{
get { return Utf8.GetString(_language, 0, _language.Length); }
}
///
/// Gets the size of the message in bytes.
///
///
/// The size of the messages in bytes.
///
protected override int BufferCapacity
{
get
{
var capacity = base.BufferCapacity;
capacity += 1; // IsAlwaysDisplay
capacity += 4; // Message length
capacity += _message.Length; // Message
capacity += 4; // Language length
capacity += _language.Length; // Language
return capacity;
}
}
///
/// Called when type specific data need to be loaded.
///
protected override void LoadData()
{
IsAlwaysDisplay = ReadBoolean();
_message = ReadBinary();
_language = ReadBinary();
}
///
/// Called when type specific data need to be saved.
///
protected override void SaveData()
{
Write(IsAlwaysDisplay);
WriteBinaryString(_message);
WriteBinaryString(_language);
}
internal override void Process(Session session)
{
session.OnDebugReceived(this);
}
}
}