using System;
using JD.Interfaces.Remoting;
namespace JD.Remoting
{
///
/// Adds behavior to the basic connection interface.
///
public static class MessageSenderExtensions
{
///
/// Sends a message to the host connected.
///
///
/// Name of the message to send.
/// When provided, will be used to fill the content of the command.
/// 0 if operation succeeded, a non-zero value otherwise.
/// See Windows Sockets Error Codes page for more information on error codes.
/// The System.Net.Socket has been closed.
public static int Send(this IMessageSender messageSender, string messageName, Action writeBlobAction = null)
{
var message = new Message(messageName);
writeBlobAction?.Invoke(message.Content);
return messageSender.Send(message);
}
}
}