From d8ee0cbe1cf93ca521f52ce39aa2a15cb5784e48 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 30 Apr 2011 09:24:15 -0700 Subject: First stab at cleaning up Caps. Compiles. Untested. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 729 +++++++++++++++++++++ .../Linden/Caps/EventQueue/EventQueueHelper.cs | 399 +++++++++++ 2 files changed, 1128 insertions(+) create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs new file mode 100644 index 0000000..fe97bf2 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -0,0 +1,729 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Net; +using System.Reflection; +using System.Threading; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenMetaverse.Messages.Linden; +using OpenMetaverse.Packets; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using BlockingLLSDQueue = OpenSim.Framework.BlockingQueue; +using Caps=OpenSim.Framework.Capabilities.Caps; + +namespace OpenSim.Region.ClientStack.Linden +{ + public struct QueueItem + { + public int id; + public OSDMap body; + } + + public class EventQueueGetModule : IEventQueue, IRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected Scene m_scene = null; + private IConfigSource m_gConfig; + bool enabledYN = false; + + private Dictionary m_ids = new Dictionary(); + + private Dictionary> queues = new Dictionary>(); + private Dictionary m_QueueUUIDAvatarMapping = new Dictionary(); + private Dictionary m_AvatarQueueUUIDMapping = new Dictionary(); + + #region IRegionModule methods + public virtual void Initialise(Scene scene, IConfigSource config) + { + m_gConfig = config; + + IConfig startupConfig = m_gConfig.Configs["Startup"]; + + ReadConfigAndPopulate(scene, startupConfig, "Startup"); + + if (enabledYN) + { + m_scene = scene; + scene.RegisterModuleInterface(this); + + // Register fallback handler + // Why does EQG Fail on region crossings! + + //scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack); + + scene.EventManager.OnNewClient += OnNewClient; + + // TODO: Leaving these open, or closing them when we + // become a child is incorrect. It messes up TP in a big + // way. CAPS/EQ need to be active as long as the UDP + // circuit is there. + + scene.EventManager.OnClientClosed += ClientClosed; + scene.EventManager.OnMakeChildAgent += MakeChildAgent; + scene.EventManager.OnRegisterCaps += OnRegisterCaps; + } + else + { + m_gConfig = null; + } + + } + + private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p) + { + enabledYN = startupConfig.GetBoolean("EventQueue", true); + } + + public void PostInitialise() + { + } + + public virtual void Close() + { + } + + public virtual string Name + { + get { return "EventQueueGetModule"; } + } + + public bool IsSharedModule + { + get { return false; } + } + #endregion + + /// + /// Always returns a valid queue + /// + /// + /// + private Queue TryGetQueue(UUID agentId) + { + lock (queues) + { + if (!queues.ContainsKey(agentId)) + { + /* + m_log.DebugFormat( + "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", + agentId, m_scene.RegionInfo.RegionName); + */ + queues[agentId] = new Queue(); + } + + return queues[agentId]; + } + } + + /// + /// May return a null queue + /// + /// + /// + private Queue GetQueue(UUID agentId) + { + lock (queues) + { + if (queues.ContainsKey(agentId)) + { + return queues[agentId]; + } + else + return null; + } + } + + #region IEventQueue Members + + public bool Enqueue(OSD ev, UUID avatarID) + { + //m_log.DebugFormat("[EVENTQUEUE]: Enqueuing event for {0} in region {1}", avatarID, m_scene.RegionInfo.RegionName); + try + { + Queue queue = GetQueue(avatarID); + if (queue != null) + queue.Enqueue(ev); + } + catch(NullReferenceException e) + { + m_log.Error("[EVENTQUEUE] Caught exception: " + e); + return false; + } + + return true; + } + + #endregion + + private void OnNewClient(IClientAPI client) + { + //client.OnLogout += ClientClosed; + } + +// private void ClientClosed(IClientAPI client) +// { +// ClientClosed(client.AgentId); +// } + + private void ClientClosed(UUID AgentID, Scene scene) + { + //m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", AgentID, m_scene.RegionInfo.RegionName); + + int count = 0; + while (queues.ContainsKey(AgentID) && queues[AgentID].Count > 0 && count++ < 5) + { + Thread.Sleep(1000); + } + + lock (queues) + { + queues.Remove(AgentID); + } + List removeitems = new List(); + lock (m_AvatarQueueUUIDMapping) + { + foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys) + { + if (ky == AgentID) + { + removeitems.Add(ky); + } + } + + foreach (UUID ky in removeitems) + { + m_AvatarQueueUUIDMapping.Remove(ky); + MainServer.Instance.RemovePollServiceHTTPHandler("","/CAPS/EQG/" + ky.ToString() + "/"); + } + + } + UUID searchval = UUID.Zero; + + removeitems.Clear(); + + lock (m_QueueUUIDAvatarMapping) + { + foreach (UUID ky in m_QueueUUIDAvatarMapping.Keys) + { + searchval = m_QueueUUIDAvatarMapping[ky]; + + if (searchval == AgentID) + { + removeitems.Add(ky); + } + } + + foreach (UUID ky in removeitems) + m_QueueUUIDAvatarMapping.Remove(ky); + + } + } + + private void MakeChildAgent(ScenePresence avatar) + { + //m_log.DebugFormat("[EVENTQUEUE]: Make Child agent {0} in region {1}.", avatar.UUID, m_scene.RegionInfo.RegionName); + //lock (m_ids) + // { + //if (m_ids.ContainsKey(avatar.UUID)) + //{ + // close the event queue. + //m_ids[avatar.UUID] = -1; + //} + //} + } + + public void OnRegisterCaps(UUID agentID, Caps caps) + { + // Register an event queue for the client + + //m_log.DebugFormat( + // "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", + // agentID, caps, m_scene.RegionInfo.RegionName); + + // Let's instantiate a Queue for this agent right now + TryGetQueue(agentID); + + string capsBase = "/CAPS/EQG/"; + UUID EventQueueGetUUID = UUID.Zero; + + lock (m_AvatarQueueUUIDMapping) + { + // Reuse open queues. The client does! + if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) + { + //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); + EventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; + } + else + { + EventQueueGetUUID = UUID.Random(); + //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); + } + } + + lock (m_QueueUUIDAvatarMapping) + { + if (!m_QueueUUIDAvatarMapping.ContainsKey(EventQueueGetUUID)) + m_QueueUUIDAvatarMapping.Add(EventQueueGetUUID, agentID); + } + + lock (m_AvatarQueueUUIDMapping) + { + if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID)) + m_AvatarQueueUUIDMapping.Add(agentID, EventQueueGetUUID); + } + + // Register this as a caps handler + caps.RegisterHandler("EventQueueGet", + new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/", + delegate(Hashtable m_dhttpMethod) + { + return ProcessQueue(m_dhttpMethod, agentID, caps); + })); + + // This will persist this beyond the expiry of the caps handlers + MainServer.Instance.AddPollServiceHTTPHandler( + capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); + + Random rnd = new Random(Environment.TickCount); + lock (m_ids) + { + if (!m_ids.ContainsKey(agentID)) + m_ids.Add(agentID, rnd.Next(30000000)); + } + } + + public bool HasEvents(UUID requestID, UUID agentID) + { + // Don't use this, because of race conditions at agent closing time + //Queue queue = TryGetQueue(agentID); + + Queue queue = GetQueue(agentID); + if (queue != null) + lock (queue) + { + if (queue.Count > 0) + return true; + else + return false; + } + return false; + } + + public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) + { + Queue queue = TryGetQueue(pAgentId); + OSD element; + lock (queue) + { + if (queue.Count == 0) + return NoEvents(requestID, pAgentId); + element = queue.Dequeue(); // 15s timeout + } + + + + int thisID = 0; + lock (m_ids) + 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 + { + array.Add(element); + lock (queue) + { + while (queue.Count > 0) + { + array.Add(queue.Dequeue()); + thisID++; + } + } + } + + OSDMap events = new OSDMap(); + events.Add("events", array); + + events.Add("id", new OSDInteger(thisID)); + lock (m_ids) + { + 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; + } + + public Hashtable NoEvents(UUID requestID, UUID agentID) + { + Hashtable responsedata = new Hashtable(); + responsedata["int_response_code"] = 502; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["reusecontext"] = false; + responsedata["str_response_string"] = "Upstream error: "; + responsedata["error_status_text"] = "Upstream error:"; + responsedata["http_protocol_version"] = "HTTP/1.0"; + return responsedata; + } + + public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps) + { + // TODO: this has to be redone to not busy-wait (and block the thread), + // TODO: as soon as we have a non-blocking way to handle HTTP-requests. + +// if (m_log.IsDebugEnabled) +// { +// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ "; +// foreach (object key in request.Keys) +// { +// debug += key.ToString() + "=" + request[key].ToString() + " "; +// } +// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name); +// } + + Queue queue = TryGetQueue(agentID); + OSD element = queue.Dequeue(); // 15s timeout + + Hashtable responsedata = new Hashtable(); + + int thisID = 0; + lock (m_ids) + thisID = m_ids[agentID]; + + if (element == null) + { + //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName); + if (thisID == -1) // close-request + { + m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName); + responsedata["int_response_code"] = 404; //501; //410; //404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "Closed EQG"; + return responsedata; + } + responsedata["int_response_code"] = 502; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "Upstream error: "; + responsedata["error_status_text"] = "Upstream error:"; + responsedata["http_protocol_version"] = "HTTP/1.0"; + return responsedata; + } + + 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}", agentID, m_scene.RegionInfo.RegionName); + } + else + { + array.Add(element); + while (queue.Count > 0) + { + array.Add(queue.Dequeue()); + thisID++; + } + } + + OSDMap events = new OSDMap(); + events.Add("events", array); + + events.Add("id", new OSDInteger(thisID)); + lock (m_ids) + { + m_ids[agentID] = thisID + 1; + } + + responsedata["int_response_code"] = 200; + responsedata["content_type"] = "application/xml"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); + //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); + + return responsedata; + } + + public Hashtable EventQueuePoll(Hashtable request) + { + return new Hashtable(); + } + + public Hashtable EventQueuePath2(Hashtable request) + { + string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); + // pull off the last "/" in the path. + Hashtable responsedata = new Hashtable(); + capuuid = capuuid.Substring(0, capuuid.Length - 1); + capuuid = capuuid.Replace("/CAPS/EQG/", ""); + UUID AvatarID = UUID.Zero; + UUID capUUID = UUID.Zero; + + // parse the path and search for the avatar with it registered + if (UUID.TryParse(capuuid, out capUUID)) + { + lock (m_QueueUUIDAvatarMapping) + { + if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) + { + AvatarID = m_QueueUUIDAvatarMapping[capUUID]; + } + } + if (AvatarID != UUID.Zero) + { + return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsHandlerForUser(AvatarID)); + } + else + { + responsedata["int_response_code"] = 404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "Not Found"; + responsedata["error_status_text"] = "Not Found"; + responsedata["http_protocol_version"] = "HTTP/1.0"; + return responsedata; + // return 404 + } + } + else + { + responsedata["int_response_code"] = 404; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = "Not Found"; + responsedata["error_status_text"] = "Not Found"; + responsedata["http_protocol_version"] = "HTTP/1.0"; + return responsedata; + // return 404 + } + + } + + public OSD EventQueueFallBack(string path, OSD request, string endpoint) + { + // This is a fallback element to keep the client from loosing EventQueueGet + // Why does CAPS fail sometimes!? + m_log.Warn("[EVENTQUEUE]: In the Fallback handler! We lost the Queue in the rest handler!"); + string capuuid = path.Replace("/CAPS/EQG/",""); + capuuid = capuuid.Substring(0, capuuid.Length - 1); + +// UUID AvatarID = UUID.Zero; + UUID capUUID = UUID.Zero; + if (UUID.TryParse(capuuid, out capUUID)) + { +/* Don't remove this yet code cleaners! + * Still testing this! + * + lock (m_QueueUUIDAvatarMapping) + { + if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) + { + AvatarID = m_QueueUUIDAvatarMapping[capUUID]; + } + } + + + if (AvatarID != UUID.Zero) + { + // Repair the CAP! + //OpenSim.Framework.Capabilities.Caps caps = m_scene.GetCapsHandlerForUser(AvatarID); + //string capsBase = "/CAPS/EQG/"; + //caps.RegisterHandler("EventQueueGet", + //new RestHTTPHandler("POST", capsBase + capUUID.ToString() + "/", + //delegate(Hashtable m_dhttpMethod) + //{ + // return ProcessQueue(m_dhttpMethod, AvatarID, caps); + //})); + // start new ID sequence. + Random rnd = new Random(System.Environment.TickCount); + lock (m_ids) + { + if (!m_ids.ContainsKey(AvatarID)) + m_ids.Add(AvatarID, rnd.Next(30000000)); + } + + + int thisID = 0; + lock (m_ids) + thisID = m_ids[AvatarID]; + + BlockingLLSDQueue queue = GetQueue(AvatarID); + OSDArray array = new OSDArray(); + LLSD element = queue.Dequeue(15000); // 15s timeout + if (element == null) + { + + array.Add(EventQueueHelper.KeepAliveEvent()); + } + else + { + array.Add(element); + while (queue.Count() > 0) + { + array.Add(queue.Dequeue(1)); + thisID++; + } + } + OSDMap events = new OSDMap(); + events.Add("events", array); + + events.Add("id", new LLSDInteger(thisID)); + + lock (m_ids) + { + m_ids[AvatarID] = thisID + 1; + } + + return events; + } + else + { + return new LLSD(); + } +* +*/ + } + else + { + //return new LLSD(); + } + + return new OSDString("shutdown404!"); + } + + public void DisableSimulator(ulong handle, UUID avatarID) + { + OSD item = EventQueueHelper.DisableSimulator(handle); + Enqueue(item, avatarID); + } + + public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID) + { + OSD item = EventQueueHelper.EnableSimulator(handle, endPoint); + Enqueue(item, avatarID); + } + + public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath) + { + OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath); + Enqueue(item, avatarID); + } + + public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, + IPEndPoint regionExternalEndPoint, + uint locationID, uint flags, string capsURL, + UUID avatarID) + { + OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, + locationID, flags, capsURL, avatarID); + Enqueue(item, avatarID); + } + + public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, + IPEndPoint newRegionExternalEndPoint, + string capsURL, UUID avatarID, UUID sessionID) + { + OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, + capsURL, avatarID, sessionID); + Enqueue(item, avatarID); + } + + public void ChatterboxInvitation(UUID sessionID, string sessionName, + UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, + uint timeStamp, bool offline, int parentEstateID, Vector3 position, + uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket) + { + OSD item = EventQueueHelper.ChatterboxInvitation(sessionID, sessionName, fromAgent, message, toAgent, fromName, dialog, + timeStamp, offline, parentEstateID, position, ttl, transactionID, + fromGroup, binaryBucket); + Enqueue(item, toAgent); + //m_log.InfoFormat("########### eq ChatterboxInvitation #############\n{0}", item); + + } + + public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, + bool isModerator, bool textMute) + { + OSD item = EventQueueHelper.ChatterBoxSessionAgentListUpdates(sessionID, fromAgent, canVoiceChat, + isModerator, textMute); + Enqueue(item, toAgent); + //m_log.InfoFormat("########### eq ChatterBoxSessionAgentListUpdates #############\n{0}", item); + } + + public void ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage, UUID avatarID) + { + OSD item = EventQueueHelper.ParcelProperties(parcelPropertiesMessage); + Enqueue(item, avatarID); + } + + public void GroupMembership(AgentGroupDataUpdatePacket groupUpdate, UUID avatarID) + { + OSD item = EventQueueHelper.GroupMembership(groupUpdate); + Enqueue(item, avatarID); + } + public void QueryReply(PlacesReplyPacket groupUpdate, UUID avatarID) + { + OSD item = EventQueueHelper.PlacesQuery(groupUpdate); + Enqueue(item, avatarID); + } + + public OSD ScriptRunningEvent(UUID objectID, UUID itemID, bool running, bool mono) + { + return EventQueueHelper.ScriptRunningReplyEvent(objectID, itemID, running, mono); + } + + public OSD BuildEvent(string eventName, OSD eventBody) + { + return EventQueueHelper.BuildEvent(eventName, eventBody); + } + } +} diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs new file mode 100644 index 0000000..3f49aba --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -0,0 +1,399 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Net; +using OpenMetaverse; +using OpenMetaverse.Packets; +using OpenMetaverse.StructuredData; +using OpenMetaverse.Messages.Linden; + +namespace OpenSim.Region.ClientStack.Linden +{ + public class EventQueueHelper + { + private EventQueueHelper() {} // no construction possible, it's an utility class + + private static byte[] ulongToByteArray(ulong uLongValue) + { + // Reverse endianness of RegionHandle + return new byte[] + { + (byte)((uLongValue >> 56) % 256), + (byte)((uLongValue >> 48) % 256), + (byte)((uLongValue >> 40) % 256), + (byte)((uLongValue >> 32) % 256), + (byte)((uLongValue >> 24) % 256), + (byte)((uLongValue >> 16) % 256), + (byte)((uLongValue >> 8) % 256), + (byte)(uLongValue % 256) + }; + } + +// private static byte[] uintToByteArray(uint uIntValue) +// { +// byte[] result = new byte[4]; +// Utils.UIntToBytesBig(uIntValue, result, 0); +// return result; +// } + + public static OSD BuildEvent(string eventName, OSD eventBody) + { + OSDMap llsdEvent = new OSDMap(2); + llsdEvent.Add("message", new OSDString(eventName)); + llsdEvent.Add("body", eventBody); + + return llsdEvent; + } + + public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint) + { + OSDMap llsdSimInfo = new OSDMap(3); + + llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); + llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); + llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port)); + + OSDArray arr = new OSDArray(1); + arr.Add(llsdSimInfo); + + OSDMap llsdBody = new OSDMap(1); + llsdBody.Add("SimulatorInfo", arr); + + return BuildEvent("EnableSimulator", llsdBody); + } + + public static OSD DisableSimulator(ulong handle) + { + //OSDMap llsdSimInfo = new OSDMap(1); + + //llsdSimInfo.Add("Handle", new OSDBinary(regionHandleToByteArray(handle))); + + //OSDArray arr = new OSDArray(1); + //arr.Add(llsdSimInfo); + + OSDMap llsdBody = new OSDMap(0); + //llsdBody.Add("SimulatorInfo", arr); + + return BuildEvent("DisableSimulator", llsdBody); + } + + public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, + IPEndPoint newRegionExternalEndPoint, + string capsURL, UUID agentID, UUID sessionID) + { + OSDArray lookAtArr = new OSDArray(3); + lookAtArr.Add(OSD.FromReal(lookAt.X)); + lookAtArr.Add(OSD.FromReal(lookAt.Y)); + lookAtArr.Add(OSD.FromReal(lookAt.Z)); + + OSDArray positionArr = new OSDArray(3); + positionArr.Add(OSD.FromReal(pos.X)); + positionArr.Add(OSD.FromReal(pos.Y)); + positionArr.Add(OSD.FromReal(pos.Z)); + + OSDMap infoMap = new OSDMap(2); + infoMap.Add("LookAt", lookAtArr); + infoMap.Add("Position", positionArr); + + OSDArray infoArr = new OSDArray(1); + infoArr.Add(infoMap); + + OSDMap agentDataMap = new OSDMap(2); + agentDataMap.Add("AgentID", OSD.FromUUID(agentID)); + agentDataMap.Add("SessionID", OSD.FromUUID(sessionID)); + + OSDArray agentDataArr = new OSDArray(1); + agentDataArr.Add(agentDataMap); + + OSDMap regionDataMap = new OSDMap(4); + regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle))); + regionDataMap.Add("SeedCapability", OSD.FromString(capsURL)); + regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); + regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port)); + + OSDArray regionDataArr = new OSDArray(1); + regionDataArr.Add(regionDataMap); + + OSDMap llsdBody = new OSDMap(3); + llsdBody.Add("Info", infoArr); + llsdBody.Add("AgentData", agentDataArr); + llsdBody.Add("RegionData", regionDataArr); + + return BuildEvent("CrossedRegion", llsdBody); + } + + public static OSD TeleportFinishEvent( + ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, + uint locationID, uint flags, string capsURL, UUID agentID) + { + OSDMap info = new OSDMap(); + info.Add("AgentID", OSD.FromUUID(agentID)); + info.Add("LocationID", OSD.FromInteger(4)); // TODO what is this? + info.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(regionHandle))); + info.Add("SeedCapability", OSD.FromString(capsURL)); + info.Add("SimAccess", OSD.FromInteger(simAccess)); + info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); + info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); + info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation + + OSDArray infoArr = new OSDArray(); + infoArr.Add(info); + + OSDMap body = new OSDMap(); + body.Add("Info", infoArr); + + return BuildEvent("TeleportFinish", body); + } + + public static OSD ScriptRunningReplyEvent(UUID objectID, UUID itemID, bool running, bool mono) + { + OSDMap script = new OSDMap(); + script.Add("ObjectID", OSD.FromUUID(objectID)); + script.Add("ItemID", OSD.FromUUID(itemID)); + script.Add("Running", OSD.FromBoolean(running)); + script.Add("Mono", OSD.FromBoolean(mono)); + + OSDArray scriptArr = new OSDArray(); + scriptArr.Add(script); + + OSDMap body = new OSDMap(); + body.Add("Script", scriptArr); + + return BuildEvent("ScriptRunningReply", body); + } + + public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap) + { + OSDMap body = new OSDMap(3); + body.Add("agent-id", new OSDUUID(agentID)); + body.Add("sim-ip-and-port", new OSDString(simIpAndPort)); + body.Add("seed-capability", new OSDString(seedcap)); + + return BuildEvent("EstablishAgentCommunication", body); + } + + public static OSD KeepAliveEvent() + { + return BuildEvent("FAKEEVENT", new OSDMap()); + } + + public static OSD AgentParams(UUID agentID, bool checkEstate, int godLevel, bool limitedToEstate) + { + OSDMap body = new OSDMap(4); + + body.Add("agent_id", new OSDUUID(agentID)); + body.Add("check_estate", new OSDInteger(checkEstate ? 1 : 0)); + body.Add("god_level", new OSDInteger(godLevel)); + body.Add("limited_to_estate", new OSDInteger(limitedToEstate ? 1 : 0)); + + return body; + } + + public static OSD InstantMessageParams(UUID fromAgent, string message, UUID toAgent, + string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID, + Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket) + { + OSDMap messageParams = new OSDMap(15); + messageParams.Add("type", new OSDInteger((int)dialog)); + + OSDArray positionArray = new OSDArray(3); + positionArray.Add(OSD.FromReal(position.X)); + positionArray.Add(OSD.FromReal(position.Y)); + positionArray.Add(OSD.FromReal(position.Z)); + messageParams.Add("position", positionArray); + + messageParams.Add("region_id", new OSDUUID(UUID.Zero)); + messageParams.Add("to_id", new OSDUUID(toAgent)); + messageParams.Add("source", new OSDInteger(0)); + + OSDMap data = new OSDMap(1); + data.Add("binary_bucket", OSD.FromBinary(binaryBucket)); + messageParams.Add("data", data); + messageParams.Add("message", new OSDString(message)); + messageParams.Add("id", new OSDUUID(transactionID)); + messageParams.Add("from_name", new OSDString(fromName)); + messageParams.Add("timestamp", new OSDInteger((int)timeStamp)); + messageParams.Add("offline", new OSDInteger(offline ? 1 : 0)); + messageParams.Add("parent_estate_id", new OSDInteger(parentEstateID)); + messageParams.Add("ttl", new OSDInteger((int)ttl)); + messageParams.Add("from_id", new OSDUUID(fromAgent)); + messageParams.Add("from_group", new OSDInteger(fromGroup ? 1 : 0)); + + return messageParams; + } + + public static OSD InstantMessage(UUID fromAgent, string message, UUID toAgent, + string fromName, byte dialog, uint timeStamp, bool offline, int parentEstateID, + Vector3 position, uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket, + bool checkEstate, int godLevel, bool limitedToEstate) + { + OSDMap im = new OSDMap(2); + im.Add("message_params", InstantMessageParams(fromAgent, message, toAgent, + fromName, dialog, timeStamp, offline, parentEstateID, + position, ttl, transactionID, fromGroup, binaryBucket)); + + im.Add("agent_params", AgentParams(fromAgent, checkEstate, godLevel, limitedToEstate)); + + return im; + } + + + public static OSD ChatterboxInvitation(UUID sessionID, string sessionName, + UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, + uint timeStamp, bool offline, int parentEstateID, Vector3 position, + uint ttl, UUID transactionID, bool fromGroup, byte[] binaryBucket) + { + OSDMap body = new OSDMap(5); + body.Add("session_id", new OSDUUID(sessionID)); + body.Add("from_name", new OSDString(fromName)); + body.Add("session_name", new OSDString(sessionName)); + body.Add("from_id", new OSDUUID(fromAgent)); + + body.Add("instantmessage", InstantMessage(fromAgent, message, toAgent, + fromName, dialog, timeStamp, offline, parentEstateID, position, + ttl, transactionID, fromGroup, binaryBucket, true, 0, true)); + + OSDMap chatterboxInvitation = new OSDMap(2); + chatterboxInvitation.Add("message", new OSDString("ChatterBoxInvitation")); + chatterboxInvitation.Add("body", body); + return chatterboxInvitation; + } + + public static OSD ChatterBoxSessionAgentListUpdates(UUID sessionID, + UUID agentID, bool canVoiceChat, bool isModerator, bool textMute) + { + OSDMap body = new OSDMap(); + OSDMap agentUpdates = new OSDMap(); + OSDMap infoDetail = new OSDMap(); + OSDMap mutes = new OSDMap(); + + mutes.Add("text", OSD.FromBoolean(textMute)); + infoDetail.Add("can_voice_chat", OSD.FromBoolean(canVoiceChat)); + infoDetail.Add("is_moderator", OSD.FromBoolean(isModerator)); + infoDetail.Add("mutes", mutes); + OSDMap info = new OSDMap(); + info.Add("info", infoDetail); + agentUpdates.Add(agentID.ToString(), info); + body.Add("agent_updates", agentUpdates); + body.Add("session_id", OSD.FromUUID(sessionID)); + body.Add("updates", new OSD()); + + OSDMap chatterBoxSessionAgentListUpdates = new OSDMap(); + chatterBoxSessionAgentListUpdates.Add("message", OSD.FromString("ChatterBoxSessionAgentListUpdates")); + chatterBoxSessionAgentListUpdates.Add("body", body); + + return chatterBoxSessionAgentListUpdates; + } + + public static OSD GroupMembership(AgentGroupDataUpdatePacket groupUpdatePacket) + { + OSDMap groupUpdate = new OSDMap(); + groupUpdate.Add("message", OSD.FromString("AgentGroupDataUpdate")); + + OSDMap body = new OSDMap(); + OSDArray agentData = new OSDArray(); + OSDMap agentDataMap = new OSDMap(); + agentDataMap.Add("AgentID", OSD.FromUUID(groupUpdatePacket.AgentData.AgentID)); + agentData.Add(agentDataMap); + body.Add("AgentData", agentData); + + OSDArray groupData = new OSDArray(); + + foreach (AgentGroupDataUpdatePacket.GroupDataBlock groupDataBlock in groupUpdatePacket.GroupData) + { + OSDMap groupDataMap = new OSDMap(); + groupDataMap.Add("ListInProfile", OSD.FromBoolean(false)); + groupDataMap.Add("GroupID", OSD.FromUUID(groupDataBlock.GroupID)); + groupDataMap.Add("GroupInsigniaID", OSD.FromUUID(groupDataBlock.GroupInsigniaID)); + groupDataMap.Add("Contribution", OSD.FromInteger(groupDataBlock.Contribution)); + groupDataMap.Add("GroupPowers", OSD.FromBinary(ulongToByteArray(groupDataBlock.GroupPowers))); + groupDataMap.Add("GroupName", OSD.FromString(Utils.BytesToString(groupDataBlock.GroupName))); + groupDataMap.Add("AcceptNotices", OSD.FromBoolean(groupDataBlock.AcceptNotices)); + + groupData.Add(groupDataMap); + + } + body.Add("GroupData", groupData); + groupUpdate.Add("body", body); + + return groupUpdate; + } + + public static OSD PlacesQuery(PlacesReplyPacket PlacesReply) + { + OSDMap placesReply = new OSDMap(); + placesReply.Add("message", OSD.FromString("PlacesReplyMessage")); + + OSDMap body = new OSDMap(); + OSDArray agentData = new OSDArray(); + OSDMap agentDataMap = new OSDMap(); + agentDataMap.Add("AgentID", OSD.FromUUID(PlacesReply.AgentData.AgentID)); + agentDataMap.Add("QueryID", OSD.FromUUID(PlacesReply.AgentData.QueryID)); + agentDataMap.Add("TransactionID", OSD.FromUUID(PlacesReply.TransactionData.TransactionID)); + agentData.Add(agentDataMap); + body.Add("AgentData", agentData); + + OSDArray QueryData = new OSDArray(); + + foreach (PlacesReplyPacket.QueryDataBlock groupDataBlock in PlacesReply.QueryData) + { + OSDMap QueryDataMap = new OSDMap(); + QueryDataMap.Add("ActualArea", OSD.FromInteger(groupDataBlock.ActualArea)); + QueryDataMap.Add("BillableArea", OSD.FromInteger(groupDataBlock.BillableArea)); + QueryDataMap.Add("Description", OSD.FromBinary(groupDataBlock.Desc)); + QueryDataMap.Add("Dwell", OSD.FromInteger((int)groupDataBlock.Dwell)); + QueryDataMap.Add("Flags", OSD.FromString(Convert.ToString(groupDataBlock.Flags))); + QueryDataMap.Add("GlobalX", OSD.FromInteger((int)groupDataBlock.GlobalX)); + QueryDataMap.Add("GlobalY", OSD.FromInteger((int)groupDataBlock.GlobalY)); + QueryDataMap.Add("GlobalZ", OSD.FromInteger((int)groupDataBlock.GlobalZ)); + QueryDataMap.Add("Name", OSD.FromBinary(groupDataBlock.Name)); + QueryDataMap.Add("OwnerID", OSD.FromUUID(groupDataBlock.OwnerID)); + QueryDataMap.Add("SimName", OSD.FromBinary(groupDataBlock.SimName)); + QueryDataMap.Add("SnapShotID", OSD.FromUUID(groupDataBlock.SnapshotID)); + QueryDataMap.Add("ProductSku", OSD.FromInteger(0)); + QueryDataMap.Add("Price", OSD.FromInteger(groupDataBlock.Price)); + + QueryData.Add(QueryDataMap); + } + body.Add("QueryData", QueryData); + placesReply.Add("QueryData[]", body); + + return placesReply; + } + + public static OSD ParcelProperties(ParcelPropertiesMessage parcelPropertiesMessage) + { + OSDMap message = new OSDMap(); + message.Add("message", OSD.FromString("ParcelProperties")); + OSD message_body = parcelPropertiesMessage.Serialize(); + message.Add("body", message_body); + return message; + } + + } +} -- cgit v1.1 From e3c27d852720ad8b743952ab4aac3b2648468a11 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 30 Apr 2011 13:24:25 -0700 Subject: Nope, that didn't feel right. Moving all those modules to Linden space. --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index fe97bf2..4827baa 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -33,6 +33,7 @@ using System.Reflection; using System.Threading; using log4net; using Nini.Config; +using Mono.Addins; using OpenMetaverse; using OpenMetaverse.Messages.Linden; using OpenMetaverse.Packets; @@ -53,6 +54,7 @@ namespace OpenSim.Region.ClientStack.Linden public OSDMap body; } + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] public class EventQueueGetModule : IEventQueue, IRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From f79400e94ca6f8b609f5d4cbe25c5bbc04b61b77 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 1 May 2011 18:22:53 -0700 Subject: Broke down Caps.cs into a generic Caps object that simply registers/unregisters capabilities and a specific bunch of capability implementations in Linden space called BunchOfCaps. Renamed a few methods that were misnomers. Compiles but doesn't work. --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 4827baa..4920347 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -522,7 +522,7 @@ namespace OpenSim.Region.ClientStack.Linden } if (AvatarID != UUID.Zero) { - return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsHandlerForUser(AvatarID)); + return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); } else { -- cgit v1.1 From 10180760b741edf22cec23db0ec490669407425f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 2 May 2011 08:48:55 -0700 Subject: Works! --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 4920347..4a8bb53 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.ClientStack.Linden public OSDMap body; } - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] public class EventQueueGetModule : IEventQueue, IRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From ac9697edbebd8c4e59191823950dbda08207177b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 2 May 2011 19:45:47 -0700 Subject: Fixed: EventQueueGet and other caps were being wrongly deregistered. Also CapabilitiesModule was being instantiated twice (damn Mono.Addins). --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 4a8bb53..139d8b8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -272,9 +272,9 @@ namespace OpenSim.Region.ClientStack.Linden public void OnRegisterCaps(UUID agentID, Caps caps) { // Register an event queue for the client - + //m_log.DebugFormat( - // "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", + // "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", // agentID, caps, m_scene.RegionInfo.RegionName); // Let's instantiate a Queue for this agent right now @@ -317,7 +317,7 @@ namespace OpenSim.Region.ClientStack.Linden { return ProcessQueue(m_dhttpMethod, agentID, caps); })); - + // This will persist this beyond the expiry of the caps handlers MainServer.Instance.AddPollServiceHTTPHandler( capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); -- cgit v1.1 From 839c1cdcc4e9ce410636becb5b81190463dec5bf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 24 Sep 2011 01:10:23 +0100 Subject: Improve locking when access queue in EventQueueGetModule --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 31 ++++++++++++---------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 139d8b8..8d0c7a1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -179,9 +179,10 @@ namespace OpenSim.Region.ClientStack.Linden { Queue queue = GetQueue(avatarID); if (queue != null) - queue.Enqueue(ev); + lock (queue) + queue.Enqueue(ev); } - catch(NullReferenceException e) + catch (NullReferenceException e) { m_log.Error("[EVENTQUEUE] Caught exception: " + e); return false; @@ -338,12 +339,8 @@ namespace OpenSim.Region.ClientStack.Linden Queue queue = GetQueue(agentID); if (queue != null) lock (queue) - { - if (queue.Count > 0) - return true; - else - return false; - } + return queue.Count > 0; + return false; } @@ -358,8 +355,6 @@ namespace OpenSim.Region.ClientStack.Linden element = queue.Dequeue(); // 15s timeout } - - int thisID = 0; lock (m_ids) thisID = m_ids[pAgentId]; @@ -431,7 +426,10 @@ namespace OpenSim.Region.ClientStack.Linden // } Queue queue = TryGetQueue(agentID); - OSD element = queue.Dequeue(); // 15s timeout + OSD element; + + lock (queue) + element = queue.Dequeue(); // 15s timeout Hashtable responsedata = new Hashtable(); @@ -470,10 +468,14 @@ namespace OpenSim.Region.ClientStack.Linden else { array.Add(element); - while (queue.Count > 0) + + lock (queue) { - array.Add(queue.Dequeue()); - thisID++; + while (queue.Count > 0) + { + array.Add(queue.Dequeue()); + thisID++; + } } } @@ -520,6 +522,7 @@ namespace OpenSim.Region.ClientStack.Linden AvatarID = m_QueueUUIDAvatarMapping[capUUID]; } } + if (AvatarID != UUID.Zero) { return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); -- cgit v1.1 From e28e2d24c714c3fba1cba60097986a1c1c28c6c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 24 Oct 2011 22:23:41 +0100 Subject: Add new EventQueueTests with basic test to check that adding a client registers an http poll --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 1 - .../Caps/EventQueue/Tests/EventQueueTests.cs | 72 ++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 8d0c7a1..3eb2b5e 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -102,7 +102,6 @@ namespace OpenSim.Region.ClientStack.Linden { m_gConfig = null; } - } private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs new file mode 100644 index 0000000..74d91d4 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -0,0 +1,72 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Net; +using log4net.Config; +using Nini.Config; +using NUnit.Framework; +using OpenMetaverse; +using OpenMetaverse.Packets; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.ClientStack.Linden; +using OpenSim.Region.CoreModules.Framework; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; + +namespace OpenSim.Region.ClientStack.Linden.Tests +{ + [TestFixture] + public class EventQueueTests + { + [Test] + public void AddForClient() + { + TestHelpers.InMethod(); + log4net.Config.XmlConfigurator.Configure(); + + MainServer.Instance = new BaseHttpServer(9999, false, 9998, ""); + + IConfigSource config = new IniConfigSource(); + config.AddConfig("Startup"); + config.Configs["Startup"].Set("EventQueue", "true"); + + CapabilitiesModule capsModule = new CapabilitiesModule(); + EventQueueGetModule eqgModule = new EventQueueGetModule(); + + TestScene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, config, capsModule, eqgModule); + + SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); + + // TODO: Add more assertions for the other aspects of event queues + Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(1)); + } + } +} \ No newline at end of file -- cgit v1.1 From 79d5bc9beb445ca07cff9ecbd91d89b2a57e14da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 24 Oct 2011 22:29:13 +0100 Subject: separate out future common setup code from EventQueueTests.AddForClient() --- .../Caps/EventQueue/Tests/EventQueueTests.cs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index 74d91d4..ec8a414 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -45,12 +45,11 @@ namespace OpenSim.Region.ClientStack.Linden.Tests [TestFixture] public class EventQueueTests { - [Test] - public void AddForClient() - { - TestHelpers.InMethod(); - log4net.Config.XmlConfigurator.Configure(); + private TestScene m_scene; + [SetUp] + public void SetUp() + { MainServer.Instance = new BaseHttpServer(9999, false, 9998, ""); IConfigSource config = new IniConfigSource(); @@ -60,10 +59,17 @@ namespace OpenSim.Region.ClientStack.Linden.Tests CapabilitiesModule capsModule = new CapabilitiesModule(); EventQueueGetModule eqgModule = new EventQueueGetModule(); - TestScene scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, config, capsModule, eqgModule); + m_scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); + } + + [Test] + public void AddForClient() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); - SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); + SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); // TODO: Add more assertions for the other aspects of event queues Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(1)); -- cgit v1.1 From 9ec672c70b28b8c1d6d81bab7744fcf7bf9b83c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 24 Oct 2011 23:16:03 +0100 Subject: Fix bugs in EventQueueGetModule.ClientClosed() and BaseHttpServer.RemovePollServerHTTPHandler() that stopped existing code in ClientClosed() from actually tearing down the poll handler Actually doing the tear down appear to have no ill effects with region crossing and teleport. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 11 +++++++---- .../Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 3eb2b5e..7d73b3e 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -204,7 +204,7 @@ namespace OpenSim.Region.ClientStack.Linden private void ClientClosed(UUID AgentID, Scene scene) { - //m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", AgentID, m_scene.RegionInfo.RegionName); +// m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", AgentID, m_scene.RegionInfo.RegionName); int count = 0; while (queues.ContainsKey(AgentID) && queues[AgentID].Count > 0 && count++ < 5) @@ -216,11 +216,13 @@ namespace OpenSim.Region.ClientStack.Linden { queues.Remove(AgentID); } + List removeitems = new List(); lock (m_AvatarQueueUUIDMapping) { foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys) { +// m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID); if (ky == AgentID) { removeitems.Add(ky); @@ -229,11 +231,13 @@ namespace OpenSim.Region.ClientStack.Linden foreach (UUID ky in removeitems) { + UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky]; m_AvatarQueueUUIDMapping.Remove(ky); - MainServer.Instance.RemovePollServiceHTTPHandler("","/CAPS/EQG/" + ky.ToString() + "/"); - } + MainServer.Instance.RemovePollServiceHTTPHandler("","/CAPS/EQG/" + eventQueueGetUuid.ToString() + "/"); + } } + UUID searchval = UUID.Zero; removeitems.Clear(); @@ -252,7 +256,6 @@ namespace OpenSim.Region.ClientStack.Linden foreach (UUID ky in removeitems) m_QueueUUIDAvatarMapping.Remove(ky); - } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index ec8a414..2ca02c5 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -74,5 +74,20 @@ namespace OpenSim.Region.ClientStack.Linden.Tests // TODO: Add more assertions for the other aspects of event queues Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(1)); } + + [Test] + public void RemoveForClient() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID spId = TestHelpers.ParseTail(0x1); + + SceneHelpers.AddScenePresence(m_scene, spId); + m_scene.IncomingCloseAgent(spId); + + // TODO: Add more assertions for the other aspects of event queues + Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); + } } } \ No newline at end of file -- cgit v1.1 From 8a0a78cbccce796addacab7ed1609279b802a9b3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 25 Oct 2011 20:24:21 +0100 Subject: Make OpenSim.Framework.Servers.HttpServer rely on OpenSim.Framework instead of the other way around. This is necessary so that code in HttpServer can use framework facilities such as the thread watchdog for monitoring purposes. Doing this shuffle meant that MainServer was moved into OpenSim/Framework/Servers Also had to make OpenSim.Framework.Console rely on OpenSim.Framework rather than the other way around since it in turn relies on HttpServer MainConsole and some new interfaces had to be moved into OpenSim/Framework to allow this. This can be reverted if parts of OpenSim.Framework stop relying on console presence (cheifly RegionInfo) --- .../Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index 2ca02c5..a5209b7 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -34,6 +34,7 @@ using NUnit.Framework; using OpenMetaverse; using OpenMetaverse.Packets; using OpenSim.Framework; +using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.ClientStack.Linden; using OpenSim.Region.CoreModules.Framework; -- cgit v1.1 From 0174e326e3680ebc76dbd525191ad9b07634ec6d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Nov 2011 20:27:11 +0000 Subject: Add a "debug eq" console command for debugging. This will log outgoing event queue message names if turned on. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 85 ++++++++++++++++++++-- 1 file changed, 79 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 7d73b3e..f5feb71 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -39,6 +39,7 @@ using OpenMetaverse.Messages.Linden; using OpenMetaverse.Packets; using OpenMetaverse.StructuredData; using OpenSim.Framework; +using OpenSim.Framework.Console; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.Framework.Interfaces; @@ -58,9 +59,15 @@ namespace OpenSim.Region.ClientStack.Linden public class EventQueueGetModule : IEventQueue, IRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected Scene m_scene = null; + + /// + /// Debug level. + /// + public int DebugLevel { get; set; } + + protected Scene m_scene; private IConfigSource m_gConfig; - bool enabledYN = false; + bool enabledYN; private Dictionary m_ids = new Dictionary(); @@ -97,6 +104,15 @@ namespace OpenSim.Region.ClientStack.Linden scene.EventManager.OnClientClosed += ClientClosed; scene.EventManager.OnMakeChildAgent += MakeChildAgent; scene.EventManager.OnRegisterCaps += OnRegisterCaps; + + MainConsole.Instance.Commands.AddCommand( + "event queue", + false, + "debug eq", + "debug eq [0|1]", + "debug eq 1 will turn on event queue debugging. This will log all outgoing event queue messages to clients.\n" + + "debug eq 1 will turn off event queue debugging.", + HandleDebugEq); } else { @@ -128,6 +144,22 @@ namespace OpenSim.Region.ClientStack.Linden } #endregion + protected void HandleDebugEq(string module, string[] args) + { + int debugLevel; + + if (!(args.Length == 3 && int.TryParse(args[2], out debugLevel))) + { + MainConsole.Instance.OutputFormat("Usage: debug eq [0|1]"); + } + else + { + DebugLevel = debugLevel; + MainConsole.Instance.OutputFormat( + "Set event queue debug level to {0} in {1}", DebugLevel, m_scene.RegionInfo.RegionName); + } + } + /// /// Always returns a valid queue /// @@ -323,7 +355,9 @@ namespace OpenSim.Region.ClientStack.Linden // This will persist this beyond the expiry of the caps handlers MainServer.Instance.AddPollServiceHTTPHandler( - capsBase + EventQueueGetUUID.ToString() + "/", EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); + capsBase + EventQueueGetUUID.ToString() + "/", + EventQueuePoll, + new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); Random rnd = new Random(Environment.TickCount); lock (m_ids) @@ -370,12 +404,31 @@ namespace OpenSim.Region.ClientStack.Linden } else { + if (DebugLevel > 0 && element is OSDMap) + { + OSDMap ev = (OSDMap)element; + m_log.DebugFormat( + "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", + ev["message"], m_scene.GetScenePresence(pAgentId).Name); + } + array.Add(element); + lock (queue) { while (queue.Count > 0) { - array.Add(queue.Dequeue()); + element = queue.Dequeue(); + + if (DebugLevel > 0 && element is OSDMap) + { + OSDMap ev = (OSDMap)element; + m_log.DebugFormat( + "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", + ev["message"], m_scene.GetScenePresence(pAgentId).Name); + } + + array.Add(element); thisID++; } } @@ -471,11 +524,29 @@ namespace OpenSim.Region.ClientStack.Linden { array.Add(element); + if (element is OSDMap) + { + OSDMap ev = (OSDMap)element; + m_log.DebugFormat( + "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", + ev["message"], m_scene.GetScenePresence(agentID).Name); + } + lock (queue) { while (queue.Count > 0) { - array.Add(queue.Dequeue()); + element = queue.Dequeue(); + + if (element is OSDMap) + { + OSDMap ev = (OSDMap)element; + m_log.DebugFormat( + "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", + ev["message"], m_scene.GetScenePresence(agentID).Name); + } + + array.Add(element); thisID++; } } @@ -494,7 +565,8 @@ namespace OpenSim.Region.ClientStack.Linden responsedata["content_type"] = "application/xml"; responsedata["keepalive"] = false; responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); - //m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); + + m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); return responsedata; } @@ -717,6 +789,7 @@ namespace OpenSim.Region.ClientStack.Linden OSD item = EventQueueHelper.GroupMembership(groupUpdate); Enqueue(item, avatarID); } + public void QueryReply(PlacesReplyPacket groupUpdate, UUID avatarID) { OSD item = EventQueueHelper.PlacesQuery(groupUpdate); -- cgit v1.1 From 63c137820b44e9d1e248ba32ccd6df5110a2bdb9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Nov 2011 21:27:35 +0000 Subject: Stop passing a request handler to the initial caps.RegisterHandler in EventQueueGetModule since this is immediatley replaced by a poll server handler. This allows us to comment out a bunch of code and simplify the codebase and readability. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 319 +++++++++++---------- 1 file changed, 162 insertions(+), 157 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index f5feb71..24f76d69 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -346,12 +346,16 @@ namespace OpenSim.Region.ClientStack.Linden } // Register this as a caps handler + // FIXME: Confusingly, we need to register separate as a capability so that the client is told about + // EventQueueGet when it receive capability information, but then we replace the rest handler immediately + // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but + // really it should be possible to directly register the poll handler as a capability. caps.RegisterHandler("EventQueueGet", - new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/", - delegate(Hashtable m_dhttpMethod) - { - return ProcessQueue(m_dhttpMethod, agentID, caps); - })); + new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/", null)); +// delegate(Hashtable m_dhttpMethod) +// { +// return ProcessQueue(m_dhttpMethod, agentID, caps); +// })); // This will persist this beyond the expiry of the caps handlers MainServer.Instance.AddPollServiceHTTPHandler( @@ -382,6 +386,8 @@ namespace OpenSim.Region.ClientStack.Linden public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) { + m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId); + Queue queue = TryGetQueue(pAgentId); OSD element; lock (queue) @@ -465,167 +471,166 @@ namespace OpenSim.Region.ClientStack.Linden return responsedata; } - public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps) - { - // TODO: this has to be redone to not busy-wait (and block the thread), - // TODO: as soon as we have a non-blocking way to handle HTTP-requests. - -// if (m_log.IsDebugEnabled) -// { -// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ "; -// foreach (object key in request.Keys) +// public Hashtable ProcessQueue(Hashtable request, UUID agentID, Caps caps) +// { +// // TODO: this has to be redone to not busy-wait (and block the thread), +// // TODO: as soon as we have a non-blocking way to handle HTTP-requests. +// +//// if (m_log.IsDebugEnabled) +//// { +//// String debug = "[EVENTQUEUE]: Got request for agent {0} in region {1} from thread {2}: [ "; +//// foreach (object key in request.Keys) +//// { +//// debug += key.ToString() + "=" + request[key].ToString() + " "; +//// } +//// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name); +//// } +// +// Queue queue = TryGetQueue(agentID); +// OSD element; +// +// lock (queue) +// element = queue.Dequeue(); // 15s timeout +// +// Hashtable responsedata = new Hashtable(); +// +// int thisID = 0; +// lock (m_ids) +// thisID = m_ids[agentID]; +// +// if (element == null) +// { +// //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName); +// if (thisID == -1) // close-request // { -// debug += key.ToString() + "=" + request[key].ToString() + " "; +// m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName); +// responsedata["int_response_code"] = 404; //501; //410; //404; +// responsedata["content_type"] = "text/plain"; +// responsedata["keepalive"] = false; +// responsedata["str_response_string"] = "Closed EQG"; +// return responsedata; // } -// m_log.DebugFormat(debug + " ]", agentID, m_scene.RegionInfo.RegionName, System.Threading.Thread.CurrentThread.Name); +// responsedata["int_response_code"] = 502; +// responsedata["content_type"] = "text/plain"; +// responsedata["keepalive"] = false; +// responsedata["str_response_string"] = "Upstream error: "; +// responsedata["error_status_text"] = "Upstream error:"; +// responsedata["http_protocol_version"] = "HTTP/1.0"; +// return responsedata; // } - - Queue queue = TryGetQueue(agentID); - OSD element; - - lock (queue) - element = queue.Dequeue(); // 15s timeout - - Hashtable responsedata = new Hashtable(); - - int thisID = 0; - lock (m_ids) - thisID = m_ids[agentID]; - - if (element == null) - { - //m_log.ErrorFormat("[EVENTQUEUE]: Nothing to process in " + m_scene.RegionInfo.RegionName); - if (thisID == -1) // close-request - { - m_log.ErrorFormat("[EVENTQUEUE]: 404 in " + m_scene.RegionInfo.RegionName); - responsedata["int_response_code"] = 404; //501; //410; //404; - responsedata["content_type"] = "text/plain"; - responsedata["keepalive"] = false; - responsedata["str_response_string"] = "Closed EQG"; - return responsedata; - } - responsedata["int_response_code"] = 502; - responsedata["content_type"] = "text/plain"; - responsedata["keepalive"] = false; - responsedata["str_response_string"] = "Upstream error: "; - responsedata["error_status_text"] = "Upstream error:"; - responsedata["http_protocol_version"] = "HTTP/1.0"; - return responsedata; - } - - 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}", agentID, m_scene.RegionInfo.RegionName); - } - else - { - array.Add(element); - - if (element is OSDMap) - { - OSDMap ev = (OSDMap)element; - m_log.DebugFormat( - "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", - ev["message"], m_scene.GetScenePresence(agentID).Name); - } - - lock (queue) - { - while (queue.Count > 0) - { - element = queue.Dequeue(); - - if (element is OSDMap) - { - OSDMap ev = (OSDMap)element; - m_log.DebugFormat( - "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", - ev["message"], m_scene.GetScenePresence(agentID).Name); - } - - array.Add(element); - thisID++; - } - } - } - - OSDMap events = new OSDMap(); - events.Add("events", array); - - events.Add("id", new OSDInteger(thisID)); - lock (m_ids) - { - m_ids[agentID] = thisID + 1; - } - - responsedata["int_response_code"] = 200; - responsedata["content_type"] = "application/xml"; - responsedata["keepalive"] = false; - responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); - - m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); - - return responsedata; - } +// +// 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}", agentID, m_scene.RegionInfo.RegionName); +// } +// else +// { +// array.Add(element); +// +// if (element is OSDMap) +// { +// OSDMap ev = (OSDMap)element; +// m_log.DebugFormat( +// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", +// ev["message"], m_scene.GetScenePresence(agentID).Name); +// } +// +// lock (queue) +// { +// while (queue.Count > 0) +// { +// element = queue.Dequeue(); +// +// if (element is OSDMap) +// { +// OSDMap ev = (OSDMap)element; +// m_log.DebugFormat( +// "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", +// ev["message"], m_scene.GetScenePresence(agentID).Name); +// } +// +// array.Add(element); +// thisID++; +// } +// } +// } +// +// OSDMap events = new OSDMap(); +// events.Add("events", array); +// +// events.Add("id", new OSDInteger(thisID)); +// lock (m_ids) +// { +// m_ids[agentID] = thisID + 1; +// } +// +// responsedata["int_response_code"] = 200; +// responsedata["content_type"] = "application/xml"; +// responsedata["keepalive"] = false; +// responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(events); +// +// m_log.DebugFormat("[EVENTQUEUE]: sending response for {0} in region {1}: {2}", agentID, m_scene.RegionInfo.RegionName, responsedata["str_response_string"]); +// +// return responsedata; +// } public Hashtable EventQueuePoll(Hashtable request) { return new Hashtable(); } - public Hashtable EventQueuePath2(Hashtable request) - { - string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); - // pull off the last "/" in the path. - Hashtable responsedata = new Hashtable(); - capuuid = capuuid.Substring(0, capuuid.Length - 1); - capuuid = capuuid.Replace("/CAPS/EQG/", ""); - UUID AvatarID = UUID.Zero; - UUID capUUID = UUID.Zero; - - // parse the path and search for the avatar with it registered - if (UUID.TryParse(capuuid, out capUUID)) - { - lock (m_QueueUUIDAvatarMapping) - { - if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) - { - AvatarID = m_QueueUUIDAvatarMapping[capUUID]; - } - } - - if (AvatarID != UUID.Zero) - { - return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); - } - else - { - responsedata["int_response_code"] = 404; - responsedata["content_type"] = "text/plain"; - responsedata["keepalive"] = false; - responsedata["str_response_string"] = "Not Found"; - responsedata["error_status_text"] = "Not Found"; - responsedata["http_protocol_version"] = "HTTP/1.0"; - return responsedata; - // return 404 - } - } - else - { - responsedata["int_response_code"] = 404; - responsedata["content_type"] = "text/plain"; - responsedata["keepalive"] = false; - responsedata["str_response_string"] = "Not Found"; - responsedata["error_status_text"] = "Not Found"; - responsedata["http_protocol_version"] = "HTTP/1.0"; - return responsedata; - // return 404 - } - - } +// public Hashtable EventQueuePath2(Hashtable request) +// { +// string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); +// // pull off the last "/" in the path. +// Hashtable responsedata = new Hashtable(); +// capuuid = capuuid.Substring(0, capuuid.Length - 1); +// capuuid = capuuid.Replace("/CAPS/EQG/", ""); +// UUID AvatarID = UUID.Zero; +// UUID capUUID = UUID.Zero; +// +// // parse the path and search for the avatar with it registered +// if (UUID.TryParse(capuuid, out capUUID)) +// { +// lock (m_QueueUUIDAvatarMapping) +// { +// if (m_QueueUUIDAvatarMapping.ContainsKey(capUUID)) +// { +// AvatarID = m_QueueUUIDAvatarMapping[capUUID]; +// } +// } +// +// if (AvatarID != UUID.Zero) +// { +// return ProcessQueue(request, AvatarID, m_scene.CapsModule.GetCapsForUser(AvatarID)); +// } +// else +// { +// responsedata["int_response_code"] = 404; +// responsedata["content_type"] = "text/plain"; +// responsedata["keepalive"] = false; +// responsedata["str_response_string"] = "Not Found"; +// responsedata["error_status_text"] = "Not Found"; +// responsedata["http_protocol_version"] = "HTTP/1.0"; +// return responsedata; +// // return 404 +// } +// } +// else +// { +// responsedata["int_response_code"] = 404; +// responsedata["content_type"] = "text/plain"; +// responsedata["keepalive"] = false; +// responsedata["str_response_string"] = "Not Found"; +// responsedata["error_status_text"] = "Not Found"; +// responsedata["http_protocol_version"] = "HTTP/1.0"; +// return responsedata; +// // return 404 +// } +// } public OSD EventQueueFallBack(string path, OSD request, string endpoint) { -- cgit v1.1 From 0a60e9537f2a1aa30fd1d9c23ada5bf1fcfed889 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Nov 2011 21:30:40 +0000 Subject: comment out a noisy log line I accidentally left in from the last commit --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 24f76d69..5c721d4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -386,7 +386,7 @@ namespace OpenSim.Region.ClientStack.Linden public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) { - m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId); +// m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId); Queue queue = TryGetQueue(pAgentId); OSD element; -- cgit v1.1 From ff0d020007d1747dbaaca077fd3a930f2ecd1767 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 29 Nov 2011 16:18:14 +0000 Subject: Correct mistake in "debug eq" help --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 5c721d4..0b76647 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -111,7 +111,7 @@ namespace OpenSim.Region.ClientStack.Linden "debug eq", "debug eq [0|1]", "debug eq 1 will turn on event queue debugging. This will log all outgoing event queue messages to clients.\n" - + "debug eq 1 will turn off event queue debugging.", + + "debug eq 0 will turn off event queue debugging.", HandleDebugEq); } else -- cgit v1.1 From 658d02b5e913bfa21b496515943f90ab25b6dac5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 29 Nov 2011 16:56:31 +0000 Subject: Improve some of the debug help messages --- OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 0b76647..9f27abc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -110,6 +110,7 @@ namespace OpenSim.Region.ClientStack.Linden false, "debug eq", "debug eq [0|1]", + "Turn on event queue debugging", "debug eq 1 will turn on event queue debugging. This will log all outgoing event queue messages to clients.\n" + "debug eq 0 will turn off event queue debugging.", HandleDebugEq); -- cgit v1.1 From e6272b8d56dd7856faf374e7ac29460b4e74f1bb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 7 Dec 2011 12:28:42 +0000 Subject: Stop also adding an ordinary http handler when we set up a poll http handler. It appears that this is entirely unnecessary since the poll http handlers are dealt with on a separate code path. --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 6 ------ 1 file changed, 6 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 9f27abc..8ba6f61 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -361,7 +361,6 @@ namespace OpenSim.Region.ClientStack.Linden // This will persist this beyond the expiry of the caps handlers MainServer.Instance.AddPollServiceHTTPHandler( capsBase + EventQueueGetUUID.ToString() + "/", - EventQueuePoll, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); Random rnd = new Random(Environment.TickCount); @@ -578,11 +577,6 @@ namespace OpenSim.Region.ClientStack.Linden // return responsedata; // } - public Hashtable EventQueuePoll(Hashtable request) - { - return new Hashtable(); - } - // public Hashtable EventQueuePath2(Hashtable request) // { // string capuuid = (string)request["uri"]; //path.Replace("/CAPS/EQG/",""); -- cgit v1.1 From 749c3fef8ad2d3af97fcd9ab9c72740675e46715 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Mar 2012 01:51:37 +0000 Subject: Change "help" to display categories/module list then "help " to display commands in a category. This is to deal with the hundred lines of command splurge when one previously typed "help" Modelled somewhat on the mysql console One can still type help to get per command help at any point. Categories capitalized to avoid conflict with the all-lowercase commands (except for commander system, as of yet). Does not affect command parsing or any other aspects of the console apart from the help system. Backwards compatible with existing modules. --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 8ba6f61..7c07c56 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -106,7 +106,7 @@ namespace OpenSim.Region.ClientStack.Linden scene.EventManager.OnRegisterCaps += OnRegisterCaps; MainConsole.Instance.Commands.AddCommand( - "event queue", + "Comms", false, "debug eq", "debug eq [0|1]", -- cgit v1.1 From 07e62df5582e28675275b3f5143ec37e5697d283 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 27 Apr 2012 00:58:54 +0100 Subject: Add regression test for teleporting an agent between separated regions on the same simulator. This involves a large amount of change in test scene setup code to allow test scenes to share shared modules SetupScene is now an instance method that requires an instantiation of SceneHelpers, though other SceneHelpers methods are still static May split these out into separate classes in the future. --- .../Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index a5209b7..c25b58c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -60,7 +60,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests CapabilitiesModule capsModule = new CapabilitiesModule(); EventQueueGetModule eqgModule = new EventQueueGetModule(); - m_scene = SceneHelpers.SetupScene(); + m_scene = new SceneHelpers().SetupScene(); SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); } -- cgit v1.1 From 231a3bf147315a9284140476d2b09e13c3fee1c0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 3 May 2012 01:45:49 +0100 Subject: Implement optional name and description on http stream handlers so that we can relate a slow request to what the handler actually does and the agent it serves, if applicable. This is most useful for capabilities where the url is not self-describing. --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 7c07c56..1a35d22 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -351,14 +351,18 @@ namespace OpenSim.Region.ClientStack.Linden // EventQueueGet when it receive capability information, but then we replace the rest handler immediately // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but // really it should be possible to directly register the poll handler as a capability. - caps.RegisterHandler("EventQueueGet", - new RestHTTPHandler("POST", capsBase + EventQueueGetUUID.ToString() + "/", null)); + caps.RegisterHandler( + "EventQueueGet", + new RestHTTPHandler( + "POST", capsBase + EventQueueGetUUID.ToString() + "/", null)); + // delegate(Hashtable m_dhttpMethod) // { // return ProcessQueue(m_dhttpMethod, agentID, caps); // })); // This will persist this beyond the expiry of the caps handlers + // TODO: Add EventQueueGet name/description for diagnostics MainServer.Instance.AddPollServiceHTTPHandler( capsBase + EventQueueGetUUID.ToString() + "/", new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); -- cgit v1.1 From 6501b1b1bb297eb5ed8a44447f771c7b73b0e905 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 18 May 2012 00:38:29 +0100 Subject: refactor: move EventQueueGet path generation into common method. Rename some local variables in line with code conventions. Add commented out EQG log lines for future use. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 53 ++++++++++++++-------- 1 file changed, 33 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 1a35d22..0054619 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -235,19 +235,19 @@ namespace OpenSim.Region.ClientStack.Linden // ClientClosed(client.AgentId); // } - private void ClientClosed(UUID AgentID, Scene scene) + private void ClientClosed(UUID agentID, Scene scene) { -// m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", AgentID, m_scene.RegionInfo.RegionName); +// m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); int count = 0; - while (queues.ContainsKey(AgentID) && queues[AgentID].Count > 0 && count++ < 5) + while (queues.ContainsKey(agentID) && queues[agentID].Count > 0 && count++ < 5) { Thread.Sleep(1000); } lock (queues) { - queues.Remove(AgentID); + queues.Remove(agentID); } List removeitems = new List(); @@ -256,7 +256,7 @@ namespace OpenSim.Region.ClientStack.Linden foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys) { // m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID); - if (ky == AgentID) + if (ky == agentID) { removeitems.Add(ky); } @@ -267,7 +267,10 @@ namespace OpenSim.Region.ClientStack.Linden UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky]; m_AvatarQueueUUIDMapping.Remove(ky); - MainServer.Instance.RemovePollServiceHTTPHandler("","/CAPS/EQG/" + eventQueueGetUuid.ToString() + "/"); + string eqgPath = GenerateEqgCapPath(eventQueueGetUuid); + MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath); + +// m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1}", eqgPath, agentID); } } @@ -281,7 +284,7 @@ namespace OpenSim.Region.ClientStack.Linden { searchval = m_QueueUUIDAvatarMapping[ky]; - if (searchval == AgentID) + if (searchval == agentID) { removeitems.Add(ky); } @@ -305,6 +308,15 @@ namespace OpenSim.Region.ClientStack.Linden //} } + /// + /// Generate an Event Queue Get handler path for the given eqg uuid. + /// + /// + private string GenerateEqgCapPath(UUID eqgUuid) + { + return string.Format("/CAPS/EQG/{0}/", eqgUuid); + } + public void OnRegisterCaps(UUID agentID, Caps caps) { // Register an event queue for the client @@ -316,8 +328,7 @@ namespace OpenSim.Region.ClientStack.Linden // Let's instantiate a Queue for this agent right now TryGetQueue(agentID); - string capsBase = "/CAPS/EQG/"; - UUID EventQueueGetUUID = UUID.Zero; + UUID eventQueueGetUUID; lock (m_AvatarQueueUUIDMapping) { @@ -325,37 +336,35 @@ namespace OpenSim.Region.ClientStack.Linden if (m_AvatarQueueUUIDMapping.ContainsKey(agentID)) { //m_log.DebugFormat("[EVENTQUEUE]: Found Existing UUID!"); - EventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; + eventQueueGetUUID = m_AvatarQueueUUIDMapping[agentID]; } else { - EventQueueGetUUID = UUID.Random(); + eventQueueGetUUID = UUID.Random(); //m_log.DebugFormat("[EVENTQUEUE]: Using random UUID!"); } } lock (m_QueueUUIDAvatarMapping) { - if (!m_QueueUUIDAvatarMapping.ContainsKey(EventQueueGetUUID)) - m_QueueUUIDAvatarMapping.Add(EventQueueGetUUID, agentID); + if (!m_QueueUUIDAvatarMapping.ContainsKey(eventQueueGetUUID)) + m_QueueUUIDAvatarMapping.Add(eventQueueGetUUID, agentID); } lock (m_AvatarQueueUUIDMapping) { if (!m_AvatarQueueUUIDMapping.ContainsKey(agentID)) - m_AvatarQueueUUIDMapping.Add(agentID, EventQueueGetUUID); + m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); } + string eventQueueGetPath = GenerateEqgCapPath(eventQueueGetUUID); + // Register this as a caps handler // FIXME: Confusingly, we need to register separate as a capability so that the client is told about // EventQueueGet when it receive capability information, but then we replace the rest handler immediately // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but // really it should be possible to directly register the poll handler as a capability. - caps.RegisterHandler( - "EventQueueGet", - new RestHTTPHandler( - "POST", capsBase + EventQueueGetUUID.ToString() + "/", null)); - + caps.RegisterHandler("EventQueueGet", new RestHTTPHandler("POST", eventQueueGetPath, null)); // delegate(Hashtable m_dhttpMethod) // { // return ProcessQueue(m_dhttpMethod, agentID, caps); @@ -364,9 +373,13 @@ namespace OpenSim.Region.ClientStack.Linden // This will persist this beyond the expiry of the caps handlers // TODO: Add EventQueueGet name/description for diagnostics MainServer.Instance.AddPollServiceHTTPHandler( - capsBase + EventQueueGetUUID.ToString() + "/", + eventQueueGetPath, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); +// m_log.DebugFormat( +// "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", +// eventQueueGetPath, agentID, m_scene.RegionInfo.RegionName); + Random rnd = new Random(Environment.TickCount); lock (m_ids) { -- cgit v1.1 From 45af29291acd22700d9fc4c442655d2e3f19a0b0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 18 May 2012 03:43:36 +0100 Subject: Add level 2 debug eq logging which logs event queue polls. Refactor: eq message logging into common method. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 55 +++++++++++++--------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 0054619..6ac19cc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -109,10 +109,11 @@ namespace OpenSim.Region.ClientStack.Linden "Comms", false, "debug eq", - "debug eq [0|1]", - "Turn on event queue debugging", - "debug eq 1 will turn on event queue debugging. This will log all outgoing event queue messages to clients.\n" - + "debug eq 0 will turn off event queue debugging.", + "debug eq [0|1|2]", + "Turn on event queue debugging", + "<= 0 - turns off all event queue logging", + ">= 1 - turns on outgoing event logging", + ">= 2 - turns on poll notification", HandleDebugEq); } else @@ -270,7 +271,9 @@ namespace OpenSim.Region.ClientStack.Linden string eqgPath = GenerateEqgCapPath(eventQueueGetUuid); MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath); -// m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1}", eqgPath, agentID); + m_log.DebugFormat( + "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}", + eqgPath, agentID, m_scene.RegionInfo.RegionName); } } @@ -376,9 +379,9 @@ namespace OpenSim.Region.ClientStack.Linden eventQueueGetPath, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); -// m_log.DebugFormat( -// "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", -// eventQueueGetPath, agentID, m_scene.RegionInfo.RegionName); + m_log.DebugFormat( + "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", + eventQueueGetPath, agentID, m_scene.RegionInfo.RegionName); Random rnd = new Random(Environment.TickCount); lock (m_ids) @@ -401,9 +404,25 @@ namespace OpenSim.Region.ClientStack.Linden return false; } + /// + /// Logs a debug line for an outbound event queue message if appropriate. + /// + /// Element containing message + private void LogOutboundDebugMessage(OSD element, UUID agentId) + { + if (element is OSDMap) + { + OSDMap ev = (OSDMap)element; + m_log.DebugFormat( + "Eq OUT {0,-30} to {1,-20} {2,-20}", + ev["message"], m_scene.GetScenePresence(agentId).Name, m_scene.RegionInfo.RegionName); + } + } + public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) { -// m_log.DebugFormat("[EVENT QUEUE GET MODULE]: Invoked GetEvents() for {0}", pAgentId); + if (DebugLevel >= 2) + m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); Queue queue = TryGetQueue(pAgentId); OSD element; @@ -427,13 +446,8 @@ namespace OpenSim.Region.ClientStack.Linden } else { - if (DebugLevel > 0 && element is OSDMap) - { - OSDMap ev = (OSDMap)element; - m_log.DebugFormat( - "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", - ev["message"], m_scene.GetScenePresence(pAgentId).Name); - } + if (DebugLevel > 0) + LogOutboundDebugMessage(element, pAgentId); array.Add(element); @@ -443,13 +457,8 @@ namespace OpenSim.Region.ClientStack.Linden { element = queue.Dequeue(); - if (DebugLevel > 0 && element is OSDMap) - { - OSDMap ev = (OSDMap)element; - m_log.DebugFormat( - "[EVENT QUEUE GET MODULE]: Eq OUT {0} to {1}", - ev["message"], m_scene.GetScenePresence(pAgentId).Name); - } + if (DebugLevel > 0) + LogOutboundDebugMessage(element, pAgentId); array.Add(element); thisID++; -- cgit v1.1 From 0147dc63028e2d77a568c6d9d5af1c9f05286f62 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 18 May 2012 03:50:23 +0100 Subject: Fix build break. Comment out EQG deregister/register logging. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 6ac19cc..ae759ca 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -110,10 +110,10 @@ namespace OpenSim.Region.ClientStack.Linden false, "debug eq", "debug eq [0|1|2]", - "Turn on event queue debugging", - "<= 0 - turns off all event queue logging", - ">= 1 - turns on outgoing event logging", - ">= 2 - turns on poll notification", + "Turn on event queue debugging" + + "<= 0 - turns off all event queue logging" + + ">= 1 - turns on outgoing event logging" + + ">= 2 - turns on poll notification", HandleDebugEq); } else @@ -271,9 +271,9 @@ namespace OpenSim.Region.ClientStack.Linden string eqgPath = GenerateEqgCapPath(eventQueueGetUuid); MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath); - m_log.DebugFormat( - "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}", - eqgPath, agentID, m_scene.RegionInfo.RegionName); +// m_log.DebugFormat( +// "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}", +// eqgPath, agentID, m_scene.RegionInfo.RegionName); } } @@ -379,9 +379,9 @@ namespace OpenSim.Region.ClientStack.Linden eventQueueGetPath, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); - m_log.DebugFormat( - "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", - eventQueueGetPath, agentID, m_scene.RegionInfo.RegionName); +// m_log.DebugFormat( +// "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", +// eventQueueGetPath, agentID, m_scene.RegionInfo.RegionName); Random rnd = new Random(Environment.TickCount); lock (m_ids) -- cgit v1.1 From 257b1b517dec58bf902bac63bc7ab7080286d415 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Jun 2012 02:03:50 +0100 Subject: Add main instance to internal MainServer.m_Servers list to simplify internal logic. This does require the server to be added before it is set as the main Instance --- .../Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index c25b58c..cd70410 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -51,7 +51,16 @@ namespace OpenSim.Region.ClientStack.Linden.Tests [SetUp] public void SetUp() { - MainServer.Instance = new BaseHttpServer(9999, false, 9998, ""); + uint port = 9999; + uint sslPort = 9998; + + // This is an unfortunate bit of clean up we have to do because MainServer manages things through static + // variables and the VM is not restarted between tests. + MainServer.RemoveHttpServer(port); + + BaseHttpServer server = new BaseHttpServer(port, false, sslPort, ""); + MainServer.AddHttpServer(server); + MainServer.Instance = server; IConfigSource config = new IniConfigSource(); config.AddConfig("Startup"); -- cgit v1.1 From c935f0346750d510e5c3c3c2ff62c84609a115e3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 15 Jun 2012 03:32:43 +0100 Subject: Put all debug console commands into a single Debug section rather than scattering them over other categories --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index ae759ca..594b229 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -106,7 +106,7 @@ namespace OpenSim.Region.ClientStack.Linden scene.EventManager.OnRegisterCaps += OnRegisterCaps; MainConsole.Instance.Commands.AddCommand( - "Comms", + "Debug", false, "debug eq", "debug eq [0|1|2]", -- cgit v1.1 From bcbd450fe441e94d6c0f547055b4e95f75a5b0d0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 20 Aug 2012 20:24:54 +0100 Subject: Add --force flag to "kick user" console command to allow bypassing of recent race condition checks. This is to allow a second attempt to remove an avatar even if "show connections" shows them as already inactive (i.e. close has already been attempted once). You should only attempt --force if a normal kick fails. This is partly for diagnostics as we have seen some connections occasionally remain on lbsa plaza even if they are registered as inactive. This is not a permanent solution and may not work anyway - the ultimate solution is to stop this problem from happening in the first place. --- .../Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index cd70410..d604cf6 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests UUID spId = TestHelpers.ParseTail(0x1); SceneHelpers.AddScenePresence(m_scene, spId); - m_scene.IncomingCloseAgent(spId); + m_scene.IncomingCloseAgent(spId, false); // TODO: Add more assertions for the other aspects of event queues Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); -- cgit v1.1 From e76b01a201a9b2d45b56cd5dc2a207b08b4529e5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Oct 2012 00:26:43 +0100 Subject: Lock on AgentCircuitData during Scene.AddClient() and RemoveClient() to prevent an inactive connection being left behind if the user closes the viewer whilst the connection is being established. This should remove the need to run the console command "kick user --force" when these connections are left around. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 594b229..0dd0904 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -94,7 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden //scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack); - scene.EventManager.OnNewClient += OnNewClient; +// scene.EventManager.OnNewClient += OnNewClient; // TODO: Leaving these open, or closing them when we // become a child is incorrect. It messes up TP in a big @@ -102,6 +102,7 @@ namespace OpenSim.Region.ClientStack.Linden // circuit is there. scene.EventManager.OnClientClosed += ClientClosed; + scene.EventManager.OnMakeChildAgent += MakeChildAgent; scene.EventManager.OnRegisterCaps += OnRegisterCaps; @@ -226,16 +227,6 @@ namespace OpenSim.Region.ClientStack.Linden #endregion - private void OnNewClient(IClientAPI client) - { - //client.OnLogout += ClientClosed; - } - -// private void ClientClosed(IClientAPI client) -// { -// ClientClosed(client.AgentId); -// } - private void ClientClosed(UUID agentID, Scene scene) { // m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); -- cgit v1.1 From 0eb457442d87315810fd8280458ca8c0c3e97d23 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Oct 2012 01:31:38 +0100 Subject: minor: Add missing newlines and spacing to help for "debug eq" console command --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 0dd0904..47cb049 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -111,10 +111,10 @@ namespace OpenSim.Region.ClientStack.Linden false, "debug eq", "debug eq [0|1|2]", - "Turn on event queue debugging" - + "<= 0 - turns off all event queue logging" - + ">= 1 - turns on outgoing event logging" - + ">= 2 - turns on poll notification", + "Turn on event queue debugging\n" + + " <= 0 - turns off all event queue logging\n" + + " >= 1 - turns on outgoing event logging\n" + + " >= 2 - turns on poll notification", HandleDebugEq); } else -- cgit v1.1 From 4ac857f9025a8308b0e14adbddffd89b467caf17 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 10 Nov 2012 08:48:31 -0800 Subject: One more module: EventQueueGetModule. Also making it non-optional for this dll. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 91 +++++++++------------- 1 file changed, 38 insertions(+), 53 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 47cb049..b96b1db 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -55,8 +55,8 @@ namespace OpenSim.Region.ClientStack.Linden public OSDMap body; } - //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class EventQueueGetModule : IEventQueue, IRegionModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class EventQueueGetModule : IEventQueue, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -66,8 +66,6 @@ namespace OpenSim.Region.ClientStack.Linden public int DebugLevel { get; set; } protected Scene m_scene; - private IConfigSource m_gConfig; - bool enabledYN; private Dictionary m_ids = new Dictionary(); @@ -75,60 +73,46 @@ namespace OpenSim.Region.ClientStack.Linden private Dictionary m_QueueUUIDAvatarMapping = new Dictionary(); private Dictionary m_AvatarQueueUUIDMapping = new Dictionary(); - #region IRegionModule methods - public virtual void Initialise(Scene scene, IConfigSource config) + #region INonSharedRegionModule methods + public virtual void Initialise(IConfigSource config) { - m_gConfig = config; - - IConfig startupConfig = m_gConfig.Configs["Startup"]; - - ReadConfigAndPopulate(scene, startupConfig, "Startup"); - - if (enabledYN) - { - m_scene = scene; - scene.RegisterModuleInterface(this); - - // Register fallback handler - // Why does EQG Fail on region crossings! - - //scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack); - -// scene.EventManager.OnNewClient += OnNewClient; - - // TODO: Leaving these open, or closing them when we - // become a child is incorrect. It messes up TP in a big - // way. CAPS/EQ need to be active as long as the UDP - // circuit is there. + } - scene.EventManager.OnClientClosed += ClientClosed; - - scene.EventManager.OnMakeChildAgent += MakeChildAgent; - scene.EventManager.OnRegisterCaps += OnRegisterCaps; - - MainConsole.Instance.Commands.AddCommand( - "Debug", - false, - "debug eq", - "debug eq [0|1|2]", - "Turn on event queue debugging\n" - + " <= 0 - turns off all event queue logging\n" - + " >= 1 - turns on outgoing event logging\n" - + " >= 2 - turns on poll notification", - HandleDebugEq); - } - else - { - m_gConfig = null; - } + public void AddRegion(Scene scene) + { + m_scene = scene; + scene.RegisterModuleInterface(this); + + scene.EventManager.OnClientClosed += ClientClosed; + scene.EventManager.OnMakeChildAgent += MakeChildAgent; + scene.EventManager.OnRegisterCaps += OnRegisterCaps; + + MainConsole.Instance.Commands.AddCommand( + "Debug", + false, + "debug eq", + "debug eq [0|1|2]", + "Turn on event queue debugging\n" + + " <= 0 - turns off all event queue logging\n" + + " >= 1 - turns on outgoing event logging\n" + + " >= 2 - turns on poll notification", + HandleDebugEq); } - private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p) + public void RemoveRegion(Scene scene) { - enabledYN = startupConfig.GetBoolean("EventQueue", true); + if (m_scene != scene) + return; + + scene.EventManager.OnClientClosed -= ClientClosed; + scene.EventManager.OnMakeChildAgent -= MakeChildAgent; + scene.EventManager.OnRegisterCaps -= OnRegisterCaps; + + scene.UnregisterModuleInterface(this); + m_scene = null; } - public void PostInitialise() + public void RegionLoaded(Scene scene) { } @@ -141,10 +125,11 @@ namespace OpenSim.Region.ClientStack.Linden get { return "EventQueueGetModule"; } } - public bool IsSharedModule + public Type ReplaceableInterface { - get { return false; } + get { return null; } } + #endregion protected void HandleDebugEq(string module, string[] args) -- cgit v1.1 From 86903f23dd9c0e671fcc9854c031bcc0c6d6cc7f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 12 Nov 2012 18:08:02 -0800 Subject: Cleanup on region modules: gave short node id's to all of them. --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index b96b1db..4d2c0f2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.Linden public OSDMap body; } - [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EventQueueGetModule")] public class EventQueueGetModule : IEventQueue, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); -- cgit v1.1 From 22d4c52ffc374e167cb674e0e20815615d8a6927 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 24 Nov 2012 03:15:24 +0000 Subject: Consistenly make NUnit test cases inherit from OpenSimTestCase which automatically turns off any logging enabled between tests --- .../Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index d604cf6..ed8ec16 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -44,7 +44,7 @@ using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.ClientStack.Linden.Tests { [TestFixture] - public class EventQueueTests + public class EventQueueTests : OpenSimTestCase { private TestScene m_scene; -- cgit v1.1 From 7bf33d333af6e7393a05940d1ab436f5dce73814 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 7 Feb 2013 22:25:28 +0000 Subject: Plumb the path from the client to the extra physics params and back --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 8 ++++++++ .../Linden/Caps/EventQueue/EventQueueHelper.cs | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 4d2c0f2..3cc3950 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -807,5 +807,13 @@ namespace OpenSim.Region.ClientStack.Linden { return EventQueueHelper.BuildEvent(eventName, eventBody); } + + public void partPhysicsProperties(uint localID, byte physhapetype, + float density, float friction, float bounce, float gravmod,UUID avatarID) + { + OSD item = EventQueueHelper.partPhysicsProperties(localID, physhapetype, + density, friction, bounce, gravmod); + Enqueue(item, avatarID); + } } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index 3f49aba..dab727f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -395,5 +395,25 @@ namespace OpenSim.Region.ClientStack.Linden return message; } + public static OSD partPhysicsProperties(uint localID, byte physhapetype, + float density, float friction, float bounce, float gravmod) + { + + OSDMap physinfo = new OSDMap(6); + physinfo["LocalID"] = localID; + physinfo["Density"] = density; + physinfo["Friction"] = friction; + physinfo["GravityMultiplier"] = gravmod; + physinfo["Restitution"] = bounce; + physinfo["PhysicsShapeType"] = (int)physhapetype; + + OSDArray array = new OSDArray(1); + array.Add(physinfo); + + OSDMap llsdBody = new OSDMap(1); + llsdBody.Add("ObjectData", array); + + return BuildEvent("ObjectPhysicsProperties", llsdBody); + } } } -- cgit v1.1 From e898a5fec5b78fe428ec10e1cd94cc717f5ac5a7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 11 Mar 2013 22:42:27 +0000 Subject: minor: Remove mono compiler warnings in EventQueueTests --- .../ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index ed8ec16..141af8a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -49,8 +49,10 @@ namespace OpenSim.Region.ClientStack.Linden.Tests private TestScene m_scene; [SetUp] - public void SetUp() + public override void SetUp() { + base.SetUp(); + uint port = 9999; uint sslPort = 9998; -- cgit v1.1 From 876d0d310f3c7248a4a6fc29d8babe55a7b1e570 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 28 Mar 2013 01:36:34 +0000 Subject: Add "show eq" console command to show numbers of messages in agent event queues. For debugging purposes. --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 3cc3950..624378e 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -97,6 +97,14 @@ namespace OpenSim.Region.ClientStack.Linden + " >= 1 - turns on outgoing event logging\n" + " >= 2 - turns on poll notification", HandleDebugEq); + + MainConsole.Instance.Commands.AddCommand( + "Debug", + false, + "show eq", + "show eq", + "Show contents of event queues for logged in avatars. Used for debugging.", + HandleShowEq); } public void RemoveRegion(Scene scene) @@ -148,6 +156,21 @@ namespace OpenSim.Region.ClientStack.Linden } } + protected void HandleShowEq(string module, string[] args) + { + MainConsole.Instance.OutputFormat("For scene {0}", m_scene.Name); + + lock (queues) + { + foreach (KeyValuePair> kvp in queues) + { + MainConsole.Instance.OutputFormat( + "For agent {0} there are {1} messages queued for send.", + kvp.Key, kvp.Value.Count); + } + } + } + /// /// Always returns a valid queue /// -- cgit v1.1 From 617637c788045f5776d21fc4ce246f3a8d6ecfb8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 28 Mar 2013 01:41:23 +0000 Subject: minor: Fix usage error message for "debug eq" console command --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 624378e..c7d4283 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -146,7 +146,7 @@ namespace OpenSim.Region.ClientStack.Linden if (!(args.Length == 3 && int.TryParse(args[2], out debugLevel))) { - MainConsole.Instance.OutputFormat("Usage: debug eq [0|1]"); + MainConsole.Instance.OutputFormat("Usage: debug eq [0|1|2]"); } else { -- cgit v1.1 From 7c0bfca7a03584dd65c5659f177b434ee94ddc9d Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 7 Jun 2013 23:43:45 +0100 Subject: Adding Avination's PollService to round out the HTTP inventory changes --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index c7d4283..e73a04a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -376,7 +376,7 @@ namespace OpenSim.Region.ClientStack.Linden // TODO: Add EventQueueGet name/description for diagnostics MainServer.Instance.AddPollServiceHTTPHandler( eventQueueGetPath, - new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); + new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID, 40000)); // m_log.DebugFormat( // "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", @@ -418,7 +418,7 @@ namespace OpenSim.Region.ClientStack.Linden } } - public Hashtable GetEvents(UUID requestID, UUID pAgentId, string request) + public Hashtable GetEvents(UUID requestID, UUID pAgentId) { if (DebugLevel >= 2) m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); -- cgit v1.1 From 013710168b3878fc0a93a92a1c026efb49da9935 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 8 Jul 2013 22:39:07 +0100 Subject: For stat purposes, add names to capability request handlers where these were not set --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index e73a04a..50bfda1 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -366,7 +366,8 @@ namespace OpenSim.Region.ClientStack.Linden // EventQueueGet when it receive capability information, but then we replace the rest handler immediately // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but // really it should be possible to directly register the poll handler as a capability. - caps.RegisterHandler("EventQueueGet", new RestHTTPHandler("POST", eventQueueGetPath, null)); + caps.RegisterHandler( + "EventQueueGet", new RestHTTPHandler("POST", eventQueueGetPath, null, "EventQueueGet", null)); // delegate(Hashtable m_dhttpMethod) // { // return ProcessQueue(m_dhttpMethod, agentID, caps); -- cgit v1.1 From 1b7b664c8696531fec26378d1386362d8a3da55e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 15 Jul 2013 23:22:39 +0100 Subject: Add request received/handling stats for caps which are served by http poll handlers. This adds explicit cap poll handler supporting to the Caps classes rather than relying on callers to do the complicated coding. Other refactoring was required to get logic into the right places to support this. --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 50bfda1..ca38a97 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -377,7 +377,7 @@ namespace OpenSim.Region.ClientStack.Linden // TODO: Add EventQueueGet name/description for diagnostics MainServer.Instance.AddPollServiceHTTPHandler( eventQueueGetPath, - new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID, 40000)); + new PollServiceEventArgs(null, eventQueueGetPath, HasEvents, GetEvents, NoEvents, agentID, 40000)); // m_log.DebugFormat( // "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", -- cgit v1.1 From e8e073aa97a8f756f42b242dd1cfcd05beb4d8ef Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 16 Jul 2013 00:05:45 +0100 Subject: Simplify EventQueue cap setup so that it is also stat monitored. Curiously, the number of requests received is always one greater than that shown as handled - needs investigation --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 74 +++++++++------------- 1 file changed, 29 insertions(+), 45 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index ca38a97..1835a72 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -252,29 +252,32 @@ namespace OpenSim.Region.ClientStack.Linden List removeitems = new List(); lock (m_AvatarQueueUUIDMapping) - { - foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys) - { -// m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID); - if (ky == agentID) - { - removeitems.Add(ky); - } - } + m_AvatarQueueUUIDMapping.Remove(agentID); - foreach (UUID ky in removeitems) - { - UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky]; - m_AvatarQueueUUIDMapping.Remove(ky); - - string eqgPath = GenerateEqgCapPath(eventQueueGetUuid); - MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath); - -// m_log.DebugFormat( -// "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}", -// eqgPath, agentID, m_scene.RegionInfo.RegionName); - } - } +// lock (m_AvatarQueueUUIDMapping) +// { +// foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys) +// { +//// m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID); +// if (ky == agentID) +// { +// removeitems.Add(ky); +// } +// } +// +// foreach (UUID ky in removeitems) +// { +// UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky]; +// m_AvatarQueueUUIDMapping.Remove(ky); +// +// string eqgPath = GenerateEqgCapPath(eventQueueGetUuid); +// MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath); +// +//// m_log.DebugFormat( +//// "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}", +//// eqgPath, agentID, m_scene.RegionInfo.RegionName); +// } +// } UUID searchval = UUID.Zero; @@ -359,29 +362,10 @@ namespace OpenSim.Region.ClientStack.Linden m_AvatarQueueUUIDMapping.Add(agentID, eventQueueGetUUID); } - string eventQueueGetPath = GenerateEqgCapPath(eventQueueGetUUID); - - // Register this as a caps handler - // FIXME: Confusingly, we need to register separate as a capability so that the client is told about - // EventQueueGet when it receive capability information, but then we replace the rest handler immediately - // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but - // really it should be possible to directly register the poll handler as a capability. - caps.RegisterHandler( - "EventQueueGet", new RestHTTPHandler("POST", eventQueueGetPath, null, "EventQueueGet", null)); -// delegate(Hashtable m_dhttpMethod) -// { -// return ProcessQueue(m_dhttpMethod, agentID, caps); -// })); - - // This will persist this beyond the expiry of the caps handlers - // TODO: Add EventQueueGet name/description for diagnostics - MainServer.Instance.AddPollServiceHTTPHandler( - eventQueueGetPath, - new PollServiceEventArgs(null, eventQueueGetPath, HasEvents, GetEvents, NoEvents, agentID, 40000)); - -// m_log.DebugFormat( -// "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", -// eventQueueGetPath, agentID, m_scene.RegionInfo.RegionName); + caps.RegisterPollHandler( + "EventQueueGet", + new PollServiceEventArgs( + null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); Random rnd = new Random(Environment.TickCount); lock (m_ids) -- cgit v1.1 From e46459ef21e1ee5ceaeca70365a7c881d33b09ce Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 17 Jul 2013 11:19:36 -0700 Subject: Cleared up much confusion in PollServiceRequestManager. Here's the history: When Melanie added the web fetch inventory throttle to core, she made the long poll requests (EQs) effectively be handled on an active loop. All those requests, if they existed, were being constantly dequeued, checked for events (which most often they didn't have), and requeued again. This was an active loop thread on a 100ms cycle! This fixes the issue. Now the inventory requests, if they aren't ready to be served, are placed directly back in the queue, but the long poll requests aren't placed there until there are events ready to be sent or timeout has been reached. This puts the LongPollServiceWatcherThread back to 1sec cycle, as it was before. --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 1835a72..f0445ff 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -364,8 +364,7 @@ namespace OpenSim.Region.ClientStack.Linden caps.RegisterPollHandler( "EventQueueGet", - new PollServiceEventArgs( - null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); + new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); Random rnd = new Random(Environment.TickCount); lock (m_ids) @@ -383,7 +382,10 @@ namespace OpenSim.Region.ClientStack.Linden Queue queue = GetQueue(agentID); if (queue != null) lock (queue) + { + //m_log.WarnFormat("POLLED FOR EVENTS BY {0} in {1} -- {2}", agentID, m_scene.RegionInfo.RegionName, queue.Count); return queue.Count > 0; + } return false; } @@ -406,7 +408,7 @@ namespace OpenSim.Region.ClientStack.Linden public Hashtable GetEvents(UUID requestID, UUID pAgentId) { if (DebugLevel >= 2) - m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); + m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); Queue queue = TryGetQueue(pAgentId); OSD element; -- cgit v1.1 From fa2370b32ee57a07f27501152c3c705a883b13d8 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 17 Jul 2013 15:05:36 -0700 Subject: Revert "Cleared up much confusion in PollServiceRequestManager. Here's the history:" This reverts commit e46459ef21e1ee5ceaeca70365a7c881d33b09ce. --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index f0445ff..1835a72 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -364,7 +364,8 @@ namespace OpenSim.Region.ClientStack.Linden caps.RegisterPollHandler( "EventQueueGet", - new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); + new PollServiceEventArgs( + null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); Random rnd = new Random(Environment.TickCount); lock (m_ids) @@ -382,10 +383,7 @@ namespace OpenSim.Region.ClientStack.Linden Queue queue = GetQueue(agentID); if (queue != null) lock (queue) - { - //m_log.WarnFormat("POLLED FOR EVENTS BY {0} in {1} -- {2}", agentID, m_scene.RegionInfo.RegionName, queue.Count); return queue.Count > 0; - } return false; } @@ -408,7 +406,7 @@ namespace OpenSim.Region.ClientStack.Linden public Hashtable GetEvents(UUID requestID, UUID pAgentId) { if (DebugLevel >= 2) - m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); + m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); Queue queue = TryGetQueue(pAgentId); OSD element; -- cgit v1.1 From 9e35b069a43942285214ff485c8f5ffb53e7c5ec Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 18 Jul 2013 12:23:27 -0700 Subject: Reverting the reverts I did yesterday. cpu-branch has now been successfully tested, and I'm merging back those changes, which proved to be good. Revert "Revert "Cleared up much confusion in PollServiceRequestManager. Here's the history:"" This reverts commit fa2370b32ee57a07f27501152c3c705a883b13d8. --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 1835a72..f0445ff 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -364,8 +364,7 @@ namespace OpenSim.Region.ClientStack.Linden caps.RegisterPollHandler( "EventQueueGet", - new PollServiceEventArgs( - null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); + new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); Random rnd = new Random(Environment.TickCount); lock (m_ids) @@ -383,7 +382,10 @@ namespace OpenSim.Region.ClientStack.Linden Queue queue = GetQueue(agentID); if (queue != null) lock (queue) + { + //m_log.WarnFormat("POLLED FOR EVENTS BY {0} in {1} -- {2}", agentID, m_scene.RegionInfo.RegionName, queue.Count); return queue.Count > 0; + } return false; } @@ -406,7 +408,7 @@ namespace OpenSim.Region.ClientStack.Linden public Hashtable GetEvents(UUID requestID, UUID pAgentId) { if (DebugLevel >= 2) - m_log.DebugFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); + m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); Queue queue = TryGetQueue(pAgentId); OSD element; -- cgit v1.1 From b5062ae7ee4067158f255a0d62fb87b8eaf9d1d6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 18 Jul 2013 13:30:04 -0700 Subject: Changed the timoeut of EQ 502s (no events) to 50 secs. The viewer post requests timeout in 60 secs. There's plenty of room for improvement in handling the EQs. Some other time... --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index f0445ff..c5e28ad 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -65,6 +65,13 @@ namespace OpenSim.Region.ClientStack.Linden /// public int DebugLevel { get; set; } + // Viewer post requests timeout in 60 secs + // https://bitbucket.org/lindenlab/viewer-release/src/421c20423df93d650cc305dc115922bb30040999/indra/llmessage/llhttpclient.cpp?at=default#cl-44 + // + private const int VIEWER_TIMEOUT = 60 * 1000; + // Just to be safe, we work on a 10 sec shorter cycle + private const int SERVER_EQ_TIME_NO_EVENTS = VIEWER_TIMEOUT - (10 * 1000); + protected Scene m_scene; private Dictionary m_ids = new Dictionary(); @@ -363,8 +370,8 @@ namespace OpenSim.Region.ClientStack.Linden } caps.RegisterPollHandler( - "EventQueueGet", - new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, 40000)); + "EventQueueGet", + new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS)); Random rnd = new Random(Environment.TickCount); lock (m_ids) -- cgit v1.1 From 878ce1e6b2b96043052015732286141f5b71310b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 25 Jul 2013 23:44:58 -0700 Subject: This should fix all issues with teleports. One should be able to TP as fast as needed. (Although sometimes Justin's state machine kicks in and doesn't let you) The EventQueues are a hairy mess, and it's very easy to mess things up. But it looks like this commit makes them work right. Here's what's going on: - Child and root agents are only closed after 15 sec, maybe - If the user comes back, they aren't closed, and everything is reused - On the receiving side, clients and scene presences are reused if they already exist - Caps are always recreated (this is where I spent most of my time!). It turns out that, because the agents carry the seeds around, the seed gets the same URL, except for the root agent coming back to a far away region, which gets a new seed (because we don't know what was its seed in the departing region, and we can't send it back to the client when the agent returns there). --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 58 ++++++---------------- 1 file changed, 14 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index c5e28ad..d02496f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -91,7 +91,6 @@ namespace OpenSim.Region.ClientStack.Linden scene.RegisterModuleInterface(this); scene.EventManager.OnClientClosed += ClientClosed; - scene.EventManager.OnMakeChildAgent += MakeChildAgent; scene.EventManager.OnRegisterCaps += OnRegisterCaps; MainConsole.Instance.Commands.AddCommand( @@ -120,7 +119,6 @@ namespace OpenSim.Region.ClientStack.Linden return; scene.EventManager.OnClientClosed -= ClientClosed; - scene.EventManager.OnMakeChildAgent -= MakeChildAgent; scene.EventManager.OnRegisterCaps -= OnRegisterCaps; scene.UnregisterModuleInterface(this); @@ -189,14 +187,12 @@ namespace OpenSim.Region.ClientStack.Linden { if (!queues.ContainsKey(agentId)) { - /* m_log.DebugFormat( "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", agentId, m_scene.RegionInfo.RegionName); - */ queues[agentId] = new Queue(); } - + return queues[agentId]; } } @@ -228,8 +224,12 @@ namespace OpenSim.Region.ClientStack.Linden { Queue queue = GetQueue(avatarID); if (queue != null) + { lock (queue) queue.Enqueue(ev); + } + else + m_log.WarnFormat("[EVENTQUEUE]: (Enqueue) No queue found for agent {0} in region {1}", avatarID, m_scene.RegionInfo.RegionName); } catch (NullReferenceException e) { @@ -244,7 +244,7 @@ namespace OpenSim.Region.ClientStack.Linden private void ClientClosed(UUID agentID, Scene scene) { -// m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); + //m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); int count = 0; while (queues.ContainsKey(agentID) && queues[agentID].Count > 0 && count++ < 5) @@ -261,31 +261,6 @@ namespace OpenSim.Region.ClientStack.Linden lock (m_AvatarQueueUUIDMapping) m_AvatarQueueUUIDMapping.Remove(agentID); -// lock (m_AvatarQueueUUIDMapping) -// { -// foreach (UUID ky in m_AvatarQueueUUIDMapping.Keys) -// { -//// m_log.DebugFormat("[EVENTQUEUE]: Found key {0} in m_AvatarQueueUUIDMapping while looking for {1}", ky, AgentID); -// if (ky == agentID) -// { -// removeitems.Add(ky); -// } -// } -// -// foreach (UUID ky in removeitems) -// { -// UUID eventQueueGetUuid = m_AvatarQueueUUIDMapping[ky]; -// m_AvatarQueueUUIDMapping.Remove(ky); -// -// string eqgPath = GenerateEqgCapPath(eventQueueGetUuid); -// MainServer.Instance.RemovePollServiceHTTPHandler("", eqgPath); -// -//// m_log.DebugFormat( -//// "[EVENT QUEUE GET MODULE]: Removed EQG handler {0} for {1} in {2}", -//// eqgPath, agentID, m_scene.RegionInfo.RegionName); -// } -// } - UUID searchval = UUID.Zero; removeitems.Clear(); @@ -305,19 +280,9 @@ namespace OpenSim.Region.ClientStack.Linden foreach (UUID ky in removeitems) m_QueueUUIDAvatarMapping.Remove(ky); } - } - private void MakeChildAgent(ScenePresence avatar) - { - //m_log.DebugFormat("[EVENTQUEUE]: Make Child agent {0} in region {1}.", avatar.UUID, m_scene.RegionInfo.RegionName); - //lock (m_ids) - // { - //if (m_ids.ContainsKey(avatar.UUID)) - //{ - // close the event queue. - //m_ids[avatar.UUID] = -1; - //} - //} + // m_log.DebugFormat("[EVENTQUEUE]: Deleted queues for {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); + } /// @@ -417,7 +382,12 @@ namespace OpenSim.Region.ClientStack.Linden if (DebugLevel >= 2) m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); - Queue queue = TryGetQueue(pAgentId); + Queue queue = GetQueue(pAgentId); + if (queue == null) + { + return NoEvents(requestID, pAgentId); + } + OSD element; lock (queue) { -- cgit v1.1 From d5367a219daa0b946b3394e342734945d5ef7f1b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 26 Jul 2013 07:39:57 -0700 Subject: Slight improvement: no need to delay the removal of the queues in EQ, because DisableSimulator is now being sent via UDP --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index d02496f..c69f758 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -246,16 +246,8 @@ namespace OpenSim.Region.ClientStack.Linden { //m_log.DebugFormat("[EVENTQUEUE]: Closed client {0} in region {1}", agentID, m_scene.RegionInfo.RegionName); - int count = 0; - while (queues.ContainsKey(agentID) && queues[agentID].Count > 0 && count++ < 5) - { - Thread.Sleep(1000); - } - lock (queues) - { queues.Remove(agentID); - } List removeitems = new List(); lock (m_AvatarQueueUUIDMapping) -- cgit v1.1 From 69975763d2a735eb2696d2e27e5796a472a208ea Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 27 Jul 2013 15:38:56 -0700 Subject: Several major improvements to group (V2) chat. Specifically: handle join/drop appropriately, invitechatboxes. The major departure from flotsam is to send only one message per destination region, as opposed to one message per group member. This reduces messaging considerably in large groups that have clusters of members in certain regions. --- .../Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index c69f758..d7afe1a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -750,12 +750,12 @@ namespace OpenSim.Region.ClientStack.Linden } - public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID fromAgent, UUID toAgent, bool canVoiceChat, + public void ChatterBoxSessionAgentListUpdates(UUID sessionID, UUID fromAgent, UUID anotherAgent, bool canVoiceChat, bool isModerator, bool textMute) { OSD item = EventQueueHelper.ChatterBoxSessionAgentListUpdates(sessionID, fromAgent, canVoiceChat, isModerator, textMute); - Enqueue(item, toAgent); + Enqueue(item, fromAgent); //m_log.InfoFormat("########### eq ChatterBoxSessionAgentListUpdates #############\n{0}", item); } -- cgit v1.1 From b1c26a56b3d615f3709363e3a2f91b5423f5891f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Aug 2013 23:29:30 +0100 Subject: Fix an issue where under teleport v2 protocol, teleporting from regions in an line from A->B->C would not close region A when reaching C The root cause was that v2 was only closing neighbour agents if the root connection also needed a close. However, fixing this requires the neighbour regions also detect when they should not close due to re-teleports re-establishing the child connection. This involves restructuring the code to introduce a scene presence state machine that can serialize the different add and remove client calls that are now possible with the late close of the This commit appears to fix these issues and improve teleport, but still has holes on at least quick reteleporting (and possibly occasionally on ordinary teleports). Also, has not been completely tested yet in scenarios where regions are running on different simulators --- .../Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index 141af8a..626932f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -91,7 +91,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests public void RemoveForClient() { TestHelpers.InMethod(); -// log4net.Config.XmlConfigurator.Configure(); +// TestHelpers.EnableLogging(); UUID spId = TestHelpers.ParseTail(0x1); -- cgit v1.1 From f3edc0d8b795f665dcf2ea2feb2b7886c8a451e1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 12 Aug 2013 19:38:23 +0100 Subject: minor: Extend warning message when adding trying to add an event for a client without a queue to include the event message name. --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index d7afe1a..c28ba94 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -229,7 +229,12 @@ namespace OpenSim.Region.ClientStack.Linden queue.Enqueue(ev); } else - m_log.WarnFormat("[EVENTQUEUE]: (Enqueue) No queue found for agent {0} in region {1}", avatarID, m_scene.RegionInfo.RegionName); + { + OSDMap evMap = (OSDMap)ev; + m_log.WarnFormat( + "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} when placing message {1} in region {2}", + avatarID, evMap["message"], m_scene.Name); + } } catch (NullReferenceException e) { @@ -365,14 +370,14 @@ namespace OpenSim.Region.ClientStack.Linden OSDMap ev = (OSDMap)element; m_log.DebugFormat( "Eq OUT {0,-30} to {1,-20} {2,-20}", - ev["message"], m_scene.GetScenePresence(agentId).Name, m_scene.RegionInfo.RegionName); + ev["message"], m_scene.GetScenePresence(agentId).Name, m_scene.Name); } } public Hashtable GetEvents(UUID requestID, UUID pAgentId) { if (DebugLevel >= 2) - m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.RegionInfo.RegionName); + m_log.WarnFormat("POLLED FOR EQ MESSAGES BY {0} in {1}", pAgentId, m_scene.Name); Queue queue = GetQueue(pAgentId); if (queue == null) -- cgit v1.1 From 857f24a5e2b59072ad4d987d5e64318f5249c7e7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 2 Sep 2013 19:15:10 +0100 Subject: Fix bug where users teleporting to non-neighbour regions could continue to hear chat from their source region for some time after teleport completion. This occurs on v2 teleport since the source region now waits 15 secs before closing the old child agent, which could still receive chat. This commit introduces a ScenePresenceState.PreClose which is set before the wait, so that ChatModule can check for ScenePresenceState.Running. This was theoretically also an issue on v1 teleport but since the pause before close was only 2 secs there, it was not noticed. --- .../ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index 626932f..b3b0b8a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests } [Test] - public void AddForClient() + public void TestAddForClient() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); @@ -88,7 +88,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests } [Test] - public void RemoveForClient() + public void TestRemoveForClient() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); -- cgit v1.1 From b16bc7b01ca0691758e66f85238d657f02271082 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 27 Sep 2013 19:14:21 +0100 Subject: refactor: rename Scene.IncomingCloseAgent() to CloseAgent() in order to make it clear that all non-clientstack callers should be using this rather than RemoveClient() in order to step through the ScenePresence state machine properly. Adds IScene.CloseAgent() to replace RemoveClient() --- .../Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index b3b0b8a..9e24bce 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -96,7 +96,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests UUID spId = TestHelpers.ParseTail(0x1); SceneHelpers.AddScenePresence(m_scene, spId); - m_scene.IncomingCloseAgent(spId, false); + m_scene.CloseAgent(spId, false); // TODO: Add more assertions for the other aspects of event queues Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); -- cgit v1.1 From a5ca15c42893681a777d091c737d5c7615af4f48 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 18 Dec 2013 23:35:38 +0000 Subject: Create regression test TestSendAgentGroupDataUpdate() for groups agent data sending --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index c28ba94..0dbdbaf 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -295,9 +295,9 @@ namespace OpenSim.Region.ClientStack.Linden { // Register an event queue for the client - //m_log.DebugFormat( - // "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", - // agentID, caps, m_scene.RegionInfo.RegionName); + m_log.DebugFormat( + "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", + agentID, caps, m_scene.RegionInfo.RegionName); // Let's instantiate a Queue for this agent right now TryGetQueue(agentID); -- cgit v1.1 From 9984ecf862ff7362b0caa6c55554c3fd2243873d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 3 Jan 2014 07:41:06 -0800 Subject: varregion: Add region size to teleport event messages (EnableSimulator, CorssRegion, TeleportFinishEvent). Have Simian grid service return the region size. Many teleport related debug log messages. Can be removed when teleport works (like that's ever going to happen). --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 28 ++++++++++++----- .../Linden/Caps/EventQueue/EventQueueHelper.cs | 36 +++++++++++++++------- 2 files changed, 45 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 0dbdbaf..a05e88c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -711,34 +711,46 @@ namespace OpenSim.Region.ClientStack.Linden Enqueue(item, avatarID); } - public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID) + public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) { - OSD item = EventQueueHelper.EnableSimulator(handle, endPoint); + m_log.DebugFormat("{0} EnableSimulator. handle={1}, avatarID={2}, regionSize={3},{4}>", + "[EVENT QUEUE GET MODULE]", handle, avatarID, regionSizeX, regionSizeY); + + OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); Enqueue(item, avatarID); } - public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath) + public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath, + ulong regionHandle, int regionSizeX, int regionSizeY) { - OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath); + m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, avatarID={2}, regionSize={3},{4}>", + "[EVENT QUEUE GET MODULE]", regionHandle, avatarID, regionSizeX, regionSizeY); + OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); Enqueue(item, avatarID); } public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL, - UUID avatarID) + UUID avatarID, int regionSizeX, int regionSizeY) { + m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, avatarID={2}, regionSize={3},{4}>", + "[EVENT QUEUE GET MODULE]", regionHandle, avatarID, regionSizeX, regionSizeY); + OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, - locationID, flags, capsURL, avatarID); + locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); Enqueue(item, avatarID); } public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, - string capsURL, UUID avatarID, UUID sessionID) + string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) { + m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", + "[EVENT QUEUE GET MODULE]", handle, avatarID, regionSizeX, regionSizeY); + OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, - capsURL, avatarID, sessionID); + capsURL, avatarID, sessionID, regionSizeX, regionSizeY); Enqueue(item, avatarID); } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index dab727f..ded228d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -70,13 +70,15 @@ namespace OpenSim.Region.ClientStack.Linden return llsdEvent; } - public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint) + public static OSD EnableSimulator(ulong handle, IPEndPoint endPoint, int regionSizeX, int regionSizeY) { - OSDMap llsdSimInfo = new OSDMap(3); + OSDMap llsdSimInfo = new OSDMap(5); llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port)); + llsdSimInfo.Add("RegionSizeX", new OSDInteger(regionSizeX)); + llsdSimInfo.Add("RegionSizeY", new OSDInteger(regionSizeY)); OSDArray arr = new OSDArray(1); arr.Add(llsdSimInfo); @@ -104,7 +106,8 @@ namespace OpenSim.Region.ClientStack.Linden public static OSD CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, - string capsURL, UUID agentID, UUID sessionID) + string capsURL, UUID agentID, UUID sessionID, + int regionSizeX, int regionSizeY) { OSDArray lookAtArr = new OSDArray(3); lookAtArr.Add(OSD.FromReal(lookAt.X)); @@ -130,11 +133,13 @@ namespace OpenSim.Region.ClientStack.Linden OSDArray agentDataArr = new OSDArray(1); agentDataArr.Add(agentDataMap); - OSDMap regionDataMap = new OSDMap(4); + OSDMap regionDataMap = new OSDMap(6); regionDataMap.Add("RegionHandle", OSD.FromBinary(ulongToByteArray(handle))); regionDataMap.Add("SeedCapability", OSD.FromString(capsURL)); regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port)); + regionDataMap.Add("RegionSizeX", new OSDInteger(regionSizeX)); + regionDataMap.Add("RegionSizeY", new OSDInteger(regionSizeY)); OSDArray regionDataArr = new OSDArray(1); regionDataArr.Add(regionDataMap); @@ -148,8 +153,9 @@ namespace OpenSim.Region.ClientStack.Linden } public static OSD TeleportFinishEvent( - ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, - uint locationID, uint flags, string capsURL, UUID agentID) + ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, + uint locationID, uint flags, string capsURL, UUID agentID, + int regionSizeX, int regionSizeY) { OSDMap info = new OSDMap(); info.Add("AgentID", OSD.FromUUID(agentID)); @@ -160,6 +166,8 @@ namespace OpenSim.Region.ClientStack.Linden info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation + info.Add("RegionSizeX", new OSDInteger(regionSizeX)); + info.Add("RegionSizeY", new OSDInteger(regionSizeY)); OSDArray infoArr = new OSDArray(); infoArr.Add(info); @@ -187,12 +195,18 @@ namespace OpenSim.Region.ClientStack.Linden return BuildEvent("ScriptRunningReply", body); } - public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap) + public static OSD EstablishAgentCommunication(UUID agentID, string simIpAndPort, string seedcap, + ulong regionHandle, int regionSizeX, int regionSizeY) { - OSDMap body = new OSDMap(3); - body.Add("agent-id", new OSDUUID(agentID)); - body.Add("sim-ip-and-port", new OSDString(simIpAndPort)); - body.Add("seed-capability", new OSDString(seedcap)); + OSDMap body = new OSDMap(6) + { + {"agent-id", new OSDUUID(agentID)}, + {"sim-ip-and-port", new OSDString(simIpAndPort)}, + {"seed-capability", new OSDString(seedcap)}, + {"region-handle", OSD.FromULong(regionHandle)}, + {"region-size-x", OSD.FromInteger(regionSizeX)}, + {"region-size-y", OSD.FromInteger(regionSizeY)} + }; return BuildEvent("EstablishAgentCommunication", body); } -- cgit v1.1 From 1eea6fd452f2584d1f0948b15a02d3164b673618 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 11 Jan 2014 22:00:24 -0800 Subject: varregion: Debug messages for region crossing debugging. --- .../ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index a05e88c..f98337d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -59,6 +59,7 @@ namespace OpenSim.Region.ClientStack.Linden public class EventQueueGetModule : IEventQueue, INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static string LogHeader = "[EVENT QUEUE GET MODULE]"; /// /// Debug level. @@ -714,7 +715,7 @@ namespace OpenSim.Region.ClientStack.Linden public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) { m_log.DebugFormat("{0} EnableSimulator. handle={1}, avatarID={2}, regionSize={3},{4}>", - "[EVENT QUEUE GET MODULE]", handle, avatarID, regionSizeX, regionSizeY); + LogHeader, handle, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); Enqueue(item, avatarID); @@ -724,7 +725,7 @@ namespace OpenSim.Region.ClientStack.Linden ulong regionHandle, int regionSizeX, int regionSizeY) { m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, avatarID={2}, regionSize={3},{4}>", - "[EVENT QUEUE GET MODULE]", regionHandle, avatarID, regionSizeX, regionSizeY); + LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); Enqueue(item, avatarID); } @@ -734,8 +735,8 @@ namespace OpenSim.Region.ClientStack.Linden uint locationID, uint flags, string capsURL, UUID avatarID, int regionSizeX, int regionSizeY) { - m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, avatarID={2}, regionSize={3},{4}>", - "[EVENT QUEUE GET MODULE]", regionHandle, avatarID, regionSizeX, regionSizeY); + m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, avatarID={2}, regionSize=<{3},{4}>", + LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); @@ -747,7 +748,7 @@ namespace OpenSim.Region.ClientStack.Linden string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) { m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", - "[EVENT QUEUE GET MODULE]", handle, avatarID, regionSizeX, regionSizeY); + LogHeader, handle, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, capsURL, avatarID, sessionID, regionSizeX, regionSizeY); -- cgit v1.1 From cc5cffc2126b062395a57ea07ebcd8882c514db4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sat, 11 Jan 2014 22:00:52 -0800 Subject: varregion: properly pack the region size parameters so he viewer will parse them. This gets rid of the viewer crash when teleporting into varregions and allows multiple, adjacent varregions (of the same size) with border crossings. --- .../ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs index ded228d..384af74 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueHelper.cs @@ -77,8 +77,8 @@ namespace OpenSim.Region.ClientStack.Linden llsdSimInfo.Add("Handle", new OSDBinary(ulongToByteArray(handle))); llsdSimInfo.Add("IP", new OSDBinary(endPoint.Address.GetAddressBytes())); llsdSimInfo.Add("Port", new OSDInteger(endPoint.Port)); - llsdSimInfo.Add("RegionSizeX", new OSDInteger(regionSizeX)); - llsdSimInfo.Add("RegionSizeY", new OSDInteger(regionSizeY)); + llsdSimInfo.Add("RegionSizeX", OSD.FromUInteger((uint) regionSizeX)); + llsdSimInfo.Add("RegionSizeY", OSD.FromUInteger((uint) regionSizeY)); OSDArray arr = new OSDArray(1); arr.Add(llsdSimInfo); @@ -138,8 +138,8 @@ namespace OpenSim.Region.ClientStack.Linden regionDataMap.Add("SeedCapability", OSD.FromString(capsURL)); regionDataMap.Add("SimIP", OSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); regionDataMap.Add("SimPort", OSD.FromInteger(newRegionExternalEndPoint.Port)); - regionDataMap.Add("RegionSizeX", new OSDInteger(regionSizeX)); - regionDataMap.Add("RegionSizeY", new OSDInteger(regionSizeY)); + regionDataMap.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); + regionDataMap.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); OSDArray regionDataArr = new OSDArray(1); regionDataArr.Add(regionDataMap); @@ -166,8 +166,8 @@ namespace OpenSim.Region.ClientStack.Linden info.Add("SimIP", OSD.FromBinary(regionExternalEndPoint.Address.GetAddressBytes())); info.Add("SimPort", OSD.FromInteger(regionExternalEndPoint.Port)); info.Add("TeleportFlags", OSD.FromULong(1L << 4)); // AgentManager.TeleportFlags.ViaLocation - info.Add("RegionSizeX", new OSDInteger(regionSizeX)); - info.Add("RegionSizeY", new OSDInteger(regionSizeY)); + info.Add("RegionSizeX", OSD.FromUInteger((uint)regionSizeX)); + info.Add("RegionSizeY", OSD.FromUInteger((uint)regionSizeY)); OSDArray infoArr = new OSDArray(); infoArr.Add(info); -- cgit v1.1 From e10012a7a6a047287c193c4beb1afdcd62922e3e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Feb 2014 23:16:42 +0000 Subject: If a caller tries to queue a CAPs message to a scene presence that has no event queue (e.g. an NPC), only warn if event queue debugging is greater than zero. Removes the spurious log warnings if groups are active when NPCs are used. Adds more regression tests associated with adding messages to the event queue --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 16 ++-- .../Caps/EventQueue/Tests/EventQueueTests.cs | 90 +++++++++++++++++++++- 2 files changed, 99 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 0dbdbaf..0447bc4 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -228,12 +228,18 @@ namespace OpenSim.Region.ClientStack.Linden lock (queue) queue.Enqueue(ev); } - else + else if (DebugLevel > 0) { - OSDMap evMap = (OSDMap)ev; - m_log.WarnFormat( - "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} when placing message {1} in region {2}", - avatarID, evMap["message"], m_scene.Name); + ScenePresence sp = m_scene.GetScenePresence(avatarID); + + // This assumes that an NPC should never have a queue. + if (sp != null && sp.PresenceType != PresenceType.Npc) + { + OSDMap evMap = (OSDMap)ev; + m_log.WarnFormat( + "[EVENTQUEUE]: (Enqueue) No queue found for agent {0} {1} when placing message {2} in region {3}", + sp.Name, sp.UUID, evMap["message"], m_scene.Name); + } } } catch (NullReferenceException e) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index 9e24bce..fb24f58 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -26,6 +26,7 @@ */ using System; +using System.Collections; using System.Collections.Generic; using System.Net; using log4net.Config; @@ -33,11 +34,14 @@ using Nini.Config; using NUnit.Framework; using OpenMetaverse; using OpenMetaverse.Packets; +using OpenMetaverse.StructuredData; using OpenSim.Framework; using OpenSim.Framework.Servers; using OpenSim.Framework.Servers.HttpServer; using OpenSim.Region.ClientStack.Linden; using OpenSim.Region.CoreModules.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.OptionalModules.World.NPC; using OpenSim.Tests.Common; using OpenSim.Tests.Common.Mock; @@ -47,6 +51,8 @@ namespace OpenSim.Region.ClientStack.Linden.Tests public class EventQueueTests : OpenSimTestCase { private TestScene m_scene; + private EventQueueGetModule m_eqgMod; + private NPCModule m_npcMod; [SetUp] public override void SetUp() @@ -69,10 +75,15 @@ namespace OpenSim.Region.ClientStack.Linden.Tests config.Configs["Startup"].Set("EventQueue", "true"); CapabilitiesModule capsModule = new CapabilitiesModule(); - EventQueueGetModule eqgModule = new EventQueueGetModule(); + m_eqgMod = new EventQueueGetModule(); + + // For NPC test support + config.AddConfig("NPC"); + config.Configs["NPC"].Set("Enabled", "true"); + m_npcMod = new NPCModule(); m_scene = new SceneHelpers().SetupScene(); - SceneHelpers.SetupSceneModules(m_scene, config, capsModule, eqgModule); + SceneHelpers.SetupSceneModules(m_scene, config, capsModule, m_eqgMod, m_npcMod); } [Test] @@ -101,5 +112,80 @@ namespace OpenSim.Region.ClientStack.Linden.Tests // TODO: Add more assertions for the other aspects of event queues Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); } + + [Test] + public void TestEnqueueMessage() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); + + string messageName = "TestMessage"; + + m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), sp.UUID); + + Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, sp.UUID); + + Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK)); + +// Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]); + + OSDMap rawOsd = (OSDMap)OSDParser.DeserializeLLSDXml((string)eventsResponse["str_response_string"]); + OSDArray eventsOsd = (OSDArray)rawOsd["events"]; + + bool foundUpdate = false; + foreach (OSD osd in eventsOsd) + { + OSDMap eventOsd = (OSDMap)osd; + + if (eventOsd["message"] == messageName) + foundUpdate = true; + } + + Assert.That(foundUpdate, Is.True, string.Format("Did not find {0} in response", messageName)); + } + + /// + /// Test an attempt to put a message on the queue of a user that is not in the region. + /// + [Test] + public void TestEnqueueMessageNoUser() + { + TestHelpers.InMethod(); + TestHelpers.EnableLogging(); + + string messageName = "TestMessage"; + + m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), TestHelpers.ParseTail(0x1)); + + Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, TestHelpers.ParseTail(0x1)); + + Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway)); + } + + /// + /// NPCs do not currently have an event queue but a caller may try to send a message anyway, so check behaviour. + /// + [Test] + public void TestEnqueueMessageToNpc() + { + TestHelpers.InMethod(); +// TestHelpers.EnableLogging(); + + UUID npcId + = m_npcMod.CreateNPC( + "John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, new AvatarAppearance()); + + ScenePresence npc = m_scene.GetScenePresence(npcId); + + string messageName = "TestMessage"; + + m_eqgMod.Enqueue(m_eqgMod.BuildEvent(messageName, new OSDMap()), npc.UUID); + + Hashtable eventsResponse = m_eqgMod.GetEvents(UUID.Zero, npc.UUID); + + Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.BadGateway)); + } } } \ No newline at end of file -- cgit v1.1 From d6890d78addd364c18629add9884cabbf0dbef4d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 5 Aug 2014 00:49:17 +0100 Subject: Make currently unfiltered EventQueue log messages only appear now at DebugLevel 1 This covers event queue setup messages and some outgoing messages (e.g. EnableSimulator) In my experience these messages are only useful if you really know what they mean and you're looking for them Otherwise, they're quite spammy. Event queue DebugLevel 1 is enabled with the "debug eq 1" console command --- .../Linden/Caps/EventQueue/EventQueueGetModule.cs | 40 +++++++++++++--------- 1 file changed, 24 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index b162bb9..9b9f6a7 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs @@ -101,7 +101,7 @@ namespace OpenSim.Region.ClientStack.Linden "debug eq [0|1|2]", "Turn on event queue debugging\n" + " <= 0 - turns off all event queue logging\n" - + " >= 1 - turns on outgoing event logging\n" + + " >= 1 - turns on event queue setup and outgoing event logging\n" + " >= 2 - turns on poll notification", HandleDebugEq); @@ -188,9 +188,11 @@ namespace OpenSim.Region.ClientStack.Linden { if (!queues.ContainsKey(agentId)) { - m_log.DebugFormat( - "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", - agentId, m_scene.RegionInfo.RegionName); + if (DebugLevel > 0) + m_log.DebugFormat( + "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}", + agentId, m_scene.RegionInfo.RegionName); + queues[agentId] = new Queue(); } @@ -302,9 +304,10 @@ namespace OpenSim.Region.ClientStack.Linden { // Register an event queue for the client - m_log.DebugFormat( - "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", - agentID, caps, m_scene.RegionInfo.RegionName); + if (DebugLevel > 0) + m_log.DebugFormat( + "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}", + agentID, caps, m_scene.RegionInfo.RegionName); // Let's instantiate a Queue for this agent right now TryGetQueue(agentID); @@ -720,8 +723,9 @@ namespace OpenSim.Region.ClientStack.Linden public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY) { - m_log.DebugFormat("{0} EnableSimulator. handle={1}, avatarID={2}, regionSize={3},{4}>", - LogHeader, handle, avatarID, regionSizeX, regionSizeY); + if (DebugLevel > 0) + m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}", + LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.EnableSimulator(handle, endPoint, regionSizeX, regionSizeY); Enqueue(item, avatarID); @@ -730,8 +734,10 @@ namespace OpenSim.Region.ClientStack.Linden public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath, ulong regionHandle, int regionSizeX, int regionSizeY) { - m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, avatarID={2}, regionSize={3},{4}>", - LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); + if (DebugLevel > 0) + m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}", + LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY); + OSD item = EventQueueHelper.EstablishAgentCommunication(avatarID, endPoint.ToString(), capsPath, regionHandle, regionSizeX, regionSizeY); Enqueue(item, avatarID); } @@ -741,8 +747,9 @@ namespace OpenSim.Region.ClientStack.Linden uint locationID, uint flags, string capsURL, UUID avatarID, int regionSizeX, int regionSizeY) { - m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, avatarID={2}, regionSize=<{3},{4}>", - LogHeader, regionHandle, avatarID, regionSizeX, regionSizeY); + if (DebugLevel > 0) + m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}", + LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.TeleportFinishEvent(regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL, avatarID, regionSizeX, regionSizeY); @@ -753,8 +760,9 @@ namespace OpenSim.Region.ClientStack.Linden IPEndPoint newRegionExternalEndPoint, string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY) { - m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", - LogHeader, handle, avatarID, regionSizeX, regionSizeY); + if (DebugLevel > 0) + m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>", + LogHeader, handle, avatarID, regionSizeX, regionSizeY); OSD item = EventQueueHelper.CrossRegion(handle, pos, lookAt, newRegionExternalEndPoint, capsURL, avatarID, sessionID, regionSizeX, regionSizeY); @@ -819,4 +827,4 @@ namespace OpenSim.Region.ClientStack.Linden Enqueue(item, avatarID); } } -} +} \ No newline at end of file -- cgit v1.1 From fc878a33edcb403018e485ba0e8b7a6b3a8c3a16 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 8 Oct 2014 21:09:25 +0100 Subject: refactor: consistently put all test classes in the OpenSim.Tests.Common package rather than some in OpenSim.Tests.Common.Mock the separate mock package was not useful and was just another using line to always add --- .../Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/EventQueue') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index fb24f58..16a902d 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs @@ -43,7 +43,6 @@ using OpenSim.Region.CoreModules.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.OptionalModules.World.NPC; using OpenSim.Tests.Common; -using OpenSim.Tests.Common.Mock; namespace OpenSim.Region.ClientStack.Linden.Tests { -- cgit v1.1