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.
dsg
Huaiyu (Kitty) Liu 2010-12-22 11:41:31 -08:00
parent c1af982ff4
commit f97fe18648
2 changed files with 24 additions and 12 deletions

View File

@ -35,7 +35,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
IConfig m_sysConfig = config.Configs["RegionSyncModule"]; m_sysConfig = config.Configs["RegionSyncModule"];
m_active = false; m_active = false;
if (m_sysConfig == null) if (m_sysConfig == null)
{ {
@ -231,6 +231,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
private HashSet<RegionSyncListenerInfo> m_remoteSyncListeners; private HashSet<RegionSyncListenerInfo> m_remoteSyncListeners;
private int m_syncConnectorNum = 0;
private Scene m_scene; private Scene m_scene;
public Scene LocalScene 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. //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 //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. //the actor operates on.
private HashSet<SyncConnector> m_syncConnectors=null; private HashSet<SyncConnector> m_syncConnectors= new HashSet<SyncConnector>();
private object m_syncConnectorsLock = new object(); private object m_syncConnectorsLock = new object();
//Timers for periodically status report has not been implemented yet. //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. //For now, we use configuration to access the information. Might be replaced by some Grid Service later on.
private RegionSyncListenerInfo GetLocalSyncListenerInfo() private RegionSyncListenerInfo GetLocalSyncListenerInfo()
{ {
string listenerAddrDefault = m_sysConfig.GetString("ServerIPAddress", "127.0.0.1"); string addr = m_sysConfig.GetString("SyncListenerIPAddress", "127.0.0.1");
string addr = m_sysConfig.GetString("SyncListenerIPAddress", listenerAddrDefault);
int port = m_sysConfig.GetInt("SyncListenerPort", 13000); int port = m_sysConfig.GetInt("SyncListenerPort", 13000);
RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port); 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. //And for now, we assume there is only 1 remote listener to connect to.
private void GetRemoteSyncListenerInfo() private void GetRemoteSyncListenerInfo()
{ {
string listenerAddrDefault = m_sysConfig.GetString("ServerIPAddress", "127.0.0.1"); string addr = m_sysConfig.GetString("SyncListenerIPAddress", "127.0.0.1");
string addr = m_sysConfig.GetString("SyncListenerIPAddress", listenerAddrDefault);
int port = m_sysConfig.GetInt("SyncListenerPort", 13000); int port = m_sysConfig.GetInt("SyncListenerPort", 13000);
RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port); RegionSyncListenerInfo info = new RegionSyncListenerInfo(addr, port);
if (m_remoteSyncListeners == null) if (m_remoteSyncListeners == null)
{ {
m_remoteSyncListeners = new HashSet<RegionSyncListenerInfo>(); m_remoteSyncListeners = new HashSet<RegionSyncListenerInfo>();
m_remoteSyncListeners.Add(info);
} }
m_remoteSyncListeners.Add(info);
} }
private void SyncStart(Object[] args) private void SyncStart(Object[] args)
@ -344,7 +344,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
{ {
foreach (RegionSyncListenerInfo remoteListener in m_remoteSyncListeners) foreach (RegionSyncListenerInfo remoteListener in m_remoteSyncListeners)
{ {
SyncConnector syncConnector = new SyncConnector(remoteListener); SyncConnector syncConnector = new SyncConnector(m_syncConnectorNum++, remoteListener);
if (syncConnector.Start()) if (syncConnector.Start())
{ {
AddSyncConnector(syncConnector); AddSyncConnector(syncConnector);
@ -358,7 +358,7 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
//IPAddress addr = ((IPEndPoint)tcpclient.Client.RemoteEndPoint).Address; //IPAddress addr = ((IPEndPoint)tcpclient.Client.RemoteEndPoint).Address;
//int port = ((IPEndPoint)tcpclient.Client.RemoteEndPoint).Port; //int port = ((IPEndPoint)tcpclient.Client.RemoteEndPoint).Port;
SyncConnector syncConnector = new SyncConnector(tcpclient); SyncConnector syncConnector = new SyncConnector(m_syncConnectorNum++, tcpclient);
AddSyncConnector(syncConnector); AddSyncConnector(syncConnector);
} }
@ -376,6 +376,8 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
m_syncConnectors = newlist; m_syncConnectors = newlist;
} }
m_log.Debug("[REGION SYNC MODULE]: new connector " + syncConnector.ConnectorNum);
} }
public void RemoveSyncConnector(SyncConnector syncConnector) public void RemoveSyncConnector(SyncConnector syncConnector)

View File

@ -19,14 +19,24 @@ namespace OpenSim.Region.CoreModules.RegionSync.RegionSyncModule
// The logfile // The logfile
private ILog m_log; 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_remoteListenerInfo = listenerInfo;
m_connectorNum = connectorNum;
m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
} }
//Start the connection //Start the connection