/// <summary>
        /// The threadmethod for the Command-Interpreter
        /// </summary>
        private void ListenerMethod()
        {
            while (true)
            {
                HttpListenerContext output;
                try
                {
                    output = commandListener.GetContext();
                }
                catch
                {
                    break;
                }
                var response = output.Response;

                string sourceString = FilterCommandString(output.Request.Url.ToString());
                string message      = string.Empty;

                if (!ConsoleCommandWords.IsLogConsoleCommand(sourceString))
                {
                    string cleanSourceString = Command.CleanupGetString(sourceString);
                    string command           = string.Empty;
                    try
                    {
                        command = Command.ReformatCommandString(cleanSourceString);
                        ICommand parsedCommand = CommandParser.Parse(command);
                        if (parsedCommand == null)
                        {
                            message = "PARSER_ERROR";
                            LogConsole.ThrowParseError("PARSER_ERROR", sourceString);
                        }
                        else
                        {
                            cmdQueue.Enqueue(parsedCommand);
                            message = CommandExecutor.ExecuteCommand(cmdQueue.Dequeue());
                        }
                    }
                    catch
                    {
                        message = "PARSER_ERROR";
                        LogConsole.ThrowParseError("PARSER_ERROR", sourceString);
                    }
                }
                else
                {
                    message = "FORBIDDEN";
                    LogConsole.ThrowParseError("FORBIDDEN", sourceString);
                }
                response.ContentType = new System.Net.Mime.ContentType("text/plain").ToString();
                response.StatusCode  = Actions.ResolveToHttpStatusCode(message);

                byte[] byteCode = System.Text.Encoding.UTF8.GetBytes(message);
                response.OutputStream.Write(byteCode, 0, byteCode.Length);
                response.OutputStream.Flush();
                response.OutputStream.Close();
            }
        }
Example #2
0
        public MainForm()
        {
            this.Icon = Audiobox_Server.Properties.Resources.Audiobox_Icon;

            InitializeComponent();

            this.Text           = About.PRODUCTNAME + " " + About.VERSION_NUMBER;
            this.DoubleBuffered = true;

            HookupEventListeners();

            UserManager.Initialize();
            Settings.Initialize();
            ConsoleCommandWords.Initialize();
            Actions.CreateFolderStructures();

            commandInterpreter = new CommandInterpreter();
            sessionManager     = new SessionManager();
        }