从PC ASP.NET c#拨打电话 [英] Call a phone from PC ASP.NET c#

查看:117
本文介绍了从PC ASP.NET c#拨打电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ASP.NET c#

我是.net基于Windows的应用程序的新手。任何人都可以帮我做以下事情。



我有一个文本框输入电话号码和一个拨号按钮拨号,当我拨号时,它应该响铃在文本框中输入相应的数字。



我需要知道如何从我的IP连接到SIP服务器以及如何回复到我的IP。

我们是否需要在服务器中设置任何内容以获得响应?



紧急...

解决方案

查看 SIP for Java,C#和VB开发人员 [ ^ ] SIP部分。



您正在撰写关于ASP.NET的文章,但您也写过基于Windows的应用程序。你的意思是Winform,WPF还是Silverlight?


假设它在你的本地网络上,你需要IP地址(如果是静态的)或SIP服务器的域名。 />
然后你应该可以在你和它之间设置一个Socket。

真的,你应该和制造商谈谈 - SIP服务器想要的通信可能会有所不同。

使用此代码段:

(虽然它是用C#编写的,但是使用.Net库。)



 命名空间 SIP_Register 
{
class 计划
{
私人 静态 ISoftPhone softphone; // softphone object
private 静态 IPhoneLine phoneLine; // phoneline对象

private static void Main( string [] args)
{
// 创建一个RTP端口范围为5000的软电话对象-10000
softphone = SoftPhoneFactory.CreateSoftPhone( 5000 10000 );

// SIP帐户注册数据,(由您的VoIP服务提供商提供)
var registrationRequired = true ;
var userName = sipusername;
var displayName = sipdisplayname;
var authenticationId = authenticationid;
var registerPassword = 密码;
var domainHost = pbxip.voipprovider。 COM;
var domainPort = 5060 ;

var account = new SIPAccount(registrationRequired,displayName,userName,authenticationId, registerPassword,domainHost,domainPort);

// 发送SIP注册请求
RegisterAccount(account) ;

// 阻止终止应用程序
控制台。的ReadLine();
}

静态 void RegisterAccount(SIPAccount帐户)
{
尝试
{
phoneLine = softphone.CreatePhoneLine(account);
phoneLine.RegistrationStateChanged + = sipAccount_RegStateChanged;
softphone.RegisterPhoneLine(phoneLine);
}
catch (例外情况)
{
Console.WriteLine( SIP注册期间出错: + ex);
}
}

静态 void sipAccount_RegStateChanged( object sender,RegistrationStateChangedArgs e)
{
if (e.State == RegState.Error || e.State == RegState.NotRegistered)
Console.WriteLine( 注册失败! );

if (e.State == RegState.RegistrationSucceeded)
Console.WriteLine( 注册成功 - 在线!);
}
}
}



(来源: C#中的SIP寄存器示例 [ ^ ])


ASP.NET c#
I am new with the .net Windows based application. Can anyone help me to do the following.

I have a textbox to enter phone number and a Dial button to dial, When I dial the number, it should ring to the corresponding number entered in the textbox.

I need to know how we can get connection to the SIP server from my Ip and the response back to my Ip.
Do we need to setup anything in the server for getting a response?

Its urgent...

解决方案

Check out Introduction to SIP for Java, C#, and VB Developers[^] for the SIP part.

You are writing about ASP.NET but you also write about "Windows based application". Do you mean Winform, WPF or Silverlight ?


Assuming it is on your local network, you would need either the IP address (if static) or the domain name of the SIP server.
You should then be able to set up a Socket between you and it.
Really, you should talk to the manufacturers - the communications the SIP server wants may vary.


Use this code snippet:
(Although it has been written in C#, but by using a .Net library.)

namespace SIP_Register
{
    class Program
    {
        private static ISoftPhone softphone;   // softphone object
        private static IPhoneLine phoneLine;   // phoneline object

        private static void Main(string[] args)
        {
            // Create a softphone object with RTP port range 5000-10000
            softphone = SoftPhoneFactory.CreateSoftPhone(5000, 10000);

            // SIP account registration data, (supplied by your VoIP service provider)
            var registrationRequired = true;
            var userName = "sipusername";
            var displayName = "sipdisplayname";
            var authenticationId = "authenticationid";
            var registerPassword = "Password";
            var domainHost = "pbxip.voipprovider.com";
            var domainPort = 5060;

            var account = new SIPAccount(registrationRequired, displayName, userName, authenticationId, registerPassword, domainHost, domainPort);

            // Send SIP regitration request
            RegisterAccount(account);

            // Prevents the termination of the application
            Console.ReadLine();
        }

        static void RegisterAccount(SIPAccount account)
        {
            try
            {
                phoneLine = softphone.CreatePhoneLine(account);
                phoneLine.RegistrationStateChanged += sipAccount_RegStateChanged;
                softphone.RegisterPhoneLine(phoneLine);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error during SIP registration: " + ex);
            }
        }

        static void sipAccount_RegStateChanged(object sender, RegistrationStateChangedArgs e)
        {
            if (e.State == RegState.Error || e.State == RegState.NotRegistered)
                Console.WriteLine("Registration failed!");

            if (e.State == RegState.RegistrationSucceeded)
                Console.WriteLine("Registration succeeded - Online!");
        }
    }
}


(Source: SIP register example in C#[^])


这篇关于从PC ASP.NET c#拨打电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆