2013-01-18 15:55:50 +00:00
|
|
|
using System;
|
|
|
|
using System.IO;
|
2014-01-08 14:16:39 +00:00
|
|
|
namespace AsterNET.FastAGI
|
2013-01-18 15:55:50 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Default implementation of the AGIWriter interface.
|
|
|
|
/// </summary>
|
|
|
|
public class AGIWriter
|
|
|
|
{
|
|
|
|
private IO.SocketConnection socket;
|
|
|
|
|
|
|
|
public AGIWriter(IO.SocketConnection socket)
|
|
|
|
{
|
|
|
|
lock (this)
|
|
|
|
this.socket = socket;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void SendCommand(Command.AGICommand command)
|
|
|
|
{
|
|
|
|
string buffer = command.BuildCommand() + "\n";
|
|
|
|
try
|
|
|
|
{
|
|
|
|
socket.Write(buffer);
|
|
|
|
}
|
|
|
|
catch (IOException e)
|
|
|
|
{
|
|
|
|
throw new AGINetworkException("Unable to send command to Asterisk: " + e.Message, e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|