From 25a998feb41057f5ad8a6190eae8f14426db1aa8 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 28 Sep 2008 02:57:53 +0000 Subject: * okay.. Now you can do border crossings with the security 'fixed' client.. with EventQueue enabled. * You occasionally loose the event queue if you cross back and forth between the same regions many multiples of times. * But Don't try to teleport! --- .../Modules/Framework/EventQueueGetModule.cs | 57 ++++--- .../Modules/Framework/EventQueueHelper.cs | 185 ++++++++++++++------- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 18 +- 3 files changed, 173 insertions(+), 87 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs index f77a7c0..95cdaed 100644 --- a/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs +++ b/OpenSim/Region/Environment/Modules/Framework/EventQueueGetModule.cs @@ -68,6 +68,7 @@ namespace OpenSim.Region.Environment.Modules.Framework private Dictionary m_ids = new Dictionary(); private Dictionary queues = new Dictionary(); + #region IRegionModule methods public void Initialise(Scene scene, IConfigSource config) @@ -171,6 +172,14 @@ namespace OpenSim.Region.Environment.Modules.Framework private void MakeChildAgent(ScenePresence avatar) { m_log.DebugFormat("[EVENTQUEUE]: Make Child agent {0}.", avatar.UUID); + 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) @@ -209,18 +218,35 @@ namespace OpenSim.Region.Environment.Modules.Framework debug += key.ToString() + "=" + request[key].ToString() + " "; } m_log.DebugFormat(debug, agentID, m_scene.RegionInfo.RegionName); + + Hashtable responsedata = new Hashtable(); 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! element = EventQueueHelper.KeepAliveEvent(); - ScenePresence avatar; - m_scene.TryGetAvatar(agentID, out avatar); + //ScenePresence avatar; + //m_scene.TryGetAvatar(agentID, out avatar); LLSDArray array = new LLSDArray(); array.Add(element); - int thisID = m_ids[agentID]; + int thisID = 0; + lock (m_ids) + thisID = m_ids[agentID]; + + + + if (thisID == -1) + { + responsedata = new Hashtable(); + responsedata["int_response_code"] = 502; + responsedata["content_type"] = "text/plain"; + responsedata["keepalive"] = false; + responsedata["str_response_string"] = ""; + return responsedata; + } + while (queue.Count() > 0) { array.Add(queue.Dequeue(1)); @@ -234,7 +260,7 @@ namespace OpenSim.Region.Environment.Modules.Framework { m_ids[agentID] = thisID + 1; } - Hashtable responsedata = new Hashtable(); + responsedata = new Hashtable(); responsedata["int_response_code"] = 200; responsedata["content_type"] = "application/llsd+xml"; responsedata["keepalive"] = true; @@ -264,7 +290,7 @@ namespace OpenSim.Region.Environment.Modules.Framework { m_ids[agentID] = thisID + 1; } - Hashtable responsedata = new Hashtable(); + responsedata = new Hashtable(); responsedata["int_response_code"] = 200; responsedata["content_type"] = "application/llsd+xml"; responsedata["keepalive"] = true; @@ -273,27 +299,6 @@ namespace OpenSim.Region.Environment.Modules.Framework return responsedata; } - - /* - responsedata["int_response_code"] = 200; - responsedata["content_type"] = "application/xml"; - responsedata["keepalive"] = true; - - responsedata["str_response_string"] = @"eventsbodyAgentDataAgentID - 0fd0e798-a54f-40b1-0000-000000000000SessionIDcc91f1fe-9d52-435d-0000-000000000000 - InfoLookAt0.9869639873504638671875 - -0.16094399988651275634765620Position1.43747997283935546875 - 95.3056030273437557.3480987548828125RegionData - RegionHandleAAPnAAAD8AA=SeedCapability - https://sim7.aditi.lindenlab.com:12043/cap/64015fb3-6fee-9205-0000-000000000000SimIPyA8FSA==SimPort13005message - CrossedRegionid1"; - - */ - //string requestbody = (string)request["requestbody"]; - //LLSD llsdRequest = LLSDParser.DeserializeXml(request); - //System.Console.WriteLine(requestbody); - } } } diff --git a/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs b/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs index 43f1782..cfa0a25 100644 --- a/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs +++ b/OpenSim/Region/Environment/Modules/Framework/EventQueueHelper.cs @@ -1,44 +1,44 @@ -/* - * 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 OpenSim 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; +/* + * 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 OpenSim 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.StructuredData; - -namespace OpenSim.Region.Environment -{ - public class EventQueueHelper - { - private EventQueueHelper() {} // no construction possible, it's an utility class - - public static LLSD EnableSimulator(ulong Handle, IPEndPoint endPoint) - { - LLSDMap llsdSimInfo = new LLSDMap(3); +using OpenMetaverse; +using OpenMetaverse.StructuredData; + +namespace OpenSim.Region.Environment +{ + public class EventQueueHelper + { + private EventQueueHelper() {} // no construction possible, it's an utility class + + public static LLSD EnableSimulator(ulong Handle, IPEndPoint endPoint) + { + LLSDMap llsdSimInfo = new LLSDMap(3); byte[] regionhandle = new byte[8]; int i = 0; @@ -49,24 +49,89 @@ namespace OpenSim.Region.Environment regionhandle[i++] = (byte)((Handle >> 32) % 256); regionhandle[i++] = (byte)((Handle >> 24) % 256); regionhandle[i++] = (byte)((Handle >> 16) % 256); - regionhandle[i++] = (byte)((Handle >> 8) % 256); + regionhandle[i++] = (byte)((Handle >> 8) % 256); regionhandle[i++] = (byte)(Handle % 256); - - llsdSimInfo.Add("Handle", new LLSDBinary(regionhandle)); - llsdSimInfo.Add("IP", new LLSDBinary(endPoint.Address.GetAddressBytes())); - llsdSimInfo.Add("Port", new LLSDInteger(endPoint.Port)); - - LLSDArray arr = new LLSDArray(1); - arr.Add(llsdSimInfo); - - LLSDMap llsdBody = new LLSDMap(1); - llsdBody.Add("SimulatorInfo", arr); - - LLSDMap llsdMessage = new LLSDMap(2); - llsdMessage.Add("message", new LLSDString("EnableSimulator")); - llsdMessage.Add("body", llsdBody); - - return llsdMessage; + + llsdSimInfo.Add("Handle", new LLSDBinary(regionhandle)); + llsdSimInfo.Add("IP", new LLSDBinary(endPoint.Address.GetAddressBytes())); + llsdSimInfo.Add("Port", new LLSDInteger(endPoint.Port)); + + LLSDArray arr = new LLSDArray(1); + arr.Add(llsdSimInfo); + + LLSDMap llsdBody = new LLSDMap(1); + llsdBody.Add("SimulatorInfo", arr); + + LLSDMap llsdMessage = new LLSDMap(2); + llsdMessage.Add("message", new LLSDString("EnableSimulator")); + llsdMessage.Add("body", llsdBody); + + return llsdMessage; + } + public static LLSD CrossRegion(ulong Handle, Vector3 pos, Vector3 lookAt, + IPEndPoint newRegionExternalEndPoint, + string capsURL, UUID AgentID, UUID SessionID) + { + LLSDArray LookAtArr = new LLSDArray(3); + LookAtArr.Add(LLSD.FromReal(lookAt.X)); + LookAtArr.Add(LLSD.FromReal(lookAt.Y)); + LookAtArr.Add(LLSD.FromReal(lookAt.Z)); + + LLSDArray PositionArr = new LLSDArray(3); + PositionArr.Add(LLSD.FromReal(pos.X)); + PositionArr.Add(LLSD.FromReal(pos.Y)); + PositionArr.Add(LLSD.FromReal(pos.Z)); + + LLSDMap InfoMap = new LLSDMap(2); + InfoMap.Add("LookAt", LookAtArr); + InfoMap.Add("Position", PositionArr); + + LLSDArray InfoArr = new LLSDArray(1); + InfoArr.Add(InfoMap); + + LLSDMap AgentDataMap = new LLSDMap(2); + AgentDataMap.Add("AgentID", LLSD.FromUUID(AgentID)); + AgentDataMap.Add("SessionID", LLSD.FromUUID(SessionID)); + + LLSDArray AgentDataArr = new LLSDArray(1); + AgentDataArr.Add(AgentDataMap); + + LLSDMap RegionDataMap = new LLSDMap(4); + byte[] regionhandle = new byte[8]; + + { + int i = 0; + regionhandle[i++] = (byte)((Handle >> 56) % 256); + regionhandle[i++] = (byte)((Handle >> 48) % 256); + regionhandle[i++] = (byte)((Handle >> 40) % 256); + regionhandle[i++] = (byte)((Handle >> 32) % 256); + regionhandle[i++] = (byte)((Handle >> 24) % 256); + regionhandle[i++] = (byte)((Handle >> 16) % 256); + regionhandle[i++] = (byte)((Handle >> 8) % 256); + regionhandle[i++] = (byte)(Handle % 256); + } + + RegionDataMap.Add("RegionHandle", LLSD.FromBinary(regionhandle)); + RegionDataMap.Add("SeedCapability", LLSD.FromString(capsURL)); + RegionDataMap.Add("SimIP", LLSD.FromBinary(newRegionExternalEndPoint.Address.GetAddressBytes())); + RegionDataMap.Add("SimPort", LLSD.FromInteger(newRegionExternalEndPoint.Port)); + + LLSDArray RegionDataArr = new LLSDArray(1); + RegionDataArr.Add(RegionDataMap); + + + + + LLSDMap llsdBody = new LLSDMap(3); + llsdBody.Add("Info", InfoArr); + llsdBody.Add("AgentData", AgentDataArr); + llsdBody.Add("RegionData", RegionDataArr); + + LLSDMap llsdMessage = new LLSDMap(2); + llsdMessage.Add("message", new LLSDString("CrossedRegion")); + llsdMessage.Add("body", llsdBody); + + return llsdMessage; } public static LLSD KeepAliveEvent() { @@ -76,6 +141,6 @@ namespace OpenSim.Region.Environment llsdMessage.Add("body", llsdSimInfo); return llsdMessage; - } - } -} + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 7428612..02859cd 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -37,7 +37,9 @@ using OpenSim.Framework; using OpenSim.Framework.Communications.Cache; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Types; +using OpenSim.Region.Interfaces; using OpenSim.Region.Physics.Manager; +using LLSD = OpenMetaverse.StructuredData.LLSD; namespace OpenSim.Region.Environment.Scenes @@ -2018,8 +2020,22 @@ namespace OpenSim.Region.Environment.Scenes m_log.DebugFormat( "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, m_uuid); - m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, + IEventQueue eq = m_scene.RequestModuleInterface(); + if (eq != null) + { + + LLSD Item = EventQueueHelper.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, + capsPath, UUID, ControllingClient.SessionId); + eq.Enqueue(Item, UUID); + } + else + { + m_controllingClient.CrossRegion(neighbourHandle, newpos, vel, neighbourRegion.ExternalEndPoint, capsPath); + } + + + MakeChildAgent(); // now we have a child agent in this region. Request all interesting data about other (root) agents SendInitialFullUpdateToAllClients(); -- cgit v1.1