手动断开星号调用

时间:2014-03-26 11:26:36

标签: c# c#-4.0 asterisk

我使用以下代码使用c#挂断星号调用。但它不工作的电话没有断开。请帮我这样做。我使用相同的方法登录星号。但它的工作。

if (this.parser == null)
{
    this.parser = new ProtocolParser();
    this.parser.Parsed += new ProtocolParser.OnParsed(ParserParsed);
}

if (this.socketmanager == null)
{
    this.socketmanager = new SocketManager(ConfigurationManager.AppSettings["SERVER_LISTEN_IP"], 8999); 

    this.socketmanager.Connected += new SocketManager.OnConnected(SocketManagerConnected);
    this.socketmanager.Disconnected += new SocketManager.OnDisconnected(SocketManagerDisconnected);
    this.socketmanager.DataArrival += new SocketManager.OnDataArrival(SocketManagerDataArrival);
    this.socketmanager.SocketError += new SocketManager.OnSocketError(SocketManagerSocketError);
    socketmanager.Connect();
}

if (this.parser != null & this.socketmanager != null)
{
    //Extnston = txt_agentex.Text;
    string application = string.Empty;
    application = "Hangup";
    string cmd = "Hangup/SIP/10.xxx.xx.xx-0000003d|1395833122.145|21";
    ExtnStrg = "IAX2/" + Extnston;

    if (this.socketmanager.SendData(cmd))
    {
        ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>show('success','" + ConfigurationManager.AppSettings["SUCS-WLK"].ToString() + "');</script>", false);
    }
    else
    {
         this.socketmanager.Disconnect();
         ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "tmp", "<script type='text/javascript'>show('error','" + ConfigurationManager.AppSettings["ERROR-AUT"].ToString() + "');</script>", false);
         return;
    }
    //this.socketmanager.Disconnect();               
}

1 个答案:

答案 0 :(得分:0)

适用于1.6+版本:

pro-sip*CLI> channel request hangup 
Usage: channel request hangup <channel>|<all>
       Request that a channel be hung up. The hangup takes effect
       the next time the driver reads or writes from the channel.
       If 'all' is specified instead of a channel name, all channels
       will see the hangup request.