Пример #1
0
        private Program(IConfigurationRoot configuration)
        {
            var redis = configuration.GetConnectionString("redis");

            _redis = ConnectionMultiplexer.Connect(redis, null);
            Clear();

            var yateConfig = configuration.GetSection("Yate");

            _yate = new YateClient(yateConfig["host"], yateConfig.GetValue <ushort>("port"));
            _yate.Connect();
            Initialize(_yate);
            _yate.Watch("chan.startup", ChanUpdate);
            _yate.Watch("chan.hangup", ChanHangup);
            _yate.Watch("call.ringing", ChanUpdate);
            _yate.Watch("call.answered", ChanUpdate);
            _yate.Watch("chan.disconnected", ChanDisconnected);
            _yate.Watch("call.update", ChanUpdate);
            _yate.Watch("user.auth", UserAuth);
            _yate.Watch("user.register", UserRegister);
            _yate.Watch("user.unregister", UserUnregister);
        }
Пример #2
0
 private void Execute()
 {
     VTConsole.Enable();
     VTConsole.SetWindowTitle("Yate Status Monitor");
     UpdateDisplay();
     using (var resetEvent = new ManualResetEventSlim())
         using (var client = new YateClient(Host, Port))
         {
             Console.CancelKeyPress += (s, e) =>
             {
                 e.Cancel = true;
                 resetEvent.Set();
             };
             client.Connect(RoleType.Global);
             client.Log($"start for {Environment.UserName}");
             client.Watch("chan.startup", ChanUpdate);
             client.Watch("chan.hangup", ChanHangup);
             client.Watch("call.ringing", ChanUpdate);
             client.Watch("call.answered", ChanUpdate);
             client.Watch("chan.disconnected", ChanDisconnected);
             client.Watch("call.update", ChanUpdate);
             client.Watch("user.auth", UserAuth);
             client.Watch("user.register", UserRegister);
             client.Watch("user.unregister", UserUnregister);
             try
             {
                 UpdateFromStatus(client);
             }
             catch (Exception ex)
             {
                 FlashMessage("error", $"engine.status failed: {ex.Message}");
             }
             resetEvent.Wait();
             Cleanup();
         }
 }