using System;
namespace Renci.SshNet.Messages.Transport
{
///
/// Represents SSH_MSG_SERVICE_REQUEST message.
///
[Message("SSH_MSG_SERVICE_REQUEST", 5)]
public class ServiceRequestMessage : Message
{
private readonly byte[] _serviceName;
///
/// Gets the name of the service.
///
///
/// The name of the service.
///
public ServiceName ServiceName
{
get { return _serviceName.ToServiceName(); }
}
///
/// 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 += 4; // ServiceName length
capacity += _serviceName.Length; // ServiceName
return capacity;
}
}
///
/// Initializes a new instance of the class.
///
/// Name of the service.
public ServiceRequestMessage(ServiceName serviceName)
{
_serviceName = serviceName.ToArray();
}
///
/// Called when type specific data need to be loaded.
///
protected override void LoadData()
{
throw new InvalidOperationException("Load data is not supported.");
}
///
/// Called when type specific data need to be saved.
///
protected override void SaveData()
{
WriteBinaryString(_serviceName);
}
internal override void Process(Session session)
{
session.OnServiceRequestReceived(this);
}
}
}