public async void InboundModeTest() { const string address = "10.0.75.2"; const string password = "******"; const int port = 8021; const int ServerPort = 10000; var client = new OutboundSession(address, port, password); await client.ConnectAsync(); Thread.Sleep(100); // this is due to the asynchronous pattern of the framework var inboundServer = new InboundServer(ServerPort, new DefaultInboundSession()); await inboundServer.StartAsync(); var callCommand = "{ignore_early_media=false,originate_timeout=120}sofia/gateway/smsghlocalsip/233247063817 &socket(192.168.74.1:10000 async full)"; var jobId = await client.SendBgApiAsync(new BgApiCommand("originate", callCommand)); Assert.True(jobId != Guid.Empty); }
private static void Main(string[] args) { const string address = "10.0.75.2"; const string password = "******"; const int port = 8021; const int ServerPort = 10000; try { //LogManager.Configuration = new XmlLoggingConfiguration(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\NLog.config"); var client = new OutboundSession(address, port, password); client.ConnectAsync().ConfigureAwait(false); Thread.Sleep(1000); _logger.Info("Connected and Authenticated {0}", client.CanSend()); var @event = "plain CHANNEL_HANGUP CHANNEL_HANGP_COMPLETE"; var subscribed = client.SubscribeAsync(@event).ConfigureAwait(true); System.Console.WriteLine("Api Response {0}", subscribed.GetAwaiter().GetResult()); _logger.Warn("Api Response {0}", subscribed.GetAwaiter().GetResult()); var commandString = "sofia profile external gwlist up"; var response = client.SendApiAsync(new ApiCommand(commandString)).ConfigureAwait(false); System.Console.WriteLine("hello test"); _logger.Warn("Api Response {0}", response.GetAwaiter().GetResult().ReplyText); var inboundServer = new InboundServer(ServerPort, new DefaultInboundSession()); inboundServer.StartAsync().Wait(500); var callCommand = "{ignore_early_media=false,originate_timeout=120}sofia/gateway/smsghlocalsip/233247063817 &socket(192.168.74.1:10000 async full)"; client.SendBgApiAsync(new BgApiCommand("originate", callCommand)).Wait(500); System.Console.ReadKey(); } catch (Exception e) { System.Console.WriteLine(e); System.Console.ReadLine(); return; } }
private static void Main(string[] args) { const string address = "192.168.74.128"; const string password = "******"; const int port = 8021; const int ServerPort = 10000; var client = new OutboundSession(address, port, password); client.ConnectAsync().ConfigureAwait(false); Thread.Sleep(1000); _logger.Info("Connected and Authenticated {0}", client.CanSend()); var @event = "plain CHANNEL_HANGUP CHANNEL_HANGP_COMPLETE"; var subscribed = client.SubscribeAsync(@event).ConfigureAwait(false); var commandString = "sofia profile external gwlist up"; var response = client.SendApiAsync(new ApiCommand(commandString)).ConfigureAwait(false); _logger.Warn("Api Response {0}", response.GetAwaiter().GetResult().ReplyText); var inboundServer = new InboundServer(ServerPort, new DefaultInboundSession()); inboundServer.StartAsync().Wait(500); var callCommand = "{ignore_early_media=false,originate_timeout=120}sofia/gateway/smsghlocalsip/233247063817 &socket(192.168.74.1:10000 async full)"; client.SendBgApiAsync(new BgApiCommand("originate", callCommand)).Wait(500); System.Console.ReadKey(); }