public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) { OSDMap events = new OSDMap(); try { OSD element; lock (queue) { if (queue.Count == 0) return NoEvents(requestID, pAgentId); element = queue.Dequeue(); } OSDArray array = new OSDArray(); if (element == null) // didn't have an event in 15s { //return NoEvents(requestID, pAgentId); // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! OSDMap keepAliveEvent = new OSDMap(2) {{"body", new OSDMap()}, {"message", new OSDString("FAKEEVENT")}}; element = keepAliveEvent; array.Add(keepAliveEvent); //MainConsole.Instance.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName); } array.Add(element); lock (queue) { while (queue.Count > 0) { array.Add(queue.Dequeue()); m_ids++; } } int removeAt = -1; //Look for disable Simulator EQMs so that we can disable ourselves safely foreach (OSD ev in array) { try { if (ev.Type == OSDType.Map) { OSDMap map = (OSDMap) ev; if (map.ContainsKey("message") && map["message"] == "DisableSimulator") { MainConsole.Instance.Debug("[EQService]: Sim Request to Disable Simulator " + m_service.RegionHandle); removeAt = array.IndexOf(ev); //This will be the last bunch of EQMs that go through, so we can safely die now //Except that we can't do this, the client will freak if we do this //m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle); } } } catch { } } if (removeAt != -1) array.RemoveAt(removeAt); events.Add("events", array); events.Add("id", new OSDInteger(m_ids)); m_ids++; } catch (Exception ex) { MainConsole.Instance.Warn("[EQS]: Exception! " + ex); } 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); //MainConsole.Instance.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); return responsedata; }
public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) { OSDMap events = new OSDMap(); try { OSD element; lock (queue) { if (queue.Count == 0) { return(NoEvents(requestID, pAgentId)); } element = queue.Dequeue(); } OSDArray array = new OSDArray(); if (element == null) // didn't have an event in 15s { //return NoEvents(requestID, pAgentId); // Send it a fake event to keep the client polling! It doesn't like 502s like the proxys say! OSDMap keepAliveEvent = new OSDMap(2) { { "body", new OSDMap() }, { "message", new OSDString("FAKEEVENT") } }; element = keepAliveEvent; array.Add(keepAliveEvent); //MainConsole.Instance.DebugFormat("[EVENTQUEUE]: adding fake event for {0} in region {1}", pAgentId, m_scene.RegionInfo.RegionName); } array.Add(element); lock (queue) { while (queue.Count > 0) { array.Add(queue.Dequeue()); m_ids++; } } int removeAt = -1; //Look for disable Simulator EQMs so that we can disable ourselves safely foreach (OSD ev in array) { try { if (ev.Type == OSDType.Map) { OSDMap map = (OSDMap)ev; if (map.ContainsKey("message") && map["message"] == "DisableSimulator") { MainConsole.Instance.Debug("[EQService]: Sim Request to Disable Simulator " + m_service.RegionHandle); removeAt = array.IndexOf(ev); //This will be the last bunch of EQMs that go through, so we can safely die now //Except that we can't do this, the client will freak if we do this //m_service.ClientCaps.RemoveCAPS(m_service.RegionHandle); } } } catch { } } if (removeAt != -1) { array.RemoveAt(removeAt); } events.Add("events", array); events.Add("id", new OSDInteger(m_ids)); m_ids++; } catch (Exception ex) { MainConsole.Instance.Warn("[EQS]: Exception! " + ex); } 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); //MainConsole.Instance.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", pAgentId, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); return(responsedata); }