using System;
namespace Renci.SshNet.Messages.Transport
{
    /// 
    /// Represents SSH_MSG_SERVICE_REQUEST message.
    /// 
    [Message("SSH_MSG_SERVICE_REQUEST", 5)]
    public class ServiceRequestMessage : Message
    {
        /// 
        /// Gets the name of the service.
        /// 
        /// 
        /// The name of the service.
        /// 
        public ServiceName ServiceName { get; private set; }
        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// Name of the service.
        public ServiceRequestMessage(ServiceName serviceName)
        {
            this.ServiceName = serviceName;
        }
        /// 
        /// 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()
        {
            switch (this.ServiceName)
            {
                case ServiceName.UserAuthentication:
                    this.WriteAscii("ssh-userauth");
                    break;
                case ServiceName.Connection:
                    this.WriteAscii("ssh-connection");
                    break;
                default:
                    throw new NotSupportedException("Not supported service name");
            }
        }
    }
}