private static void Main(string[] args) {

            // Let us start the outboud server
            server = new FreeSwitchServer();
            server.ClientReady += OnClientReady;

            server.Start(IPAddress.Parse("192.168.74.1"), ServerPort);
            Thread.Sleep(500);

            string evenlist = "BACKGROUND_JOB  CHANNEL_PROGRESS  CHANNEL_PROGRESS_MEDIA  CHANNEL_HANGUP_COMPLETE  CHANNEL_STATE SESSION_HEARTBEAT  CALL_UPDATE RECORD_STOP  CHANNEL_BRIDGE  CHANNEL_UNBRIDGE  CHANNEL_ANSWER  CHANNEL_ORIGINATE CHANNEL_EXECUTE  CHANNEL_EXECUTE_COMPLETE";
            client = new OutboundChannelSession(Address, Port, Password, evenlist);
            client.OnChannelProgressMedia += OnChannelProgressMedia;
            client.OnChannelState += OnChannelState;
            bool connected = Connect().Result;
            if (connected) {
                Thread.Sleep(500);

                Log.Info("Connection Status {0}", client.Connected);
                Log.Info("Authentication Status {0}", client.Authenticated);

                var command = new ApiCommand("sofia profile external gwlist up");
                ApiResponse response = client.SendApi(command).Result;
                if (response == null) Log.Info("No gateways available");
                else if (string.IsNullOrEmpty(response.Body)) Log.Info("No gateways available");
                else
                {
                    List<string> gws = response.Body.Split().ToList();
                    if (gws.Any())
                    {
                        var counter = 1;
                        foreach (var gw in gws) Log.Info("Gateway no {0} : {1}", counter++, gw);
                    }
                }

                command = new ApiCommand("sofia status");
                response = client.SendApi(command).Result;
                Log.Info("sofia status :\n");
                Log.Info("\n\n" + response.Body);

                // Let us make a call and handle it
                string callCommand = "{ignore_early_media=false,originate_timeout=120}sofia/gateway/smsghlocalsip/233247063817 &socket(192.168.74.1:10000 async full)";
                BgApiCommand bgapicommand = new BgApiCommand("originate", callCommand);
                Guid jobId = client.SendBgApi(bgapicommand).Result;
                Log.Info("Job Id {0}", jobId);

                Thread.Sleep(500);

                // EslLogLevels levels = EslLogLevels.INFO;
                // client.SetLogLevel(levels);

                // client.CloseAsync();

                //Thread.Sleep(500);
                //Log.Info("Connection Status {0}", client.Connected);
                //Log.Info("Authentication Status {0}", client.Authenticated);

            }
            
            Console.ReadKey();
        }
 /// <summary>
 ///     SendApi().
 ///     It is used to send an api command to FreeSwitch.
 /// </summary>
 /// <param name="command"></param>
 /// <returns>ApiResponse response</returns>
 public async Task<ApiResponse> SendApi(ApiCommand command) {
     if (!Connected
         || !Authenticated)
         return null;
     // Send the command
     var event2 = EnqueueCommand(command);
     await SendAsync(command);
     return await event2.Task as ApiResponse;
 }