aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureServerConnector.cs76
-rw-r--r--OpenSim/Data/IHGTravelingData.cs59
-rw-r--r--OpenSim/Data/MySQL/MySQLHGTravelData.cs80
-rw-r--r--OpenSim/Data/MySQL/Resources/HGTravelStore.migrations18
-rw-r--r--OpenSim/Data/SQLite/Resources/HGTravelStore.migrations18
-rw-r--r--OpenSim/Data/SQLite/SQLiteHGTravelData.cs82
-rw-r--r--OpenSim/Framework/ChildAgentDataUpdate.cs3
-rw-r--r--OpenSim/Framework/Tests/MundaneFrameworkTests.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs1
-rw-r--r--OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs42
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs14
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs7
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs29
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs40
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs63
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs25
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs70
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs5
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs101
-rw-r--r--OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs2
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs71
-rw-r--r--OpenSim/Services/HypergridService/GatekeeperService.cs6
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs208
-rw-r--r--OpenSim/Services/HypergridService/UserAgentServiceBase.cs84
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs12
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs2
30 files changed, 729 insertions, 433 deletions
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureServerConnector.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureServerConnector.cs
new file mode 100644
index 0000000..10ea8ee
--- /dev/null
+++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureServerConnector.cs
@@ -0,0 +1,76 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using Nini.Config;
30using OpenSim.Server.Base;
31using OpenSim.Services.Interfaces;
32using OpenSim.Framework.Servers.HttpServer;
33using OpenSim.Server.Handlers.Base;
34using OpenMetaverse;
35
36namespace OpenSim.Capabilities.Handlers
37{
38 public class UploadBakedTextureServerConnector : ServiceConnector
39 {
40 private IAssetService m_AssetService;
41 private string m_ConfigName = "CapsService";
42
43 public UploadBakedTextureServerConnector(IConfigSource config, IHttpServer server, string configName) :
44 base(config, server, configName)
45 {
46 if (configName != String.Empty)
47 m_ConfigName = configName;
48
49 IConfig serverConfig = config.Configs[m_ConfigName];
50 if (serverConfig == null)
51 throw new Exception(String.Format("No section '{0}' in config file", m_ConfigName));
52
53 string assetService = serverConfig.GetString("AssetService", String.Empty);
54
55 if (assetService == String.Empty)
56 throw new Exception("No AssetService in config file");
57
58 Object[] args = new Object[] { config };
59 m_AssetService =
60 ServerUtils.LoadPlugin<IAssetService>(assetService, args);
61
62 if (m_AssetService == null)
63 throw new Exception(String.Format("Failed to load AssetService from {0}; config is {1}", assetService, m_ConfigName));
64
65 // NEED TO FIX THIS
66 OpenSim.Framework.Capabilities.Caps caps = new OpenSim.Framework.Capabilities.Caps(server, "", server.Port, "", UUID.Zero, "");
67 server.AddStreamHandler(new RestStreamHandler(
68 "POST",
69 "/CAPS/UploadBakedTexture/",
70 new UploadBakedTextureHandler(caps, m_AssetService, true).UploadBakedTexture,
71 "UploadBakedTexture",
72 "Upload Baked Texture Capability"));
73
74 }
75 }
76} \ No newline at end of file
diff --git a/OpenSim/Data/IHGTravelingData.cs b/OpenSim/Data/IHGTravelingData.cs
new file mode 100644
index 0000000..452af7b
--- /dev/null
+++ b/OpenSim/Data/IHGTravelingData.cs
@@ -0,0 +1,59 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Data
34{
35 // This MUST be a ref type!
36 public class HGTravelingData
37 {
38 public UUID SessionID;
39 public UUID UserID;
40 public Dictionary<string, string> Data;
41
42 public HGTravelingData()
43 {
44 Data = new Dictionary<string, string>();
45 }
46 }
47
48 /// <summary>
49 /// An interface for connecting to the user grid datastore
50 /// </summary>
51 public interface IHGTravelingData
52 {
53 HGTravelingData Get(UUID sessionID);
54 HGTravelingData[] GetSessions(UUID userID);
55 bool Store(HGTravelingData data);
56 bool Delete(UUID sessionID);
57 void DeleteOld();
58 }
59} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/MySQLHGTravelData.cs b/OpenSim/Data/MySQL/MySQLHGTravelData.cs
new file mode 100644
index 0000000..e81b880
--- /dev/null
+++ b/OpenSim/Data/MySQL/MySQLHGTravelData.cs
@@ -0,0 +1,80 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using MySql.Data.MySqlClient;
37
38namespace OpenSim.Data.MySQL
39{
40 /// <summary>
41 /// A MySQL Interface for user grid data
42 /// </summary>
43 public class MySQLHGTravelData : MySQLGenericTableHandler<HGTravelingData>, IHGTravelingData
44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 public MySQLHGTravelData(string connectionString, string realm) : base(connectionString, realm, "HGTravelStore") { }
48
49 public HGTravelingData Get(UUID sessionID)
50 {
51 HGTravelingData[] ret = Get("SessionID", sessionID.ToString());
52
53 if (ret.Length == 0)
54 return null;
55
56 return ret[0];
57 }
58
59 public HGTravelingData[] GetSessions(UUID userID)
60 {
61 return base.Get("UserID", userID.ToString());
62 }
63
64 public bool Delete(UUID sessionID)
65 {
66 return Delete("SessionID", sessionID.ToString());
67 }
68
69 public void DeleteOld()
70 {
71 using (MySqlCommand cmd = new MySqlCommand())
72 {
73 cmd.CommandText = String.Format("delete from {0} where TMStamp < NOW() - INTERVAL 2 DAY", m_Realm);
74
75 ExecuteNonQuery(cmd);
76 }
77
78 }
79 }
80} \ No newline at end of file
diff --git a/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations
new file mode 100644
index 0000000..b4e4422
--- /dev/null
+++ b/OpenSim/Data/MySQL/Resources/HGTravelStore.migrations
@@ -0,0 +1,18 @@
1:VERSION 1 # --------------------------
2
3BEGIN;
4
5CREATE TABLE `hg_traveling_data` (
6 `SessionID` VARCHAR(36) NOT NULL,
7 `UserID` VARCHAR(36) NOT NULL,
8 `GridExternalName` VARCHAR(255) NOT NULL DEFAULT '',
9 `ServiceToken` VARCHAR(255) NOT NULL DEFAULT '',
10 `ClientIPAddress` VARCHAR(16) NOT NULL DEFAULT '',
11 `MyIPAddress` VARCHAR(16) NOT NULL DEFAULT '',
12 `TMStamp` timestamp NOT NULL,
13 PRIMARY KEY (`SessionID`),
14 KEY (`UserID`)
15) ENGINE=InnoDB;
16
17COMMIT;
18
diff --git a/OpenSim/Data/SQLite/Resources/HGTravelStore.migrations b/OpenSim/Data/SQLite/Resources/HGTravelStore.migrations
new file mode 100644
index 0000000..2e73caa
--- /dev/null
+++ b/OpenSim/Data/SQLite/Resources/HGTravelStore.migrations
@@ -0,0 +1,18 @@
1:VERSION 1 # --------------------------
2
3BEGIN;
4
5CREATE TABLE hg_traveling_data (
6 SessionID VARCHAR(36) NOT NULL,
7 UserID VARCHAR(36) NOT NULL,
8 GridExternalName VARCHAR(255) NOT NULL DEFAULT '',
9 ServiceToken VARCHAR(255) NOT NULL DEFAULT '',
10 ClientIPAddress VARCHAR(16) NOT NULL DEFAULT '',
11 MyIPAddress VARCHAR(16) NOT NULL DEFAULT '',
12 TMStamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
13 PRIMARY KEY (`SessionID`),
14 KEY (`UserID`)
15) ENGINE=InnoDB;
16
17COMMIT;
18
diff --git a/OpenSim/Data/SQLite/SQLiteHGTravelData.cs b/OpenSim/Data/SQLite/SQLiteHGTravelData.cs
new file mode 100644
index 0000000..db288b2
--- /dev/null
+++ b/OpenSim/Data/SQLite/SQLiteHGTravelData.cs
@@ -0,0 +1,82 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Data;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using Mono.Data.Sqlite;
37
38namespace OpenSim.Data.SQLite
39{
40 /// <summary>
41 /// A SQL Interface for user grid data
42 /// </summary>
43 public class SQLiteHGTravelData : SQLiteGenericTableHandler<HGTravelingData>, IHGTravelingData
44 {
45// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 public SQLiteHGTravelData(string connectionString, string realm)
48 : base(connectionString, realm, "HGTravelStore") {}
49
50 public HGTravelingData Get(UUID sessionID)
51 {
52 HGTravelingData[] ret = Get("SessionID", sessionID.ToString());
53
54 if (ret.Length == 0)
55 return null;
56
57 return ret[0];
58 }
59
60 public HGTravelingData[] GetSessions(UUID userID)
61 {
62 return base.Get("UserID", userID.ToString());
63 }
64
65 public bool Delete(UUID sessionID)
66 {
67 return Delete("SessionID", sessionID.ToString());
68 }
69
70 public void DeleteOld()
71 {
72 using (SqliteCommand cmd = new SqliteCommand())
73 {
74 cmd.CommandText = String.Format("delete from {0} where TMStamp < datetime('now', '-2 day') ", m_Realm);
75
76 DoQuery(cmd);
77 }
78
79 }
80
81 }
82} \ No newline at end of file
diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs
index 8c32734..b399a58 100644
--- a/OpenSim/Framework/ChildAgentDataUpdate.cs
+++ b/OpenSim/Framework/ChildAgentDataUpdate.cs
@@ -171,9 +171,10 @@ namespace OpenSim.Framework
171 /// Soon to be decommissioned 171 /// Soon to be decommissioned
172 /// </summary> 172 /// </summary>
173 /// <param name="cAgent"></param> 173 /// <param name="cAgent"></param>
174 public void CopyFrom(ChildAgentDataUpdate cAgent) 174 public void CopyFrom(ChildAgentDataUpdate cAgent, UUID sid)
175 { 175 {
176 AgentID = new UUID(cAgent.AgentID); 176 AgentID = new UUID(cAgent.AgentID);
177 SessionID = sid;
177 178
178 // next: ??? 179 // next: ???
179 Size = new Vector3(); 180 Size = new Vector3();
diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
index 0fbdaf3..08f2af5 100644
--- a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
+++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs
@@ -100,7 +100,7 @@ namespace OpenSim.Framework.Tests
100 cadu.AVHeight = Size1.Z; 100 cadu.AVHeight = Size1.Z;
101 101
102 AgentPosition position2 = new AgentPosition(); 102 AgentPosition position2 = new AgentPosition();
103 position2.CopyFrom(cadu); 103 position2.CopyFrom(cadu, position1.SessionID);
104 104
105 Assert.IsTrue( 105 Assert.IsTrue(
106 position2.AgentID == position1.AgentID 106 position2.AgentID == position1.AgentID
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 8a1f267..77b07ed 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1512,6 +1512,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1512 { 1512 {
1513 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code); 1513 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code);
1514 bool tp = (aCircuit.teleportFlags > 0); 1514 bool tp = (aCircuit.teleportFlags > 0);
1515 // Let's delay this for TP agents, otherwise the viewer doesn't know where to get resources from
1515 if (!tp) 1516 if (!tp)
1516 client.SceneAgent.SendInitialDataToMe(); 1517 client.SceneAgent.SendInitialDataToMe();
1517 } 1518 }
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index 2fc3b1c..6ce6227 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -127,25 +127,27 @@ namespace OpenSim.Region.CoreModules.Framework
127 Caps caps; 127 Caps caps;
128 String capsObjectPath = GetCapsPath(agentId); 128 String capsObjectPath = GetCapsPath(agentId);
129 129
130 if (m_capsObjects.ContainsKey(circuitCode)) 130 lock (m_capsObjects)
131 { 131 {
132 Caps oldCaps = m_capsObjects[circuitCode]; 132 if (m_capsObjects.ContainsKey(circuitCode))
133 133 {
134 m_log.DebugFormat( 134 Caps oldCaps = m_capsObjects[circuitCode];
135 "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ", 135
136 agentId, oldCaps.CapsObjectPath, capsObjectPath); 136 m_log.DebugFormat(
137 // This should not happen. The caller code is confused. We need to fix that. 137 "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ",
138 // CAPs can never be reregistered, or the client will be confused. 138 agentId, oldCaps.CapsObjectPath, capsObjectPath);
139 // Hence this return here. 139 // This should not happen. The caller code is confused. We need to fix that.
140 //return; 140 // CAPs can never be reregistered, or the client will be confused.
141 } 141 // Hence this return here.
142 142 //return;
143 caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, 143 }
144 (MainServer.Instance == null) ? 0: MainServer.Instance.Port,
145 capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
146 144
147 m_capsObjects[circuitCode] = caps; 145 caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
146 (MainServer.Instance == null) ? 0: MainServer.Instance.Port,
147 capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
148 148
149 m_capsObjects[circuitCode] = caps;
150 }
149 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); 151 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
150 } 152 }
151 153
@@ -301,7 +303,7 @@ namespace OpenSim.Region.CoreModules.Framework
301 { 303 {
302 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) 304 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects)
303 { 305 {
304 caps.AppendFormat("** User {0}:\n", kvp.Key); 306 caps.AppendFormat("** Circuit {0}:\n", kvp.Key);
305 307
306 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) 308 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
307 { 309 {
@@ -345,7 +347,7 @@ namespace OpenSim.Region.CoreModules.Framework
345 347
346 private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName) 348 private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName)
347 { 349 {
348 /* 350 /*
349 sb.AppendFormat("Capability name {0}\n", capName); 351 sb.AppendFormat("Capability name {0}\n", capName);
350 352
351 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 353 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
@@ -387,7 +389,7 @@ namespace OpenSim.Region.CoreModules.Framework
387 389
388 private void BuildSummaryStatsByCapReport(StringBuilder sb) 390 private void BuildSummaryStatsByCapReport(StringBuilder sb)
389 { 391 {
390 /* 392 /*
391 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 393 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
392 cdt.AddColumn("Name", 34); 394 cdt.AddColumn("Name", 34);
393 cdt.AddColumn("Req Received", 12); 395 cdt.AddColumn("Req Received", 12);
@@ -434,6 +436,7 @@ namespace OpenSim.Region.CoreModules.Framework
434 436
435 private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams) 437 private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams)
436 { 438 {
439 /*
437 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) 440 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
438 return; 441 return;
439 442
@@ -464,6 +467,7 @@ namespace OpenSim.Region.CoreModules.Framework
464 } 467 }
465 468
466 MainConsole.Instance.Output(sb.ToString()); 469 MainConsole.Instance.Output(sb.ToString());
470 */
467 } 471 }
468 472
469 private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp) 473 private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp)
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index b9c88d4..a3c539d 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -822,7 +822,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
822 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.", 822 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.",
823 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); 823 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
824 824
825 Fail(sp, finalDestination, logout, "Connection between viewer and destination region could not be established."); 825 Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established.");
826 return; 826 return;
827 } 827 }
828 828
@@ -834,7 +834,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
834 "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request", 834 "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request",
835 sp.Name, finalDestination.RegionName, sp.Scene.Name); 835 sp.Name, finalDestination.RegionName, sp.Scene.Name);
836 836
837 CleanupFailedInterRegionTeleport(sp, finalDestination); 837 CleanupFailedInterRegionTeleport(sp, currentAgentCircuit.SessionID.ToString(), finalDestination);
838 838
839 return; 839 return;
840 } 840 }
@@ -878,7 +878,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
878 "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.", 878 "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.",
879 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); 879 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
880 880
881 Fail(sp, finalDestination, logout, "Destination region did not signal teleport completion."); 881 Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Destination region did not signal teleport completion.");
882 882
883 return; 883 return;
884 } 884 }
@@ -932,7 +932,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
932 /// <remarks> 932 /// <remarks>
933 /// <param name='sp'> </param> 933 /// <param name='sp'> </param>
934 /// <param name='finalDestination'></param> 934 /// <param name='finalDestination'></param>
935 protected virtual void CleanupFailedInterRegionTeleport(ScenePresence sp, GridRegion finalDestination) 935 protected virtual void CleanupFailedInterRegionTeleport(ScenePresence sp, string auth_token, GridRegion finalDestination)
936 { 936 {
937 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); 937 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
938 938
@@ -943,7 +943,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
943 943
944 // Finally, kill the agent we just created at the destination. 944 // Finally, kill the agent we just created at the destination.
945 // XXX: Possibly this should be done asynchronously. 945 // XXX: Possibly this should be done asynchronously.
946 Scene.SimulationService.CloseAgent(finalDestination, sp.UUID); 946 Scene.SimulationService.CloseAgent(finalDestination, sp.UUID, auth_token);
947 } 947 }
948 948
949 /// <summary> 949 /// <summary>
@@ -953,9 +953,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
953 /// <param name='finalDestination'></param> 953 /// <param name='finalDestination'></param>
954 /// <param name='logout'></param> 954 /// <param name='logout'></param>
955 /// <param name='reason'>Human readable reason for teleport failure. Will be sent to client.</param> 955 /// <param name='reason'>Human readable reason for teleport failure. Will be sent to client.</param>
956 protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout, string reason) 956 protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout, string auth_code, string reason)
957 { 957 {
958 CleanupFailedInterRegionTeleport(sp, finalDestination); 958 CleanupFailedInterRegionTeleport(sp, auth_code, finalDestination);
959 959
960 m_interRegionTeleportFailures.Value++; 960 m_interRegionTeleportFailures.Value++;
961 961
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 975fccf..1cf1884 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -207,6 +207,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
207 { 207 {
208 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); 208 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
209 m_UAS = scene.RequestModuleInterface<IUserAgentService>(); 209 m_UAS = scene.RequestModuleInterface<IUserAgentService>();
210 if (m_UAS == null)
211 m_UAS = new UserAgentServiceConnector(m_ThisHomeURI);
212
210 } 213 }
211 } 214 }
212 215
@@ -571,12 +574,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
571 if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) 574 if (uMan != null && uMan.IsLocalGridUser(obj.AgentId))
572 { 575 {
573 // local grid user 576 // local grid user
577 m_UAS.LogoutAgent(obj.AgentId, obj.SessionId);
574 return; 578 return;
575 } 579 }
576 580
577 AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); 581 AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
578 582 if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("HomeURI"))
579 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
580 { 583 {
581 string url = aCircuit.ServiceURLs["HomeURI"].ToString(); 584 string url = aCircuit.ServiceURLs["HomeURI"].ToString();
582 IUserAgentService security = new UserAgentServiceConnector(url); 585 IUserAgentService security = new UserAgentServiceConnector(url);
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index e4aa7bc..8207fb9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -250,26 +250,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
250 return true; 250 return true;
251 } 251 }
252 252
253 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
254 {
255 agent = null;
256
257 if (destination == null)
258 return false;
259
260 if (m_scenes.ContainsKey(destination.RegionID))
261 {
262// m_log.DebugFormat(
263// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
264// s.RegionInfo.RegionName, destination.RegionHandle);
265
266 return m_scenes[destination.RegionID].IncomingRetrieveRootAgent(id, out agent);
267 }
268
269 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
270 return false;
271 }
272
273 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason) 253 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason)
274 { 254 {
275 reason = "Communications failure"; 255 reason = "Communications failure";
@@ -306,12 +286,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
306 return false; 286 return false;
307 } 287 }
308 288
309 public bool CloseChildAgent(GridRegion destination, UUID id) 289 public bool CloseAgent(GridRegion destination, UUID id, string auth_token)
310 {
311 return CloseAgent(destination, id);
312 }
313
314 public bool CloseAgent(GridRegion destination, UUID id)
315 { 290 {
316 if (destination == null) 291 if (destination == null)
317 return false; 292 return false;
@@ -322,7 +297,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
322// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", 297// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
323// s.RegionInfo.RegionName, destination.RegionHandle); 298// s.RegionInfo.RegionName, destination.RegionHandle);
324 299
325 m_scenes[destination.RegionID].IncomingCloseAgent(id, false); 300 m_scenes[destination.RegionID].IncomingCloseAgent(id, false, auth_token);
326 return true; 301 return true;
327 } 302 }
328 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); 303 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index f7dae59..a1ab3e3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -212,24 +212,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
212 return m_remoteConnector.UpdateAgent(destination, cAgentData); 212 return m_remoteConnector.UpdateAgent(destination, cAgentData);
213 } 213 }
214 214
215 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
216 {
217 agent = null;
218
219 if (destination == null)
220 return false;
221
222 // Try local first
223 if (m_localBackend.RetrieveAgent(destination, id, out agent))
224 return true;
225
226 // else do the remote thing
227 if (!m_localBackend.IsLocalRegion(destination.RegionID))
228 return m_remoteConnector.RetrieveAgent(destination, id, out agent);
229
230 return false;
231 }
232
233 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason) 215 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason)
234 { 216 {
235 reason = "Communications failure"; 217 reason = "Communications failure";
@@ -262,34 +244,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
262 return false; 244 return false;
263 } 245 }
264 246
265 public bool CloseChildAgent(GridRegion destination, UUID id) 247 public bool CloseAgent(GridRegion destination, UUID id, string auth_token)
266 {
267 if (destination == null)
268 return false;
269
270 // Try local first
271 if (m_localBackend.CloseChildAgent(destination, id))
272 return true;
273
274 // else do the remote thing
275 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
276 return m_remoteConnector.CloseChildAgent(destination, id);
277
278 return false;
279 }
280
281 public bool CloseAgent(GridRegion destination, UUID id)
282 { 248 {
283 if (destination == null) 249 if (destination == null)
284 return false; 250 return false;
285 251
286 // Try local first 252 // Try local first
287 if (m_localBackend.CloseAgent(destination, id)) 253 if (m_localBackend.CloseAgent(destination, id, auth_token))
288 return true; 254 return true;
289 255
290 // else do the remote thing 256 // else do the remote thing
291 if (!m_localBackend.IsLocalRegion(destination.RegionID)) 257 if (!m_localBackend.IsLocalRegion(destination.RegionID))
292 return m_remoteConnector.CloseAgent(destination, id); 258 return m_remoteConnector.CloseAgent(destination, id, auth_token);
293 259
294 return false; 260 return false;
295 } 261 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d293a8b..c132c5d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3609,7 +3609,7 @@ namespace OpenSim.Region.Framework.Scenes
3609 regions.Remove(RegionInfo.RegionHandle); 3609 regions.Remove(RegionInfo.RegionHandle);
3610 3610
3611 // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours. 3611 // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours.
3612 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3612 m_sceneGridService.SendCloseChildAgentConnections(agentID, acd.SessionID.ToString(), regions);
3613 } 3613 }
3614 3614
3615 m_eventManager.TriggerClientClosed(agentID, this); 3615 m_eventManager.TriggerClientClosed(agentID, this);
@@ -3856,7 +3856,6 @@ namespace OpenSim.Region.Framework.Scenes
3856 m_log.WarnFormat( 3856 m_log.WarnFormat(
3857 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", 3857 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3858 sp.Name, sp.UUID, RegionInfo.RegionName); 3858 sp.Name, sp.UUID, RegionInfo.RegionName);
3859
3860 3859
3861 if (sp.ControllingClient != null) 3860 if (sp.ControllingClient != null)
3862 sp.ControllingClient.Close(true, true); 3861 sp.ControllingClient.Close(true, true);
@@ -4395,10 +4394,16 @@ namespace OpenSim.Region.Framework.Scenes
4395 4394
4396 if (childAgentUpdate != null) 4395 if (childAgentUpdate != null)
4397 { 4396 {
4397 if (cAgentData.SessionID != childAgentUpdate.ControllingClient.SessionId)
4398 {
4399 m_log.WarnFormat("[SCENE]: Attempt to update agent {0} with invalid session id {1} (possibly from simulator in older version; tell them to update).", childAgentUpdate.UUID, cAgentData.SessionID);
4400 Console.WriteLine(String.Format("[SCENE]: Attempt to update agent {0} ({1}) with invalid session id {2}",
4401 childAgentUpdate.UUID, childAgentUpdate.ControllingClient.SessionId, cAgentData.SessionID));
4402 }
4403
4398 childAgentUpdate.ChildAgentDataUpdate(cAgentData); 4404 childAgentUpdate.ChildAgentDataUpdate(cAgentData);
4399 return true; 4405 return true;
4400 } 4406 }
4401
4402 return false; 4407 return false;
4403 } 4408 }
4404 4409
@@ -4414,20 +4419,24 @@ namespace OpenSim.Region.Framework.Scenes
4414 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); 4419 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID);
4415 if (childAgentUpdate != null) 4420 if (childAgentUpdate != null)
4416 { 4421 {
4417 // I can't imagine *yet* why we would get an update if the agent is a root agent.. 4422 if (childAgentUpdate.ControllingClient.SessionId == cAgentData.SessionID)
4418 // however to avoid a race condition crossing borders.. 4423 {
4419 if (childAgentUpdate.IsChildAgent) 4424 // I can't imagine *yet* why we would get an update if the agent is a root agent..
4420 { 4425 // however to avoid a race condition crossing borders..
4421 uint rRegionX = (uint)(cAgentData.RegionHandle >> 40); 4426 if (childAgentUpdate.IsChildAgent)
4422 uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8); 4427 {
4423 uint tRegionX = RegionInfo.RegionLocX; 4428 uint rRegionX = (uint)(cAgentData.RegionHandle >> 40);
4424 uint tRegionY = RegionInfo.RegionLocY; 4429 uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8);
4425 //Send Data to ScenePresence 4430 uint tRegionX = RegionInfo.RegionLocX;
4426 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); 4431 uint tRegionY = RegionInfo.RegionLocY;
4427 // Not Implemented: 4432 //Send Data to ScenePresence
4428 //TODO: Do we need to pass the message on to one of our neighbors? 4433 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY);
4434 // Not Implemented:
4435 //TODO: Do we need to pass the message on to one of our neighbors?
4436 }
4429 } 4437 }
4430 4438 else
4439 m_log.WarnFormat("[SCENE]: Attempt at updating position of agent {0} with invalid session id {1}", childAgentUpdate.UUID, cAgentData.SessionID);
4431 return true; 4440 return true;
4432 } 4441 }
4433 4442
@@ -4470,6 +4479,25 @@ namespace OpenSim.Region.Framework.Scenes
4470 4479
4471 return false; 4480 return false;
4472 } 4481 }
4482 /// <summary>
4483 /// Authenticated close (via network)
4484 /// </summary>
4485 /// <param name="agentID"></param>
4486 /// <param name="force"></param>
4487 /// <param name="auth_token"></param>
4488 /// <returns></returns>
4489 public bool IncomingCloseAgent(UUID agentID, bool force, string auth_token)
4490 {
4491 //m_log.DebugFormat("[SCENE]: Processing incoming close agent {0} in region {1} with auth_token {2}", agentID, RegionInfo.RegionName, auth_token);
4492
4493 // Check that the auth_token is valid
4494 AgentCircuitData acd = AuthenticateHandler.GetAgentCircuitData(agentID);
4495 if (acd != null && acd.SessionID.ToString() == auth_token)
4496 return IncomingCloseAgent(agentID, force);
4497 else
4498 m_log.ErrorFormat("[SCENE]: Request to close agent {0} with invalid authorization token {1}", agentID, auth_token);
4499 return false;
4500 }
4473 4501
4474 public bool IncomingCloseAgent(UUID agentID) 4502 public bool IncomingCloseAgent(UUID agentID)
4475 { 4503 {
@@ -4492,7 +4520,6 @@ namespace OpenSim.Region.Framework.Scenes
4492 public bool IncomingCloseAgent(UUID agentID, bool force) 4520 public bool IncomingCloseAgent(UUID agentID, bool force)
4493 { 4521 {
4494 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4522 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
4495
4496 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4523 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4497 if (presence != null) 4524 if (presence != null)
4498 { 4525 {
@@ -4500,7 +4527,7 @@ namespace OpenSim.Region.Framework.Scenes
4500 return true; 4527 return true;
4501 } 4528 }
4502 4529
4503 // Agent not here 4530 // Agent not here
4504 return false; 4531 return false;
4505 } 4532 }
4506 4533
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index df61dde..52f46f2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -200,7 +200,7 @@ namespace OpenSim.Region.Framework.Scenes
200 /// This Closes child agents on neighboring regions 200 /// This Closes child agents on neighboring regions
201 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 201 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
202 /// </summary> 202 /// </summary>
203 protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle) 203 protected void SendCloseChildAgent(UUID agentID, ulong regionHandle, string auth_token)
204 { 204 {
205 // let's do our best, but there's not much we can do if the neighbour doesn't accept. 205 // let's do our best, but there's not much we can do if the neighbour doesn't accept.
206 206
@@ -209,24 +209,25 @@ namespace OpenSim.Region.Framework.Scenes
209 Utils.LongToUInts(regionHandle, out x, out y); 209 Utils.LongToUInts(regionHandle, out x, out y);
210 210
211 GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); 211 GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y);
212 m_scene.SimulationService.CloseChildAgent(destination, agentID);
213 }
214 212
215 private void SendCloseChildAgentCompleted(IAsyncResult iar) 213 m_log.DebugFormat(
216 { 214 "[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName);
217 SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState; 215
218 icon.EndInvoke(iar); 216 m_scene.SimulationService.CloseAgent(destination, agentID, auth_token);
219 } 217 }
220 218
221 public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) 219 /// <summary>
220 /// Closes a child agents in a collection of regions. Does so asynchronously
221 /// so that the caller doesn't wait.
222 /// </summary>
223 /// <param name="agentID"></param>
224 /// <param name="regionslst"></param>
225 public void SendCloseChildAgentConnections(UUID agentID, string auth_code, List<ulong> regionslst)
222 { 226 {
223 foreach (ulong handle in regionslst) 227 foreach (ulong handle in regionslst)
224 { 228 {
225 ulong handleCopy = handle; 229 ulong handleCopy = handle;
226 SendCloseChildAgentDelegate d = SendCloseChildAgentAsync; 230 Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); });
227 d.BeginInvoke(agentID, handleCopy,
228 SendCloseChildAgentCompleted,
229 d);
230 } 231 }
231 } 232 }
232 233
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 2594b1b..59a453a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4704,50 +4704,6 @@ namespace OpenSim.Region.Framework.Scenes
4704 } 4704 }
4705 4705
4706 /// <summary> 4706 /// <summary>
4707 /// Subscribe for physics collision events if needed for scripts and sounds
4708 /// </summary>
4709 public void SubscribeForCollisionEvents()
4710 {
4711 PhysicsActor pa = PhysActor;
4712
4713 if (pa != null)
4714 {
4715 if (
4716 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4717 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4718 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4719 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4720 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4721 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4722 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) ||
4723 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4724 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4725 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4726 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4727 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4728 (CollisionSound != UUID.Zero)
4729 )
4730 {
4731 if (!pa.SubscribedEvents())
4732 {
4733 // If not already subscribed for event, set up for a collision event.
4734 pa.OnCollisionUpdate += PhysicsCollision;
4735 pa.SubscribeEvents(1000);
4736 }
4737 }
4738 else
4739 {
4740 // There is no need to be subscribed to collisions so, if subscribed, remove subscription
4741 if (pa.SubscribedEvents())
4742 {
4743 pa.OnCollisionUpdate -= PhysicsCollision;
4744 pa.UnSubscribeEvents();
4745 }
4746 }
4747 }
4748 }
4749
4750 /// <summary>
4751 /// Adds this part to the physics scene. 4707 /// Adds this part to the physics scene.
4752 /// and sets the PhysActor property 4708 /// and sets the PhysActor property
4753 /// </summary> 4709 /// </summary>
@@ -5205,7 +5161,31 @@ namespace OpenSim.Region.Framework.Scenes
5205 { 5161 {
5206 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; 5162 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
5207 } 5163 }
5208 5164/*
5165 PhysicsActor pa = PhysActor;
5166 if (pa != null)
5167 {
5168 if (
5169// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
5170// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
5171// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
5172// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
5173// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
5174// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
5175 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
5176 )
5177 {
5178 // subscribe to physics updates.
5179 pa.OnCollisionUpdate += PhysicsCollision;
5180 pa.SubscribeEvents(1000);
5181 }
5182 else
5183 {
5184 pa.UnSubscribeEvents();
5185 pa.OnCollisionUpdate -= PhysicsCollision;
5186 }
5187 }
5188 */
5209 UpdatePhysicsSubscribedEvents(); 5189 UpdatePhysicsSubscribedEvents();
5210 5190
5211 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) 5191 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4ae0eb1..6e4ac98 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1151,9 +1151,9 @@ namespace OpenSim.Region.Framework.Scenes
1151 1151
1152 MovementFlag = 0; 1152 MovementFlag = 0;
1153 1153
1154 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1154 // DIVA NOTE: I moved TriggerOnMakeRootAgent out of here and into the end of
1155 1155 // CompleteMovement. We don't want modules doing heavy computation before CompleteMovement
1156 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; 1156 // is over.
1157 } 1157 }
1158 1158
1159 public int GetStateSource() 1159 public int GetStateSource()
@@ -1519,10 +1519,15 @@ namespace OpenSim.Region.Framework.Scenes
1519 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1519 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1520 MakeRootAgent(AbsolutePosition, flying); 1520 MakeRootAgent(AbsolutePosition, flying);
1521 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1521 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1522 // Remember in HandleUseCircuitCode, we delayed this to here
1523 // This will also send the initial data to clients when TP to a neighboring region.
1524 // Not ideal, but until we know we're TP-ing from a neighboring region, there's not much we can do
1525 if (m_teleportFlags > 0)
1526 SendInitialDataToMe();
1522 1527
1523// m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); 1528// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1524 1529
1525 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1530 if (!string.IsNullOrEmpty(m_callbackURI))
1526 { 1531 {
1527 // We cannot sleep here since this would hold up the inbound packet processing thread, as 1532 // We cannot sleep here since this would hold up the inbound packet processing thread, as
1528 // CompleteMovement() is executed synchronously. However, it might be better to delay the release 1533 // CompleteMovement() is executed synchronously. However, it might be better to delay the release
@@ -1550,9 +1555,6 @@ namespace OpenSim.Region.Framework.Scenes
1550 // Create child agents in neighbouring regions 1555 // Create child agents in neighbouring regions
1551 if (openChildAgents && !IsChildAgent) 1556 if (openChildAgents && !IsChildAgent)
1552 { 1557 {
1553 // Remember in HandleUseCircuitCode, we delayed this to here
1554 SendInitialDataToMe();
1555
1556 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); 1558 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1557 if (m_agentTransfer != null) 1559 if (m_agentTransfer != null)
1558 m_agentTransfer.EnableChildAgents(this); 1560 m_agentTransfer.EnableChildAgents(this);
@@ -1575,6 +1577,11 @@ namespace OpenSim.Region.Framework.Scenes
1575// m_log.DebugFormat( 1577// m_log.DebugFormat(
1576// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1578// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
1577// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1579// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
1580
1581 // DIVA NOTE: moved this here from MakeRoot. We don't want modules making heavy
1582 // computations before CompleteMovement is over
1583 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1584
1578 } 1585 }
1579 1586
1580 /// <summary> 1587 /// <summary>
@@ -2886,11 +2893,12 @@ namespace OpenSim.Region.Framework.Scenes
2886 SendOtherAgentsAppearanceToMe(); 2893 SendOtherAgentsAppearanceToMe();
2887 2894
2888 EntityBase[] entities = Scene.Entities.GetEntities(); 2895 EntityBase[] entities = Scene.Entities.GetEntities();
2889 foreach(EntityBase e in entities) 2896 foreach (EntityBase e in entities)
2890 { 2897 {
2891 if (e != null && e is SceneObjectGroup) 2898 if (e != null && e is SceneObjectGroup)
2892 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); 2899 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient);
2893 } 2900 }
2901
2894 }); 2902 });
2895 } 2903 }
2896 2904
@@ -3116,7 +3124,7 @@ namespace OpenSim.Region.Framework.Scenes
3116 cadu.Velocity = Velocity; 3124 cadu.Velocity = Velocity;
3117 3125
3118 AgentPosition agentpos = new AgentPosition(); 3126 AgentPosition agentpos = new AgentPosition();
3119 agentpos.CopyFrom(cadu); 3127 agentpos.CopyFrom(cadu, ControllingClient.SessionId);
3120 3128
3121 // Let's get this out of the update loop 3129 // Let's get this out of the update loop
3122 Util.FireAndForget(delegate { m_scene.SendOutChildAgentUpdates(agentpos, this); }); 3130 Util.FireAndForget(delegate { m_scene.SendOutChildAgentUpdates(agentpos, this); });
@@ -3355,7 +3363,11 @@ namespace OpenSim.Region.Framework.Scenes
3355 { 3363 {
3356 m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); 3364 m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents");
3357 3365
3358 m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions); 3366 AgentCircuitData acd = Scene.AuthenticateHandler.GetAgentCircuitData(UUID);
3367 string auth = string.Empty;
3368 if (acd != null)
3369 auth = acd.SessionID.ToString();
3370 m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, auth, byebyeRegions);
3359 } 3371 }
3360 3372
3361 foreach (ulong handle in byebyeRegions) 3373 foreach (ulong handle in byebyeRegions)
@@ -3456,6 +3468,7 @@ namespace OpenSim.Region.Framework.Scenes
3456 3468
3457 cAgent.AgentID = UUID; 3469 cAgent.AgentID = UUID;
3458 cAgent.RegionID = Scene.RegionInfo.RegionID; 3470 cAgent.RegionID = Scene.RegionInfo.RegionID;
3471 cAgent.SessionID = ControllingClient.SessionId;
3459 3472
3460 cAgent.Position = AbsolutePosition; 3473 cAgent.Position = AbsolutePosition;
3461 cAgent.Velocity = m_velocity; 3474 cAgent.Velocity = m_velocity;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
index 5a72239..5df9aba 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
@@ -112,6 +112,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
112 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero); 112 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
113 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2))); 113 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
114 moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; 114 moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
115 moveArgs.SessionID = acd.SessionID;
115 116
116 originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs); 117 originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
117 118
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index a6db2e5..44a7c14 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -353,12 +353,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
353 // Position of a sensor in a child prim attached to an avatar 353 // Position of a sensor in a child prim attached to an avatar
354 // will be still wrong. 354 // will be still wrong.
355 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 355 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
356 fromRegionPos = avatar.AbsolutePosition;
357 q = avatar.Rotation;
358 356
359 // Don't proceed if the avatar for this attachment has since been removed from the scene. 357 // Don't proceed if the avatar for this attachment has since been removed from the scene.
360 if (avatar == null) 358 if (avatar == null)
361 return sensedEntities; 359 return sensedEntities;
360
361 fromRegionPos = avatar.AbsolutePosition;
362 q = avatar.Rotation;
362 } 363 }
363 364
364 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); 365 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
@@ -487,6 +488,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
487 // Position of a sensor in a child prim attached to an avatar 488 // Position of a sensor in a child prim attached to an avatar
488 // will be still wrong. 489 // will be still wrong.
489 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 490 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
491
492 // Don't proceed if the avatar for this attachment has since been removed from the scene.
490 if (avatar == null) 493 if (avatar == null)
491 return sensedEntities; 494 return sensedEntities;
492 fromRegionPos = avatar.AbsolutePosition; 495 fromRegionPos = avatar.AbsolutePosition;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index b25894a..d211a2b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -343,7 +343,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
343 void llSetDamage(double damage); 343 void llSetDamage(double damage);
344 void llSetForce(LSL_Vector force, int local); 344 void llSetForce(LSL_Vector force, int local);
345 void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local); 345 void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local);
346 void llSetVelocity(LSL_Vector velocity, int local);
347 void llSetAngularVelocity(LSL_Vector angularVelocity, int local); 346 void llSetAngularVelocity(LSL_Vector angularVelocity, int local);
348 void llSetHoverHeight(double height, int water, double tau); 347 void llSetHoverHeight(double height, int water, double tau);
349 void llSetInventoryPermMask(string item, int mask, int value); 348 void llSetInventoryPermMask(string item, int mask, int value);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 2f528af..4fc8d65 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -1550,11 +1550,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1550 m_LSL_Functions.llSetForceAndTorque(force, torque, local); 1550 m_LSL_Functions.llSetForceAndTorque(force, torque, local);
1551 } 1551 }
1552 1552
1553 public void llSetVelocity(LSL_Vector force, int local)
1554 {
1555 m_LSL_Functions.llSetVelocity(force, local);
1556 }
1557
1558 public void llSetAngularVelocity(LSL_Vector force, int local) 1553 public void llSetAngularVelocity(LSL_Vector force, int local)
1559 { 1554 {
1560 m_LSL_Functions.llSetAngularVelocity(force, local); 1555 m_LSL_Functions.llSetAngularVelocity(force, local);
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index 3ace9fb..964ccf8 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -27,11 +27,13 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Specialized;
30using System.IO; 31using System.IO;
31using System.IO.Compression; 32using System.IO.Compression;
32using System.Reflection; 33using System.Reflection;
33using System.Net; 34using System.Net;
34using System.Text; 35using System.Text;
36using System.Web;
35 37
36using OpenSim.Server.Base; 38using OpenSim.Server.Base;
37using OpenSim.Server.Handlers.Base; 39using OpenSim.Server.Handlers.Base;
@@ -90,19 +92,13 @@ namespace OpenSim.Server.Handlers.Simulation
90 92
91 // Next, let's parse the verb 93 // Next, let's parse the verb
92 string method = (string)request["http-method"]; 94 string method = (string)request["http-method"];
93 if (method.Equals("GET")) 95 if (method.Equals("DELETE"))
94 { 96 {
95 DoAgentGet(request, responsedata, agentID, regionID); 97 string auth_token = string.Empty;
96 return responsedata; 98 if (request.ContainsKey("auth"))
97 } 99 auth_token = request["auth"].ToString();
98 else if (method.Equals("DELETE")) 100
99 { 101 DoAgentDelete(request, responsedata, agentID, action, regionID, auth_token);
100 DoAgentDelete(request, responsedata, agentID, action, regionID);
101 return responsedata;
102 }
103 else if (method.Equals("DELETECHILD"))
104 {
105 DoChildAgentDelete(request, responsedata, agentID, action, regionID);
106 return responsedata; 102 return responsedata;
107 } 103 }
108 else if (method.Equals("QUERYACCESS")) 104 else if (method.Equals("QUERYACCESS"))
@@ -112,7 +108,7 @@ namespace OpenSim.Server.Handlers.Simulation
112 } 108 }
113 else 109 else
114 { 110 {
115 m_log.InfoFormat("[AGENT HANDLER]: method {0} not supported in agent message (caller is {1})", method, Util.GetCallerIP(request)); 111 m_log.ErrorFormat("[AGENT HANDLER]: method {0} not supported in agent message {1} (caller is {2})", method, (string)request["uri"], Util.GetCallerIP(request));
116 responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; 112 responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed;
117 responsedata["str_response_string"] = "Method not allowed"; 113 responsedata["str_response_string"] = "Method not allowed";
118 114
@@ -161,79 +157,12 @@ namespace OpenSim.Server.Handlers.Simulation
161// Console.WriteLine("str_response_string [{0}]", responsedata["str_response_string"]); 157// Console.WriteLine("str_response_string [{0}]", responsedata["str_response_string"]);
162 } 158 }
163 159
164 protected virtual void DoAgentGet(Hashtable request, Hashtable responsedata, UUID id, UUID regionID) 160 protected void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID, string auth_token)
165 {
166 if (m_SimulationService == null)
167 {
168 m_log.Debug("[AGENT HANDLER]: Agent GET called. Harmless but useless.");
169 responsedata["content_type"] = "application/json";
170 responsedata["int_response_code"] = HttpStatusCode.NotImplemented;
171 responsedata["str_response_string"] = string.Empty;
172
173 return;
174 }
175
176 GridRegion destination = new GridRegion();
177 destination.RegionID = regionID;
178
179 IAgentData agent = null;
180 bool result = m_SimulationService.RetrieveAgent(destination, id, out agent);
181 OSDMap map = null;
182 if (result)
183 {
184 if (agent != null) // just to make sure
185 {
186 map = agent.Pack();
187 string strBuffer = "";
188 try
189 {
190 strBuffer = OSDParser.SerializeJsonString(map);
191 }
192 catch (Exception e)
193 {
194 m_log.WarnFormat("[AGENT HANDLER]: Exception thrown on serialization of DoAgentGet: {0}", e.Message);
195 responsedata["int_response_code"] = HttpStatusCode.InternalServerError;
196 // ignore. buffer will be empty, caller should check.
197 }
198
199 responsedata["content_type"] = "application/json";
200 responsedata["int_response_code"] = HttpStatusCode.OK;
201 responsedata["str_response_string"] = strBuffer;
202 }
203 else
204 {
205 responsedata["int_response_code"] = HttpStatusCode.InternalServerError;
206 responsedata["str_response_string"] = "Internal error";
207 }
208 }
209 else
210 {
211 responsedata["int_response_code"] = HttpStatusCode.NotFound;
212 responsedata["str_response_string"] = "Not Found";
213 }
214 }
215
216 protected void DoChildAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID)
217 { 161 {
218 m_log.Debug(" >>> DoChildAgentDelete action:" + action + "; RegionID:" + regionID); 162 if (string.IsNullOrEmpty(action))
219 163 m_log.DebugFormat("[AGENT HANDLER]: >>> DELETE <<< RegionID: {0}; from: {1}; auth_code: {2}", regionID, Util.GetCallerIP(request), auth_token);
220 GridRegion destination = new GridRegion();
221 destination.RegionID = regionID;
222
223 if (action.Equals("release"))
224 ReleaseAgent(regionID, id);
225 else 164 else
226 m_SimulationService.CloseChildAgent(destination, id); 165 m_log.DebugFormat("[AGENT HANDLER]: Release {0} to RegionID: {1}", id, regionID);
227
228 responsedata["int_response_code"] = HttpStatusCode.OK;
229 responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
230
231 m_log.Debug("[AGENT HANDLER]: Child Agent Released/Deleted.");
232 }
233
234 protected void DoAgentDelete(Hashtable request, Hashtable responsedata, UUID id, string action, UUID regionID)
235 {
236 m_log.Debug(" >>> DoDelete action:" + action + "; RegionID:" + regionID);
237 166
238 GridRegion destination = new GridRegion(); 167 GridRegion destination = new GridRegion();
239 destination.RegionID = regionID; 168 destination.RegionID = regionID;
@@ -241,12 +170,12 @@ namespace OpenSim.Server.Handlers.Simulation
241 if (action.Equals("release")) 170 if (action.Equals("release"))
242 ReleaseAgent(regionID, id); 171 ReleaseAgent(regionID, id);
243 else 172 else
244 Util.FireAndForget(delegate { m_SimulationService.CloseAgent(destination, id); }); 173 Util.FireAndForget(delegate { m_SimulationService.CloseAgent(destination, id, auth_token); });
245 174
246 responsedata["int_response_code"] = HttpStatusCode.OK; 175 responsedata["int_response_code"] = HttpStatusCode.OK;
247 responsedata["str_response_string"] = "OpenSim agent " + id.ToString(); 176 responsedata["str_response_string"] = "OpenSim agent " + id.ToString();
248 177
249 m_log.DebugFormat("[AGENT HANDLER]: Agent {0} Released/Deleted from region {1}", id, regionID); 178 //m_log.DebugFormat("[AGENT HANDLER]: Agent {0} Released/Deleted from region {1}", id, regionID);
250 } 179 }
251 180
252 protected virtual void ReleaseAgent(UUID regionID, UUID id) 181 protected virtual void ReleaseAgent(UUID regionID, UUID id)
diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
index 94bda82..1a62d2f 100644
--- a/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
+++ b/OpenSim/Services/Connectors/GridUser/GridUserServicesConnector.cs
@@ -214,7 +214,7 @@ namespace OpenSim.Services.Connectors
214 214
215 } 215 }
216 else 216 else
217 m_log.DebugFormat("[GRID USER CONNECTOR]: Loggedin received empty reply"); 217 m_log.DebugFormat("[GRID USER CONNECTOR]: Get received empty reply");
218 } 218 }
219 catch (Exception e) 219 catch (Exception e)
220 { 220 {
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index da77719..0e74073 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -272,41 +272,6 @@ namespace OpenSim.Services.Connectors.Simulation
272 return false; 272 return false;
273 } 273 }
274 274
275 /// <summary>
276 /// Not sure what sequence causes this function to be invoked. The only calling
277 /// path is through the GET method
278 /// </summary>
279 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
280 {
281 // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: RetrieveAgent start");
282
283 agent = null;
284
285 // Eventually, we want to use a caps url instead of the agentID
286 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
287
288 try
289 {
290 OSDMap result = WebUtil.GetFromService(uri, 10000);
291 if (result["Success"].AsBoolean())
292 {
293 // OSDMap args = Util.GetOSDMap(result["_RawResult"].AsString());
294 OSDMap args = (OSDMap)result["_Result"];
295 if (args != null)
296 {
297 agent = new CompleteAgentData();
298 agent.Unpack(args, null);
299 return true;
300 }
301 }
302 }
303 catch (Exception e)
304 {
305 m_log.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e.ToString());
306 }
307
308 return false;
309 }
310 275
311 /// <summary> 276 /// <summary>
312 /// </summary> 277 /// </summary>
@@ -405,35 +370,25 @@ namespace OpenSim.Services.Connectors.Simulation
405 return true; 370 return true;
406 } 371 }
407 372
408 private bool CloseAgent(GridRegion destination, UUID id, bool ChildOnly) 373 /// <summary>
374 /// </summary>
375 public bool CloseAgent(GridRegion destination, UUID id, string auth_code)
409 { 376 {
410// m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent start"); 377 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/?auth=" + auth_code;
411 Util.FireAndForget(x => { 378 m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: CloseAgent {0}", uri);
412 string uri = destination.ServerURI + AgentPath() + id + "/" + destination.RegionID.ToString() + "/";
413 379
414 try 380 try
415 { 381 {
416 WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false); 382 WebUtil.ServiceOSDRequest(uri, null, "DELETE", 10000, false);
417 } 383 }
418 catch (Exception e) 384 catch (Exception e)
419 { 385 {
420 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CloseAgent failed with exception; {0}",e.ToString()); 386 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] CloseAgent failed with exception; {0}",e.ToString());
421 } 387 }
422 });
423 388
424 return true; 389 return true;
425 } 390 }
426 391
427 public bool CloseChildAgent(GridRegion destination, UUID id)
428 {
429 return CloseAgent(destination, id, true);
430 }
431
432 public bool CloseAgent(GridRegion destination, UUID id)
433 {
434 return CloseAgent(destination, id, false);
435 }
436
437 #endregion Agents 392 #endregion Agents
438 393
439 #region Objects 394 #region Objects
diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs
index 0cf1c14..0a3e70b 100644
--- a/OpenSim/Services/HypergridService/GatekeeperService.cs
+++ b/OpenSim/Services/HypergridService/GatekeeperService.cs
@@ -419,6 +419,12 @@ namespace OpenSim.Services.HypergridService
419 if (!CheckAddress(aCircuit.ServiceSessionID)) 419 if (!CheckAddress(aCircuit.ServiceSessionID))
420 return false; 420 return false;
421 421
422 if (string.IsNullOrEmpty(aCircuit.IPAddress))
423 {
424 m_log.DebugFormat("[GATEKEEPER SERVICE]: Agent did not provide a client IP address.");
425 return false;
426 }
427
422 string userURL = string.Empty; 428 string userURL = string.Empty;
423 if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) 429 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
424 userURL = aCircuit.ServiceURLs["HomeURI"].ToString(); 430 userURL = aCircuit.ServiceURLs["HomeURI"].ToString();
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index a6b5fc2..b414aca 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Reflection; 31using System.Reflection;
32 32
33using OpenSim.Data;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using OpenSim.Services.Connectors.Friends; 35using OpenSim.Services.Connectors.Friends;
35using OpenSim.Services.Connectors.Hypergrid; 36using OpenSim.Services.Connectors.Hypergrid;
@@ -50,14 +51,14 @@ namespace OpenSim.Services.HypergridService
50 /// needs to do it for them. 51 /// needs to do it for them.
51 /// Once we have better clients, this shouldn't be needed. 52 /// Once we have better clients, this shouldn't be needed.
52 /// </summary> 53 /// </summary>
53 public class UserAgentService : IUserAgentService 54 public class UserAgentService : UserAgentServiceBase, IUserAgentService
54 { 55 {
55 private static readonly ILog m_log = 56 private static readonly ILog m_log =
56 LogManager.GetLogger( 57 LogManager.GetLogger(
57 MethodBase.GetCurrentMethod().DeclaringType); 58 MethodBase.GetCurrentMethod().DeclaringType);
58 59
59 // This will need to go into a DB table 60 // This will need to go into a DB table
60 static Dictionary<UUID, TravelingAgentInfo> m_TravelingAgents = new Dictionary<UUID, TravelingAgentInfo>(); 61 //static Dictionary<UUID, TravelingAgentInfo> m_Database = new Dictionary<UUID, TravelingAgentInfo>();
61 62
62 static bool m_Initialized = false; 63 static bool m_Initialized = false;
63 64
@@ -86,6 +87,7 @@ namespace OpenSim.Services.HypergridService
86 } 87 }
87 88
88 public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector) 89 public UserAgentService(IConfigSource config, IFriendsSimConnector friendsConnector)
90 : base(config)
89 { 91 {
90 // Let's set this always, because we don't know the sequence 92 // Let's set this always, because we don't know the sequence
91 // of instantiations 93 // of instantiations
@@ -146,6 +148,9 @@ namespace OpenSim.Services.HypergridService
146 if (!m_GridName.EndsWith("/")) 148 if (!m_GridName.EndsWith("/"))
147 m_GridName = m_GridName + "/"; 149 m_GridName = m_GridName + "/";
148 150
151 // Finally some cleanup
152 m_Database.DeleteOld();
153
149 } 154 }
150 } 155 }
151 156
@@ -260,7 +265,8 @@ namespace OpenSim.Services.HypergridService
260 265
261 // Generate a new service session 266 // Generate a new service session
262 agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random(); 267 agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random();
263 TravelingAgentInfo old = UpdateTravelInfo(agentCircuit, region); 268 TravelingAgentInfo old = null;
269 TravelingAgentInfo travel = CreateTravelInfo(agentCircuit, region, fromLogin, out old);
264 270
265 bool success = false; 271 bool success = false;
266 string myExternalIP = string.Empty; 272 string myExternalIP = string.Empty;
@@ -282,23 +288,21 @@ namespace OpenSim.Services.HypergridService
282 m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}", 288 m_log.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} {1} to grid {2}, reason: {3}",
283 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason); 289 agentCircuit.firstname, agentCircuit.lastname, region.ServerURI, reason);
284 290
285 // restore the old travel info 291 if (old != null)
286 lock (m_TravelingAgents) 292 StoreTravelInfo(old);
287 { 293 else
288 if (old == null) 294 m_Database.Delete(agentCircuit.SessionID);
289 m_TravelingAgents.Remove(agentCircuit.SessionID);
290 else
291 m_TravelingAgents[agentCircuit.SessionID] = old;
292 }
293 295
294 return false; 296 return false;
295 } 297 }
296 298
299 // Everything is ok
300
301 // Update the perceived IP Address of our grid
297 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP); 302 m_log.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP);
298 // else set the IP addresses associated with this client 303 travel.MyIpAddress = myExternalIP;
299 if (fromLogin) 304
300 m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = agentCircuit.IPAddress; 305 StoreTravelInfo(travel);
301 m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;
302 306
303 return true; 307 return true;
304 } 308 }
@@ -309,57 +313,39 @@ namespace OpenSim.Services.HypergridService
309 return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, false, out reason); 313 return LoginAgentToGrid(agentCircuit, gatekeeper, finalDestination, false, out reason);
310 } 314 }
311 315
312 private void SetClientIP(UUID sessionID, string ip) 316 TravelingAgentInfo CreateTravelInfo(AgentCircuitData agentCircuit, GridRegion region, bool fromLogin, out TravelingAgentInfo existing)
313 { 317 {
314 if (m_TravelingAgents.ContainsKey(sessionID)) 318 HGTravelingData hgt = m_Database.Get(agentCircuit.SessionID);
315 { 319 existing = null;
316 m_log.DebugFormat("[USER AGENT SERVICE]: Setting IP {0} for session {1}", ip, sessionID);
317 m_TravelingAgents[sessionID].ClientIPAddress = ip;
318 }
319 }
320 320
321 TravelingAgentInfo UpdateTravelInfo(AgentCircuitData agentCircuit, GridRegion region) 321 if (hgt != null)
322 {
323 TravelingAgentInfo travel = new TravelingAgentInfo();
324 TravelingAgentInfo old = null;
325 lock (m_TravelingAgents)
326 { 322 {
327 if (m_TravelingAgents.ContainsKey(agentCircuit.SessionID)) 323 // Very important! Override whatever this agent comes with.
328 { 324 // UserAgentService always sets the IP for every new agent
329 // Very important! Override whatever this agent comes with. 325 // with the original IP address.
330 // UserAgentService always sets the IP for every new agent 326 existing = new TravelingAgentInfo(hgt);
331 // with the original IP address. 327 agentCircuit.IPAddress = existing.ClientIPAddress;
332 agentCircuit.IPAddress = m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress;
333
334 old = m_TravelingAgents[agentCircuit.SessionID];
335 }
336
337 m_TravelingAgents[agentCircuit.SessionID] = travel;
338 } 328 }
329
330 TravelingAgentInfo travel = new TravelingAgentInfo(existing);
331 travel.SessionID = agentCircuit.SessionID;
339 travel.UserID = agentCircuit.AgentID; 332 travel.UserID = agentCircuit.AgentID;
340 travel.GridExternalName = region.ServerURI; 333 travel.GridExternalName = region.ServerURI;
341 travel.ServiceToken = agentCircuit.ServiceSessionID; 334 travel.ServiceToken = agentCircuit.ServiceSessionID;
342 if (old != null)
343 travel.ClientIPAddress = old.ClientIPAddress;
344 335
345 return old; 336 if (fromLogin)
337 travel.ClientIPAddress = agentCircuit.IPAddress;
338
339 StoreTravelInfo(travel);
340
341 return travel;
346 } 342 }
347 343
348 public void LogoutAgent(UUID userID, UUID sessionID) 344 public void LogoutAgent(UUID userID, UUID sessionID)
349 { 345 {
350 m_log.DebugFormat("[USER AGENT SERVICE]: User {0} logged out", userID); 346 m_log.DebugFormat("[USER AGENT SERVICE]: User {0} logged out", userID);
351 347
352 lock (m_TravelingAgents) 348 m_Database.Delete(sessionID);
353 {
354 List<UUID> travels = new List<UUID>();
355 foreach (KeyValuePair<UUID, TravelingAgentInfo> kvp in m_TravelingAgents)
356 if (kvp.Value == null) // do some clean up
357 travels.Add(kvp.Key);
358 else if (kvp.Value.UserID == userID)
359 travels.Add(kvp.Key);
360 foreach (UUID session in travels)
361 m_TravelingAgents.Remove(session);
362 }
363 349
364 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString()); 350 GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString());
365 if (guinfo != null) 351 if (guinfo != null)
@@ -369,10 +355,11 @@ namespace OpenSim.Services.HypergridService
369 // We need to prevent foreign users with the same UUID as a local user 355 // We need to prevent foreign users with the same UUID as a local user
370 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName) 356 public bool IsAgentComingHome(UUID sessionID, string thisGridExternalName)
371 { 357 {
372 if (!m_TravelingAgents.ContainsKey(sessionID)) 358 HGTravelingData hgt = m_Database.Get(sessionID);
359 if (hgt == null)
373 return false; 360 return false;
374 361
375 TravelingAgentInfo travel = m_TravelingAgents[sessionID]; 362 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
376 363
377 return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower(); 364 return travel.GridExternalName.ToLower() == thisGridExternalName.ToLower();
378 } 365 }
@@ -385,29 +372,32 @@ namespace OpenSim.Services.HypergridService
385 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.", 372 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying Client session {0} with reported IP {1}.",
386 sessionID, reportedIP); 373 sessionID, reportedIP);
387 374
388 if (m_TravelingAgents.ContainsKey(sessionID)) 375 HGTravelingData hgt = m_Database.Get(sessionID);
389 { 376 if (hgt == null)
390 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing with login IP {0} and MyIP {1}", 377 return false;
391 m_TravelingAgents[sessionID].ClientIPAddress, m_TravelingAgents[sessionID].MyIpAddress);
392 378
393 return m_TravelingAgents[sessionID].ClientIPAddress == reportedIP || 379 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
394 m_TravelingAgents[sessionID].MyIpAddress == reportedIP; // NATed
395 }
396 380
397 return false; 381 bool result = travel.ClientIPAddress == reportedIP || travel.MyIpAddress == reportedIP; // NATed
382
383 m_log.DebugFormat("[USER AGENT SERVICE]: Comparing {0} with login IP {1} and MyIP {1}; result is {3}",
384 reportedIP, travel.ClientIPAddress, travel.MyIpAddress, result);
385
386 return result;
398 } 387 }
399 388
400 public bool VerifyAgent(UUID sessionID, string token) 389 public bool VerifyAgent(UUID sessionID, string token)
401 { 390 {
402 if (m_TravelingAgents.ContainsKey(sessionID)) 391 HGTravelingData hgt = m_Database.Get(sessionID);
392 if (hgt == null)
403 { 393 {
404 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying agent token {0} against {1}", token, m_TravelingAgents[sessionID].ServiceToken); 394 m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID);
405 return m_TravelingAgents[sessionID].ServiceToken == token; 395 return false;
406 } 396 }
407 397
408 m_log.DebugFormat("[USER AGENT SERVICE]: Token verification for session {0}: no such session", sessionID); 398 TravelingAgentInfo travel = new TravelingAgentInfo(hgt);
409 399 m_log.DebugFormat("[USER AGENT SERVICE]: Verifying agent token {0} against {1}", token, travel.ServiceToken);
410 return false; 400 return travel.ServiceToken == token;
411 } 401 }
412 402
413 [Obsolete] 403 [Obsolete]
@@ -470,17 +460,17 @@ namespace OpenSim.Services.HypergridService
470 } 460 }
471 } 461 }
472 462
473 // Lastly, let's notify the rest who may be online somewhere else 463 //// Lastly, let's notify the rest who may be online somewhere else
474 foreach (string user in usersToBeNotified) 464 //foreach (string user in usersToBeNotified)
475 { 465 //{
476 UUID id = new UUID(user); 466 // UUID id = new UUID(user);
477 if (m_TravelingAgents.ContainsKey(id) && m_TravelingAgents[id].GridExternalName != m_GridName) 467 // if (m_Database.ContainsKey(id) && m_Database[id].GridExternalName != m_GridName)
478 { 468 // {
479 string url = m_TravelingAgents[id].GridExternalName; 469 // string url = m_Database[id].GridExternalName;
480 // forward 470 // // forward
481 m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url); 471 // m_log.WarnFormat("[USER AGENT SERVICE]: User {0} is visiting {1}. HG Status notifications still not implemented.", user, url);
482 } 472 // }
483 } 473 //}
484 474
485 // and finally, let's send the online friends 475 // and finally, let's send the online friends
486 if (online) 476 if (online)
@@ -607,16 +597,13 @@ namespace OpenSim.Services.HypergridService
607 597
608 public string LocateUser(UUID userID) 598 public string LocateUser(UUID userID)
609 { 599 {
610 foreach (TravelingAgentInfo t in m_TravelingAgents.Values) 600 HGTravelingData[] hgts = m_Database.GetSessions(userID);
611 { 601 if (hgts == null)
612 if (t == null) 602 return string.Empty;
613 { 603
614 m_log.ErrorFormat("[USER AGENT SERVICE]: Oops! Null TravelingAgentInfo. Please report this on mantis"); 604 foreach (HGTravelingData t in hgts)
615 continue; 605 if (t.Data.ContainsKey("GridExternalName") && !m_GridName.Equals(t.Data["GridExternalName"]))
616 } 606 return t.Data["GridExternalName"];
617 if (t.UserID == userID && !m_GridName.Equals(t.GridExternalName))
618 return t.GridExternalName;
619 }
620 607
621 return string.Empty; 608 return string.Empty;
622 } 609 }
@@ -687,17 +674,60 @@ namespace OpenSim.Services.HypergridService
687 return exception; 674 return exception;
688 } 675 }
689 676
677 private void StoreTravelInfo(TravelingAgentInfo travel)
678 {
679 if (travel == null)
680 return;
681
682 HGTravelingData hgt = new HGTravelingData();
683 hgt.SessionID = travel.SessionID;
684 hgt.UserID = travel.UserID;
685 hgt.Data = new Dictionary<string, string>();
686 hgt.Data["GridExternalName"] = travel.GridExternalName;
687 hgt.Data["ServiceToken"] = travel.ServiceToken;
688 hgt.Data["ClientIPAddress"] = travel.ClientIPAddress;
689 hgt.Data["MyIPAddress"] = travel.MyIpAddress;
690
691 m_Database.Store(hgt);
692 }
690 #endregion 693 #endregion
691 694
692 } 695 }
693 696
694 class TravelingAgentInfo 697 class TravelingAgentInfo
695 { 698 {
699 public UUID SessionID;
696 public UUID UserID; 700 public UUID UserID;
697 public string GridExternalName = string.Empty; 701 public string GridExternalName = string.Empty;
698 public string ServiceToken = string.Empty; 702 public string ServiceToken = string.Empty;
699 public string ClientIPAddress = string.Empty; // as seen from this user agent service 703 public string ClientIPAddress = string.Empty; // as seen from this user agent service
700 public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper 704 public string MyIpAddress = string.Empty; // the user agent service's external IP, as seen from the next gatekeeper
705
706 public TravelingAgentInfo(HGTravelingData t)
707 {
708 if (t.Data != null)
709 {
710 SessionID = new UUID(t.SessionID);
711 UserID = new UUID(t.UserID);
712 GridExternalName = t.Data["GridExternalName"];
713 ServiceToken = t.Data["ServiceToken"];
714 ClientIPAddress = t.Data["ClientIPAddress"];
715 MyIpAddress = t.Data["MyIPAddress"];
716 }
717 }
718
719 public TravelingAgentInfo(TravelingAgentInfo old)
720 {
721 if (old != null)
722 {
723 SessionID = old.SessionID;
724 UserID = old.UserID;
725 GridExternalName = old.GridExternalName;
726 ServiceToken = old.ServiceToken;
727 ClientIPAddress = old.ClientIPAddress;
728 MyIpAddress = old.MyIpAddress;
729 }
730 }
701 } 731 }
702 732
703} 733}
diff --git a/OpenSim/Services/HypergridService/UserAgentServiceBase.cs b/OpenSim/Services/HypergridService/UserAgentServiceBase.cs
new file mode 100644
index 0000000..a00e5a6
--- /dev/null
+++ b/OpenSim/Services/HypergridService/UserAgentServiceBase.cs
@@ -0,0 +1,84 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Reflection;
30using Nini.Config;
31using OpenSim.Framework;
32using OpenSim.Data;
33using OpenSim.Services.Interfaces;
34using OpenSim.Services.Base;
35
36namespace OpenSim.Services.HypergridService
37{
38 public class UserAgentServiceBase : ServiceBase
39 {
40 protected IHGTravelingData m_Database = null;
41
42 public UserAgentServiceBase(IConfigSource config)
43 : base(config)
44 {
45 string dllName = String.Empty;
46 string connString = String.Empty;
47 string realm = "hg_traveling_data";
48
49 //
50 // Try reading the [DatabaseService] section, if it exists
51 //
52 IConfig dbConfig = config.Configs["DatabaseService"];
53 if (dbConfig != null)
54 {
55 if (dllName == String.Empty)
56 dllName = dbConfig.GetString("StorageProvider", String.Empty);
57 if (connString == String.Empty)
58 connString = dbConfig.GetString("ConnectionString", String.Empty);
59 }
60
61 //
62 // [UserAgentService] section overrides [DatabaseService], if it exists
63 //
64 IConfig gridConfig = config.Configs["UserAgentService"];
65 if (gridConfig != null)
66 {
67 dllName = gridConfig.GetString("StorageProvider", dllName);
68 connString = gridConfig.GetString("ConnectionString", connString);
69 realm = gridConfig.GetString("Realm", realm);
70 }
71
72 //
73 // We tried, but this doesn't exist. We can't proceed.
74 //
75 if (dllName.Equals(String.Empty))
76 throw new Exception("No StorageProvider configured");
77
78 m_Database = LoadPlugin<IHGTravelingData>(dllName, new Object[] { connString, realm });
79 if (m_Database == null)
80 throw new Exception("Could not find a storage interface in the given module");
81
82 }
83 }
84}
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index a963b8e..1c82b3e 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -75,8 +75,6 @@ namespace OpenSim.Services.Interfaces
75 /// <returns></returns> 75 /// <returns></returns>
76 bool UpdateAgent(GridRegion destination, AgentPosition data); 76 bool UpdateAgent(GridRegion destination, AgentPosition data);
77 77
78 bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent);
79
80 bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason); 78 bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason);
81 79
82 /// <summary> 80 /// <summary>
@@ -90,20 +88,12 @@ namespace OpenSim.Services.Interfaces
90 bool ReleaseAgent(UUID originRegion, UUID id, string uri); 88 bool ReleaseAgent(UUID originRegion, UUID id, string uri);
91 89
92 /// <summary> 90 /// <summary>
93 /// Close child agent.
94 /// </summary>
95 /// <param name="regionHandle"></param>
96 /// <param name="id"></param>
97 /// <returns></returns>
98 bool CloseChildAgent(GridRegion destination, UUID id);
99
100 /// <summary>
101 /// Close agent. 91 /// Close agent.
102 /// </summary> 92 /// </summary>
103 /// <param name="regionHandle"></param> 93 /// <param name="regionHandle"></param>
104 /// <param name="id"></param> 94 /// <param name="id"></param>
105 /// <returns></returns> 95 /// <returns></returns>
106 bool CloseAgent(GridRegion destination, UUID id); 96 bool CloseAgent(GridRegion destination, UUID id, string auth_token);
107 97
108 #endregion Agents 98 #endregion Agents
109 99
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 179a91f..6528d9a 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -591,7 +591,7 @@ namespace OpenSim.Tests.Common.Mock
591 { 591 {
592 AgentCircuitData agentData = new AgentCircuitData(); 592 AgentCircuitData agentData = new AgentCircuitData();
593 agentData.AgentID = AgentId; 593 agentData.AgentID = AgentId;
594 agentData.SessionID = UUID.Zero; 594 agentData.SessionID = SessionId;
595 agentData.SecureSessionID = UUID.Zero; 595 agentData.SecureSessionID = UUID.Zero;
596 agentData.circuitcode = m_circuitCode; 596 agentData.circuitcode = m_circuitCode;
597 agentData.child = false; 597 agentData.child = false;