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); } }
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; }