using System;
using System.Text;
namespace Sodao.FastSocket.Server.Messaging
{
///
/// command line message.
///
public class CommandLineMessage : Messaging.IMessage
{
#region Public Members
///
/// get the current command name.
///
public readonly string CmdName;
///
/// 参数
///
public readonly string[] Parameters;
#endregion
#region Constructors
///
/// new
///
///
///
/// cmdName is null
public CommandLineMessage(string cmdName, params string[] parameters)
{
if (cmdName == null) throw new ArgumentNullException("cmdName");
this.CmdName = cmdName;
this.Parameters = parameters;
}
#endregion
#region Public Methods
///
/// reply
///
///
///
/// connection is null
public void Reply(SocketBase.IConnection connection, string value)
{
if (connection == null) throw new ArgumentNullException("connection");
connection.BeginSend(ToPacket(value));
}
///
/// to
///
///
///
/// value is null
static public SocketBase.Packet ToPacket(string value)
{
if (value == null) throw new ArgumentNullException("value");
return new SocketBase.Packet(Encoding.UTF8.GetBytes(string.Concat(value, Environment.NewLine)));
}
#endregion
}
}