public void Run()
        {
            try
            {
                AGIReader reader = new AGIReader(socket);
                AGIWriter writer = new AGIWriter(socket);
                AGIRequest request = reader.ReadRequest();
                AGIChannel channel = new AGIChannel(writer, reader);
                AGIScript script = mappingStrategy.DetermineScript(request);
                Thread.SetData(AGIConnectionHandler.channel, channel);

                if (script != null)
                {
            #if LOGGER
                    logger.Info("Begin AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name);
            #endif
                    script.Service(request, channel);
            #if LOGGER
                    logger.Info("End AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name);
            #endif
                }
                else
                {
                    string error;
                    error = "No script configured for URL '" + request.RequestURL + "' (script '" + request.Script + "')";
                    channel.SendCommand(new Command.VerboseCommand(error, 1));
            #if LOGGER
                    logger.Error(error);
            #endif
                }
            }
            catch (AGIHangupException)
            {
            }
            catch (IOException)
            {
            }
            catch (AGIException ex)
            {
            #if LOGGER
                logger.Error("AGIException while handling request", ex);
            #else
                throw ex;
            #endif
            }
            catch (Exception ex)
            {
            #if LOGGER
                logger.Error("Unexpected Exception while handling request", ex);
            #else
                throw ex;
            #endif
            }

            Thread.SetData(AGIConnectionHandler.channel, null);
            try
            {
                socket.Close();
            }
            #if LOGGER
            catch(IOException ex)
            {
                logger.Error("Error on close socket", ex);
            }
            #else
            catch { }
            #endif
        }
        public void Run()
        {
            try
            {
                AGIReader  reader  = new AGIReader(socket);
                AGIWriter  writer  = new AGIWriter(socket);
                AGIRequest request = reader.ReadRequest();
                AGIChannel channel = new AGIChannel(writer, reader);
                AGIScript  script  = mappingStrategy.DetermineScript(request);
                Thread.SetData(AGIConnectionHandler.channel, channel);

                if (script != null)
                {
#if LOGGER
                    logger.Info("Begin AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name);
#endif
                    script.Service(request, channel);
#if LOGGER
                    logger.Info("End AGIScript " + script.GetType().FullName + " on " + Thread.CurrentThread.Name);
#endif
                }
                else
                {
                    string error;
                    error = "No script configured for URL '" + request.RequestURL + "' (script '" + request.Script + "')";
                    channel.SendCommand(new Command.VerboseCommand(error, 1));
#if LOGGER
                    logger.Error(error);
#endif
                }
            }
            catch (AGIHangupException)
            {
            }
            catch (IOException)
            {
            }
            catch (AGIException ex)
            {
#if LOGGER
                logger.Error("AGIException while handling request", ex);
#else
                throw ex;
#endif
            }
            catch (Exception ex)
            {
#if LOGGER
                logger.Error("Unexpected Exception while handling request", ex);
#else
                throw ex;
#endif
            }

            Thread.SetData(AGIConnectionHandler.channel, null);
            try
            {
                socket.Close();
            }
#if LOGGER
            catch (IOException ex)
            {
                logger.Error("Error on close socket", ex);
            }
#else
            catch { }
#endif
        }