public static void Main(string[] args) { XmlConfigurator.Configure(); _logger = LogManager.GetLogger("root"); var ua = Configure.Pjsip4Net().FromConfig().WithVersion_1_4().Build().Start(); ua.Log += Log; ua.ImManager.IncomingMessage += ImManager_IncomingMessage; ua.CallManager.CallRedirected += CallManager_CallRedirected; var factory = new CommandFactory(ua); factory.Create("?").Execute(); while (true) { try { var line = System.Console.ReadLine(); if (string.IsNullOrEmpty(line)) break; var command = factory.Create(line); command.Execute(); } catch(PjsipErrorException ex) { System.Console.WriteLine(ex.Message); } catch(SystemException ex) { System.Console.WriteLine(ex.Message); } } ua.Destroy(); }
public static void Main(string[] args) { XmlConfigurator.Configure(); _logger = LogManager.GetLogger("root");//logging is purely an application facility, you can choose whatever you want to log with var container = new WindsorContainer(); var cfg = Configure.Pjsip4Net()//dynamically discovers interop assembly and loads API providers unless concrete version loader specified .With_CastleContainer(container)//plugs an existing DI-container .FromConfig();//read configuration from .config file var ua = cfg.Build().Start();//build and start ua.ImManager.IncomingMessage += IncomingMessage; ua.CallManager.CallRedirected += CallRedirected; ua.CallManager.IncomingDtmfDigit += IncomingDtmfDigit; ua.ImManager.NatDetected += OnNatDetected; ua.CallManager.IncomingCall += CallManager_IncomingCall; ua.CallManager.Ring += CallManager_Ring; ua.CallManager.CallStateChanged += CallManager_CallStateChanged; var factory = new CommandFactory(ua, cfg.Container); factory.Create("?").Execute(); while (true) { try { var line = System.Console.ReadLine(); if (string.IsNullOrEmpty(line)) break; var command = factory.Create(line); command.Execute(); } catch(PjsipErrorException ex) { System.Console.WriteLine(ex.Message); } catch(SystemException ex) { System.Console.WriteLine(ex.Message); } } ua.Destroy(); }