ladendirekt / pjsip4net

A wrapper library exposing the pjsip library to the .NET world in a OO-friendly way.
71 stars 42 forks source link

First steps: Registration, outgoing call, incoming call. #80

Closed Mikhail-Fadeev closed 7 years ago

Mikhail-Fadeev commented 7 years ago

Hi, I can not figure out how registration works. What do I need to do to send a request to the server and get a response about successful authorization, otherwise I have not been able to figure it out for several days. And how to make a call or listen to an incoming call. If it does not complicate you.

Mikhail-Fadeev commented 7 years ago

I use ` public class MyConfigurator : IConfigurationProvider { public void Configure(IConfigurationContext context) { var registrar = "vpbx400102665.mangosip.ru"; var accountId = new SipUriBuilder().AppendDomain("vpbx400102665.mangosip.ru").AppendExtension("user1").ToString(); var proxy = ""; context.RegisterAccounts(new[] { new AccountConfig() { RegUri = registrar, Id = accountId, Credentials = new List() {new NetworkCredential("user1", "123321", "*")}, Proxy = new List() {proxy} }, }); } } public Form1() { InitializeComponent();

        var ua = Configure.Pjsip4Net().With(new MyConfigurator()).WithVersion_1_4().Build().Start();

        ua.Container.Get<IAccountBuilder>() /* ERROR does not contain a definition "Container" */
            .WithExtension("user1")
            .WithPassword("123321")
            .At("vpbx400102665.mangosip.ru")
            .ExposeAccount(x => x.Proxies.Add("proxy.live.sipgate.de"))
            .Register();
        ua.Destroy();
       ua.CallManager.MakeCall(ua.AccountManager.GetAccountById(0), "11@mangosip.ru");
    }

`

siniypin commented 7 years ago

Hi, assuming you're familiar with SIP registration process in general, following is the way you can register with your registrar server using pjsip4net:

Assuming you have a valid registered account you can make a call like that https://github.com/siniypin/pjsip4net/blob/master/Tests/Integration/pjsip4net.Console/CommandFactory.cs#L476 .
To answer an incoming call you have two possibilities:

Hope that helps.

Mikhail-Fadeev commented 7 years ago

https://gist.github.com/siniypin/7860029 Thanks for the response and the links provided. I tried to read from the App.config file, but the data was still not read.

siniypin commented 7 years ago

Just a general advice - try running and playing around with a test console app https://github.com/siniypin/pjsip4net/blob/master/Tests/Integration/pjsip4net.Console and then copy the parts you'd need over to your app.

Mikhail-Fadeev commented 7 years ago

Thank you so much. It turned out to make the registration, the definition of incoming and outgoing calls. I will continue to study your work. And the last question is how to change the status to online and do you still have links, only for working with audio devices?

siniypin commented 7 years ago

You are welcome.
To publish your account's presence status (Online/Offline) you need to set a publishPresence https://github.com/siniypin/pjsip4net/blob/master/pjsip4net/Accounts/Account.cs#L159 property of your account config to true. You can only set it during an initialization phase either in config file or in code, depending on how you register the account, so be careful with that. After you've configured and registered your account the status will get published automatically. If you want to publish a custom status string you can do so with PublishOnline(note) method https://github.com/siniypin/pjsip4net/blob/master/pjsip4net/Accounts/Account.cs#L357