Skip to content

Instantly share code, notes, and snippets.

@siniypin
Created July 8, 2013 19:21
Show Gist options
  • Save siniypin/5951687 to your computer and use it in GitHub Desktop.
Save siniypin/5951687 to your computer and use it in GitHub Desktop.
Creating sip preconfigured and dynamic sip accounts.
public class Class1
{
public class MyConfigurator : IConfigurationProvider
{
public void Configure(IConfigurationContext context)
{
var registrar = "sipgate.de";
var accountId = new SipUriBuilder().AppendDomain("sipgate.de").AppendExtension("me").ToString();
var proxy = "proxy.live.sipgate.de";
context.RegisterAccounts(new[]
{
new AccountConfig()
{
RegUri = registrar,
Id = accountId,
Credentials = new List<NetworkCredential>() {new NetworkCredential("me", "password", "*")},
Proxy = new List<string>() {proxy}
},
});
}
}
public static void Main()
{
//account to be configured in initialization stage
var ua = Configure.Pjsip4Net().With(new MyConfigurator()).WithVersion_1_4().Build().Start();
//account to be configured dynamically
ua.Container.Get<IAccountBuilder>()
.WithExtension("me")
.WithPassword("password")
.At("sipgate.de")
.ExposeAccount(x => x.Proxies.Add("proxy.live.sipgate.de"))
.Register();
ua.Destroy();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment