public override string ReadLine(string p, bool isCommand, bool e)
        {
            if (isCommand)
            {
                Output("+++" + p);
            }
            else
            {
                Output("-++" + p);
            }

            string cmdinput = m_InputData.Dequeue();

            if (isCommand)
            {
                string[] cmd = Commands.Resolve(Parser.Parse(cmdinput));

                if (cmd.Length != 0)
                {
                    int i;

                    for (i = 0; i < cmd.Length; i++)
                    {
                        if (cmd[i].Contains(" "))
                        {
                            cmd[i] = "\"" + cmd[i] + "\"";
                        }
                    }
                    return(String.Empty);
                }
            }
            return(cmdinput);
        }
        public void Stop()
        {
            IsRunning = false;
//            m_timeout = -10000; // cause all to expire
            Thread.Sleep(1000); // let the world move

            foreach (Thread t in m_workerThreads)
            {
                Watchdog.AbortThread(t.ManagedThreadId);
            }

            PollServiceHttpRequest wreq;

            if (m_longPollRequests.Count > 0 && IsRunning)
            {
                m_longPollRequests.ForEach(req => m_requests.Enqueue(req));
            }

            try
            {
                while (true)
                {
                    wreq = m_requests.Dequeue(0);
                    ResponsesProcessed++;
                    try
                    {
                        wreq.DoHTTPGruntWork(
                            m_server, wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id));
                    }
                    catch
                    {
                    }
                }
            }
            catch
            {
            }

            m_longPollRequests.Clear();
            m_requests.Clear();
        }
示例#3
0
        public void WaitProcessQueuedInventoryRequest()
        {
            aPollRequest poolreq = m_queue.Dequeue();

            if (poolreq != null && poolreq.thepoll != null)
            {
                try
                {
                    poolreq.thepoll.Process(poolreq);
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat(
                        "[INVENTORY]: Failed to process queued inventory request {0} for {1} in {2}.  Exception {3}",
                        poolreq.reqID, poolreq.presence != null ? poolreq.presence.Name : "unknown", Scene.Name, e);
                }
            }
        }
示例#4
0
        public Hashtable GetEvents(UUID requestID, UUID pAgentId)
        {
            if (DebugLevel >= 2)
            {
                m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.Name);
            }

            ThreadedClasses.BlockingQueue <OSD> queue = GetQueue(pAgentId);
            if (queue == null)
            {
                return(NoEvents(requestID, pAgentId));
            }

            OSD element;

            try
            {
                element = queue.Dequeue(15000);
            }
            catch
            {
                return(NoEvents(requestID, pAgentId));
            }

            int thisID = m_ids[pAgentId];

            OSDArray array = new OSDArray();

            if (element == null) // didn't have an event in 15s
            {
                // Send it a fake event to keep the client polling!   It doesn't like 502s like the proxys say!
                array.Add(EventQueueHelper.KeepAliveEvent());
                //m_log.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName);
            }
            else
            {
                if (DebugLevel > 0)
                {
                    LogOutboundDebugMessage(element, pAgentId);
                }

                array.Add(element);

                lock (queue) /* we use this here to get the inner code race condition safe, NonblockingQueue tolerates this */
                {
                    while (queue.Count > 0)
                    {
                        element = queue.Dequeue();

                        if (DebugLevel > 0)
                        {
                            LogOutboundDebugMessage(element, pAgentId);
                        }

                        array.Add(element);
                        thisID++;
                    }
                }
            }

            OSDMap events = new OSDMap();

            events.Add("events", array);

            events.Add("id", new OSDInteger(thisID));
            m_ids[pAgentId] = thisID + 1;
            Hashtable responsedata = new Hashtable();

            responsedata["int_response_code"]   = 200;
            responsedata["content_type"]        = "application/xml";
            responsedata["keepalive"]           = false;
            responsedata["reusecontext"]        = false;
            responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events);
            //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]);
            return(responsedata);
        }
        private void ConsoleOutputThread()
        {
            Thread.CurrentThread.Name = "Console Output Thread";
            for (; ;)
            {
                KeyValuePair <string, string> output;
                try
                {
                    output = m_consoleQueue.Dequeue(1000);
                }
                catch (Exception)
                {
                    continue;
                }
                if (m_AbortConsoleThread)
                {
                    break;
                }
                FireOnOutput(output.Key);

                lock (m_commandLine)
                {
                    if (m_cursorYPosition == -1)
                    {
                        WriteLocalText(output.Key, output.Value);
                    }
                    else
                    {
                        try
                        {
                            m_cursorYPosition = SetCursorTop(m_cursorYPosition);
                        }
                        catch
                        {
                        }
                        SetCursorLeft(0);

                        int count = m_commandLine.Length + prompt.Length;

                        if (count != 0)
                        {
                            string d = "";
                            while (count-- > 0)
                            {
                                d += " ";
                            }

                            System.Console.Write(d);
                        }

                        try
                        {
                            m_cursorYPosition = SetCursorTop(m_cursorYPosition);
                        }
                        catch
                        {
                        }
                        SetCursorLeft(0);

                        WriteLocalText(output.Key, output.Value);

                        m_cursorYPosition = System.Console.CursorTop;

                        Show();
                    }
                }
            }
        }