Ejemplo n.º 1
0
 public void SendCommand(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);
     }
 }
Ejemplo n.º 2
0
 public AGIReply SendCommand(AGICommand command)
 {
     agiWriter.SendCommand(command);
     agiReply = agiReader.ReadReply();
     int status = agiReply.GetStatus();
     if (status == (int) AGIReplyStatuses.SC_INVALID_OR_UNKNOWN_COMMAND)
         throw new InvalidOrUnknownCommandException(command.BuildCommand());
     if (status == (int) AGIReplyStatuses.SC_INVALID_COMMAND_SYNTAX)
         throw new InvalidCommandSyntaxException(agiReply.GetSynopsis(), agiReply.GetUsage());
     if (status == (int) AGIReplyStatuses.SC_DEAD_CHANNEL && _SC511_CAUSES_EXCEPTION)
         throw new AGIHangupException();
     if ((status == 0) && agiReply.FirstLine == "HANGUP" && _SCHANGUP_CAUSES_EXCEPTION)
         throw new AGIHangupException();
     return agiReply;
 }
 /// <summary>
 /// Sends the given command to the channel attached to the current thread.
 /// </summary>
 /// <param name="command">the command to send to Asterisk</param>
 /// <returns> the reply received from Asterisk</returns>
 /// <throws>  AGIException if the command could not be processed properly </throws>
 private AGIReply SendCommand(Command.AGICommand command)
 {
     return(this.Channel.SendCommand(command));
 }