From 54b1071556edf264835f990bb3595064d2b2e2f0 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 2 Aug 2013 23:12:54 +0100
Subject: Allow older teleport ConnectorProtocolVersion of "SIMULATION/0.1" to
 be manually forced in a new [SimulationService] config setting.

This is for testing and debugging purposes to help determine whether a particular issue may be teleport related or not
"SIMULATION/0.2" (the newer teleport protocol) remains the default.  If the source simulator only implements "SIMULATION/0.1" this will correctly allow fallback to the older protocol.
Specifying "SIMULATION/0.1" will force the older, less efficient protocol to always be used.
---
 .../Simulation/LocalSimulationConnector.cs         | 33 +++++++++++++---------
 .../Simulation/RemoteSimulationConnector.cs        | 21 ++++++--------
 bin/config-include/Grid.ini                        | 11 ++++++++
 bin/config-include/Standalone.ini                  | 11 ++++++++
 4 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 697ce68..7aadb87 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -63,35 +63,40 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
         /// </summary>
         private bool m_ModuleEnabled = false;
 
-        public LocalSimulationConnectorModule()
-        {
-            ServiceVersion = "SIMULATION/0.2";
-        }
-
         #region Region Module interface
 
-        public void Initialise(IConfigSource config)
+        public void Initialise(IConfigSource configSource)
         {
-            IConfig moduleConfig = config.Configs["Modules"];
+            IConfig moduleConfig = configSource.Configs["Modules"];
             if (moduleConfig != null)
             {
                 string name = moduleConfig.GetString("SimulationServices", "");
                 if (name == Name)
                 {
-                    //IConfig userConfig = config.Configs["SimulationService"];
-                    //if (userConfig == null)
-                    //{
-                    //    m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpenSim.ini");
-                    //    return;
-                    //}
+                    InitialiseService(configSource);
 
                     m_ModuleEnabled = true;
 
-                    m_log.Info("[SIMULATION CONNECTOR]: Local simulation enabled");
+                    m_log.Info("[LOCAL SIMULATION CONNECTOR]: Local simulation enabled.");
                 }
             }
         }
 
+        public void InitialiseService(IConfigSource configSource)
+        {
+            IConfig config = configSource.Configs["SimulationService"];
+            if (config != null)
+            {
+                ServiceVersion = config.GetString("ConnectorProtocolVersion", "SIMULATION/0.2");
+
+                if (ServiceVersion != "SIMULATION/0.1" && ServiceVersion != "SIMULATION/0.2")
+                    throw new Exception(string.Format("Invalid ConnectorProtocolVersion {0}", ServiceVersion));
+
+                m_log.InfoFormat(
+                    "[LOCAL SIMULATION CONNECTOR]: Initialzied with connector protocol version {0}", ServiceVersion);
+            }
+        }
+
         public void PostInitialise()
         {
         }
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index 8722b80..f45f560 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -50,9 +50,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
     [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteSimulationConnectorModule")]
     public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService
     {
-        private bool initialized = false;
         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
+        private bool initialized = false;
         protected bool m_enabled = false;
         protected Scene m_aScene;
         // RemoteSimulationConnector does not care about local regions; it delegates that to the Local module
@@ -64,27 +64,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
 
         #region Region Module interface
 
-        public virtual void Initialise(IConfigSource config)
+        public virtual void Initialise(IConfigSource configSource)
         {
-
-            IConfig moduleConfig = config.Configs["Modules"];
+            IConfig moduleConfig = configSource.Configs["Modules"];
             if (moduleConfig != null)
             {
                 string name = moduleConfig.GetString("SimulationServices", "");
                 if (name == Name)
                 {
-                    //IConfig userConfig = config.Configs["SimulationService"];
-                    //if (userConfig == null)
-                    //{
-                    //    m_log.Error("[AVATAR CONNECTOR]: SimulationService missing from OpenSim.ini");
-                    //    return;
-                    //}
+                    m_localBackend = new LocalSimulationConnectorModule();
+
+                    m_localBackend.InitialiseService(configSource);
 
                     m_remoteConnector = new SimulationServiceConnector();
 
                     m_enabled = true;
 
-                    m_log.Info("[SIMULATION CONNECTOR]: Remote simulation enabled");
+                    m_log.Info("[REMOTE SIMULATION CONNECTOR]: Remote simulation enabled.");
                 }
             }
         }
@@ -142,8 +138,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
         }
 
         protected virtual void InitOnce(Scene scene)
-        {
-            m_localBackend = new LocalSimulationConnectorModule();
+        {            
             m_aScene = scene;
             //m_regionClient = new RegionToRegionClient(m_aScene, m_hyperlinkService);
             m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName);
diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini
index 15ba55a..1837bdd 100644
--- a/bin/config-include/Grid.ini
+++ b/bin/config-include/Grid.ini
@@ -30,6 +30,17 @@
     SimulationServiceInConnector	= true
     LibraryModule					= true
 
+[SimulationService]
+    ; This is the protocol version which the simulator advertises to the source destination when acting as a target destination for a teleport
+    ; It is used to control the teleport handoff process.
+    ; Valid values are 
+    ; "SIMULATION/0.2"
+    ;   - this is the default.  A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol
+    ;   - this protocol is more efficient than "SIMULATION/0.1"
+    ; "SIMULATION/0.1" 
+    ;   - this is an older teleport protocol used in OpenSimulator 0.7.5 and before.
+    ConnectorProtocolVersion = "SIMULATION/0.2"
+
 [SimulationDataStore]
     LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService"
 
diff --git a/bin/config-include/Standalone.ini b/bin/config-include/Standalone.ini
index d3b9cb4..7b7beb2 100644
--- a/bin/config-include/Standalone.ini
+++ b/bin/config-include/Standalone.ini
@@ -26,6 +26,17 @@
     GridInfoServiceInConnector = true
     MapImageServiceInConnector = true
 
+[SimulationService]
+    ; This is the protocol version which the simulator advertises to the source destination when acting as a target destination for a teleport
+    ; It is used to control the teleport handoff process.
+    ; Valid values are 
+    ; "SIMULATION/0.2"
+    ;   - this is the default.  A source simulator which only implements "SIMULATION/0.1" can still teleport with that protocol 
+    ;   - this protocol is more efficient than "SIMULATION/0.1"
+    ; "SIMULATION/0.1" 
+    ;   - this is an older teleport protocol used in OpenSimulator 0.7.5 and before.
+    ConnectorProtocolVersion = "SIMULATION/0.2"
+
 [SimulationDataStore]
     LocalServiceModule = "OpenSim.Services.Connectors.dll:SimulationDataService"
 
-- 
cgit v1.1