using System;
using JD.Interfaces.Remoting;
using JD.Remoting.Details;
namespace JD.Remoting
{
///
/// The Message is the logical communication element, user can send a message by creating a new one or by simply using the "Send" method.
///
public class Message : IMessage
{
///
/// Gets the content of the message at the current read/write position.
///
public IBlob Content { get; private set; }
///
/// The command
///
public string CommandName
{
get { return Header.CommandName; }
}
///
/// The parsed header from the engine message
///
internal MessageHeader Header { get; set; }
///
/// Builds a message either to read from or to write into.
///
/// When the plugin name is not specified, it is automatically filled with the appropriate value.
public Message(string commandName, IBlob content = null)
{
if (string.IsNullOrEmpty(commandName))
throw new ArgumentException("CommandName cannot be left empty");
Content = content ?? new Blob(allowRead: true);
Header = new MessageHeader { CommandName = commandName };
}
}
}