Advertisement
Guest User

Untitled

a guest
Oct 11th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. ISipUserAgent ua;
  2. public class MyConfigurator : IConfigurationProvider
  3. {
  4. string SIP_USER = "";
  5. string SIP_PASSWORD = "";
  6. string SIP_DOMAIN = "";
  7. public MyConfigurator(string user, string password, string domain)
  8. {
  9. SIP_USER = user;
  10. SIP_PASSWORD = password;
  11. SIP_DOMAIN = domain;
  12. }
  13. public void Configure(IConfigurationContext context)
  14. {
  15. var registrar = "sip:" + SIP_DOMAIN;
  16. var accountId = "sip:" + SIP_USER + "@" + SIP_DOMAIN;
  17. var proxy = "";
  18. context.RegisterAccounts(new[]
  19. {
  20. new AccountConfig()
  21. {
  22. RegUri = registrar,
  23. Id = accountId,
  24. Credentials = new List<NetworkCredential>() {new NetworkCredential(SIP_USER, SIP_PASSWORD, "*") },
  25. Proxy = new List<string>() {proxy}
  26. },
  27. });
  28. }
  29. }
  30.  
  31. public SoftPhone_Widow(string user, string password, string domain)
  32. {
  33. InitializeComponent();
  34. Thread thread = new Thread(Method =>
  35. {
  36. ua = Configure.Pjsip4Net().With(new MyConfigurator("user1", "123312", "mangosip.ru")).Build().Start();
  37. ua.AccountManager.AccountStateChanged += AccountManager_AccountStateChanged;
  38. });
  39. thread.Start();
  40. }
  41.  
  42. private void AccountManager_AccountStateChanged(object sender, pjsip4net.Accounts.AccountStateChangedEventArgs e)
  43. {
  44. if (e != null)
  45. MessageBox.Show(e.StatusText);
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement