From f97fe1864832657069ecc5496ab0b4d2d563d261 Mon Sep 17 00:00:00 2001 From: "Huaiyu (Kitty) Liu" Date: Wed, 22 Dec 2010 11:41:31 -0800 Subject: [PATCH] Code good for an actor (script engine tested) to connect to ScenePersistence for synchronization. Need to work on data transmission along the connection as next step. --- .../SymmetricSync/RegionSyncModule.cs | 20 ++++++++++--------- .../SymmetricSync/SyncConnector.cs | 16 ++++++++++++--- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs index 79228dc099..b24e4db3e7 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/RegionSyncModule.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - IConfig m_sysConfig = config.Configs["RegionSyncModule"]; + m_sysConfig = config.Configs["RegionSyncModule"]; m_active = false; if (m_sysConfig == null) { @@ -231,6 +231,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule private HashSet m_remoteSyncListeners; + private int m_syncConnectorNum = 0; + private Scene m_scene; public Scene LocalScene { @@ -242,7 +244,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //The list of SyncConnectors. ScenePersistence could have multiple SyncConnectors, each connecting to a differerent actor. //An actor could have several SyncConnectors as well, each connecting to a ScenePersistence that hosts a portion of the objects/avatars //the actor operates on. - private HashSet m_syncConnectors=null; + private HashSet m_syncConnectors= new HashSet(); private object m_syncConnectorsLock = new object(); //Timers for periodically status report has not been implemented yet. @@ -268,8 +270,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //For now, we use configuration to access the information. Might be replaced by some Grid Service later on. private RegionSyncListenerInfo GetLocalSyncListenerInfo() { - string listenerAddrDefault = m_sysConfig.GetString("ServerIPAddress", "127.0.0.1"); - string addr = m_sysConfig.GetString("SyncListenerIPAddress", listenerAddrDefault); + string addr = m_sysConfig.GetString("SyncListenerIPAddress", "127.0.0.1"); int port = m_sysConfig.GetInt("SyncListenerPort", 13000); RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port); @@ -283,16 +284,15 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //And for now, we assume there is only 1 remote listener to connect to. private void GetRemoteSyncListenerInfo() { - string listenerAddrDefault = m_sysConfig.GetString("ServerIPAddress", "127.0.0.1"); - string addr = m_sysConfig.GetString("SyncListenerIPAddress", listenerAddrDefault); + string addr = m_sysConfig.GetString("SyncListenerIPAddress", "127.0.0.1"); int port = m_sysConfig.GetInt("SyncListenerPort", 13000); RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port); if (m_remoteSyncListeners == null) { m_remoteSyncListeners = new HashSet(); - m_remoteSyncListeners.Add(info); } + m_remoteSyncListeners.Add(info); } private void SyncStart(Object[] args) @@ -344,7 +344,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule { foreach (RegionSyncListenerInfo remoteListener in m_remoteSyncListeners) { - SyncConnector syncConnector = new SyncConnector(remoteListener); + SyncConnector syncConnector = new SyncConnector(m_syncConnectorNum++, remoteListener); if (syncConnector.Start()) { AddSyncConnector(syncConnector); @@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule //IPAddress addr = ((IPEndPoint)tcpclient.Client.RemoteEndPoint).Address; //int port = ((IPEndPoint)tcpclient.Client.RemoteEndPoint).Port; - SyncConnector syncConnector = new SyncConnector(tcpclient); + SyncConnector syncConnector = new SyncConnector(m_syncConnectorNum++, tcpclient); AddSyncConnector(syncConnector); } @@ -376,6 +376,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule m_syncConnectors = newlist; } + + m_log.Debug("[REGION SYNC MODULE]: new connector " + syncConnector.ConnectorNum); } public void RemoveSyncConnector(SyncConnector syncConnector) diff --git a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs index 90869b1a2f..661b7d7ca3 100755 --- a/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs +++ b/OpenSim/Region/CoreModules/RegionSync/RegionSyncModule/SymmetricSync/SyncConnector.cs @@ -19,14 +19,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule // The logfile private ILog m_log; - public SyncConnector(TcpClient tcpclient) + private int m_connectorNum; + public int ConnectorNum { - m_tcpConnection = tcpclient; + get { return m_connectorNum; } } - public SyncConnector(RegionSyncListenerInfo listenerInfo) + public SyncConnector(int connectorNum, TcpClient tcpclient) + { + m_tcpConnection = tcpclient; + m_connectorNum = connectorNum; + m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + } + + public SyncConnector(int connectorNum, RegionSyncListenerInfo listenerInfo) { m_remoteListenerInfo = listenerInfo; + m_connectorNum = connectorNum; + m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); } //Start the connection