public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene) :
                base(null, uri, null, null, null, null, pId, int.MaxValue)
            {
                m_scene = scene;

                // x is request id, y is userid
                HasEvents = (x, y) =>
                {
                    lock (responses)
                    {
                        APollResponse response;
                        if (responses.TryGetValue(x, out response))
                        {
                            if (m_presence == null)
                            {
                                m_presence = m_scene.GetScenePresence(pId);
                            }

                            if (m_presence == null || m_presence.IsDeleted)
                            {
                                return(true);
                            }
                            if (response.throttle)
                            {
                                return(m_presence.CapCanSendAsset(1, response.bytes));
                            }
                            return(m_presence.CapCanSendAsset(2, response.bytes));
                        }
                        return(false);
                    }
                };

                Drop = (x, y) =>
                {
                    lock (responses)
                    {
                        responses.Remove(x);
                        lock (dropedResponses)
                            dropedResponses.Add(x);
                    }
                };

                GetEvents = (x, y) =>
                {
                    lock (responses)
                    {
                        try
                        {
                            return(responses[x].response);
                        }
                        finally
                        {
                            responses.Remove(x);
                        }
                    }
                };
                // x is request id, y is request data hashtable
                Request = (x, y) =>
                {
                    APollRequest reqinfo = new APollRequest();
                    reqinfo.thepoll = this;
                    reqinfo.reqID   = x;
                    reqinfo.request = y;

                    m_queue.Add(reqinfo);
                };

                // this should never happen except possible on shutdown
                NoEvents = (x, y) =>
                {
                    /*
                     *                  lock (requests)
                     *                  {
                     *                      Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString());
                     *                      requests.Remove(request);
                     *                  }
                     */
                    Hashtable response = new Hashtable();

                    response["int_response_code"]   = 500;
                    response["str_response_string"] = "timeout";
                    response["content_type"]        = "text/plain";
                    response["keepalive"]           = false;
                    return(response);
                };
            }
Exemplo n.º 2
0
            public PollServiceAssetEventArgs(string uri, UUID pId, Scene scene, string HGAssetSVC) :
                base(null, uri, null, null, null, null, pId, int.MaxValue)
            {
                m_scene    = scene;
                m_hgassets = HGAssetSVC;

                HasEvents = (requestID, agentID) =>
                {
                    lock (responses)
                    {
                        APollResponse response;
                        if (responses.TryGetValue(requestID, out response))
                        {
                            ScenePresence sp = m_scene.GetScenePresence(pId);

                            if (sp == null || sp.IsDeleted)
                            {
                                return(true);
                            }

                            OSHttpResponse resp = response.osresponse;

                            if (Util.GetTimeStamp() - resp.RequestTS > (resp.RawBufferLen > 2000000 ? 200 : 90))
                            {
                                return(sp.CapCanSendAsset(2, resp.RawBufferLen));
                            }

                            if (resp.Priority > 1)
                            {
                                return(sp.CapCanSendAsset(1, resp.RawBufferLen));
                            }
                            return(sp.CapCanSendAsset(2, resp.RawBufferLen));
                        }
                        return(false);
                    }
                };

                Drop = (requestID, y) =>
                {
                    lock (responses)
                    {
                        responses.Remove(requestID);
                        lock (dropedResponses)
                            dropedResponses.Add(requestID);
                    }
                };

                GetEvents = (requestID, y) =>
                {
                    lock (responses)
                    {
                        try
                        {
                            OSHttpResponse response = responses[requestID].osresponse;
                            if (response.Priority < 0)
                            {
                                response.Priority = 0;
                            }

                            Hashtable lixo = new Hashtable(1);
                            lixo["h"] = response;
                            return(lixo);
                        }
                        finally
                        {
                            responses.Remove(requestID);
                        }
                    }
                };
                // x is request id, y is request data hashtable
                Request = (requestID, request) =>
                {
                    APollRequest reqinfo = new APollRequest();
                    reqinfo.thepoll = this;
                    reqinfo.reqID   = requestID;
                    reqinfo.request = request;

                    m_queue.Add(reqinfo);
                };

                // this should never happen except possible on shutdown
                NoEvents = (x, y) =>
                {
                    /*
                     *                  lock (requests)
                     *                  {
                     *                      Hashtable request = requests.Find(id => id["RequestID"].ToString() == x.ToString());
                     *                      requests.Remove(request);
                     *                  }
                     */
                    Hashtable response = new Hashtable();

                    response["int_response_code"]   = 500;
                    response["str_response_string"] = "timeout";
                    response["content_type"]        = "text/plain";
                    response["keepalive"]           = false;
                    return(response);
                };
            }
Exemplo n.º 3
0
            public PollServiceAssetEventArgs(UUID pId, Scene scene) :
                base(null, "", null, null, null, null, pId, int.MaxValue)
            {
                m_scene = scene;
                // x is request id, y is userid
                HasEvents = (x, y) =>
                {
                    lock (responses)
                    {
                        APollResponse response;
                        if (responses.TryGetValue(x, out response))
                        {
                            if (m_presence == null)
                            {
                                m_presence = m_scene.GetScenePresence(pId);
                            }

                            if (m_presence == null || m_presence.IsDeleted)
                            {
                                return(true);
                            }
                            return(m_presence.CapCanSendAsset(0, response.bytes));
                        }
                        return(false);
                    }
                };

                Drop = (x, y) =>
                {
                    lock (responses)
                    {
                        responses.Remove(x);
                        dropedResponses.Add(x);
                    }
                };

                GetEvents = (x, y) =>
                {
                    lock (responses)
                    {
                        try
                        {
                            return(responses[x].response);
                        }
                        finally
                        {
                            responses.Remove(x);
                        }
                    }
                };
                // x is request id, y is request data hashtable
                Request = (x, y) =>
                {
                    APollRequest reqinfo = new APollRequest();
                    reqinfo.thepoll = this;
                    reqinfo.reqID   = x;
                    reqinfo.request = y;
                    reqinfo.send503 = false;

                    lock (responses)
                    {
                        if (responses.Count > 0 && m_queue.Count > 32)
                        {
                            reqinfo.send503 = true;
                        }
                    }

                    m_queue.Add(reqinfo);
                };

                // this should never happen except possible on shutdown
                NoEvents = (x, y) =>
                {
                    Hashtable response = new Hashtable();

                    response["int_response_code"]   = 500;
                    response["str_response_string"] = "timeout";
                    response["content_type"]        = "text/plain";
                    response["keepalive"]           = false;
                    return(response);
                };
            }