From f4448fcd7df587604b63e45fc5bcdbaec3f579ee Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 31 May 2007 17:33:52 +0000 Subject: [PATCH] After nearly a hour of searching for an annoying bug (which turned out to be a new statement one line outside the loop it should have been in)....Multi-Regions in a single instance work, there is no Grid mode communication, so it can only be tested in sandbox mode right now. All you need to do is put .xml files for each region you want to be ran by the single server inside the "bin\Regions" folder (make sure none of the settings in those .xml files conflict with each other) and then startup the server and login, Any neighbouring regions that are being ran in the instance should show up. (However there is still no movement or anything) Now time to refine the communications interfaces! --- .../TestLocalCommsManager.cs | 35 +++++++++++++++++-- .../Interfaces/IClientAPI.cs | 1 + .../OpenSim.RegionServer/ClientView.API.cs | 2 +- OpenSim/OpenSim.World/World.cs | 20 +++++++---- OpenSim/OpenSim/OpenSimMain.cs | 4 ++- 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/Common/OpenGrid.Framework.Communications/TestLocalCommsManager.cs b/Common/OpenGrid.Framework.Communications/TestLocalCommsManager.cs index 54ca966135..c82c8204a2 100644 --- a/Common/OpenGrid.Framework.Communications/TestLocalCommsManager.cs +++ b/Common/OpenGrid.Framework.Communications/TestLocalCommsManager.cs @@ -26,12 +26,17 @@ namespace OpenGrid.Framework.Communications /// public override RegionCommsHostBase RegisterRegion(RegionInfo regionInfo) { + //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering"); + if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) { + //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle ); + this.regions.Add(regionInfo.RegionHandle, regionInfo); RegionCommsHostBase regionHost = new RegionCommsHostBase(); this.regionHosts.Add(regionInfo.RegionHandle, regionHost); + return regionHost; } @@ -46,7 +51,26 @@ namespace OpenGrid.Framework.Communications /// public override List RequestNeighbours(RegionInfo regionInfo) { - return null; + // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle); + List neighbours = new List(); + + foreach (RegionInfo reg in this.regions.Values) + { + // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY); + if (reg.RegionHandle != regionInfo.RegionHandle) + { + //Console.WriteLine("CommsManager- RequestNeighbours() - found a different region in list, checking location"); + if ((reg.RegionLocX > (regionInfo.RegionLocX - 2)) && (reg.RegionLocX < (regionInfo.RegionLocX + 2))) + { + if ((reg.RegionLocY > (regionInfo.RegionLocY - 2)) && (reg.RegionLocY < (regionInfo.RegionLocY + 2))) + { + neighbours.Add(reg); + } + } + } + } + + return neighbours; } /// @@ -55,6 +79,13 @@ namespace OpenGrid.Framework.Communications /// public override bool InformNeighbourOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData { + //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent"); + if (this.regionHosts.ContainsKey(regionHandle)) + { + // Console.WriteLine("CommsManager- Informing a region to expect child agent"); + this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData); + return true; + } return false; } @@ -66,7 +97,7 @@ namespace OpenGrid.Framework.Communications /// public bool AddNewSession(ulong regionHandle, Login loginData) { - Console.WriteLine(" comms manager been told to expect new user"); + //Console.WriteLine(" comms manager been told to expect new user"); AgentCircuitData agent = new AgentCircuitData(); agent.AgentID = loginData.Agent; agent.firstname = loginData.First; diff --git a/Common/OpenSim.Framework/Interfaces/IClientAPI.cs b/Common/OpenSim.Framework/Interfaces/IClientAPI.cs index 78be30a4d9..810345f31f 100644 --- a/Common/OpenSim.Framework/Interfaces/IClientAPI.cs +++ b/Common/OpenSim.Framework/Interfaces/IClientAPI.cs @@ -84,6 +84,7 @@ namespace OpenSim.Framework.Interfaces void SendRegionHandshake(RegionInfo regionInfo); void MoveAgentIntoRegion(RegionInfo regInfo); void SendAvatarData(RegionInfo regionInfo, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos); + void InformClientOfNeighbour(ulong neighbourHandle, System.Net.IPAddress neighbourIP, ushort neighbourPort); AgentCircuitData RequestClientInfo(); } } diff --git a/OpenSim/OpenSim.RegionServer/ClientView.API.cs b/OpenSim/OpenSim.RegionServer/ClientView.API.cs index e14b7b7cd6..89c1f61bbe 100644 --- a/OpenSim/OpenSim.RegionServer/ClientView.API.cs +++ b/OpenSim/OpenSim.RegionServer/ClientView.API.cs @@ -374,7 +374,7 @@ namespace OpenSim return objdata; } - protected void InformClientOfNeighbour(ulong neighbourHandle, System.Net.IPAddress neighbourIP, ushort neighbourPort) + public void InformClientOfNeighbour(ulong neighbourHandle, System.Net.IPAddress neighbourIP, ushort neighbourPort) { EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); diff --git a/OpenSim/OpenSim.World/World.cs b/OpenSim/OpenSim.World/World.cs index 2c5971d3a2..1d56ea32a0 100644 --- a/OpenSim/OpenSim.World/World.cs +++ b/OpenSim/OpenSim.World/World.cs @@ -504,16 +504,22 @@ namespace OpenSim.world /// protected void InformClientOfNeighbours(IClientAPI remoteClient) { + // Console.WriteLine("informing client of neighbouring regions"); List neighbours = this.commsManager.RequestNeighbours(this.m_regInfo); - - for (int i = 0; i < neighbours.Count; i++) + //Console.WriteLine("we have " + neighbours.Count + " neighbouring regions"); + if (neighbours != null) { - AgentCircuitData agent = remoteClient.RequestClientInfo(); - agent.BaseFolder = LLUUID.Zero; - agent.InventoryFolder = LLUUID.Zero; - agent.startpos = new LLVector3(128, 128, 70); - this.commsManager.InformNeighbourOfChildAgent(neighbours[i].RegionHandle, agent); + for (int i = 0; i < neighbours.Count; i++) + { + // Console.WriteLine("sending neighbours data"); + AgentCircuitData agent = remoteClient.RequestClientInfo(); + agent.BaseFolder = LLUUID.Zero; + agent.InventoryFolder = LLUUID.Zero; + agent.startpos = new LLVector3(128, 128, 70); + this.commsManager.InformNeighbourOfChildAgent(neighbours[i].RegionHandle, agent); + remoteClient.InformClientOfNeighbour(neighbours[i].RegionHandle, System.Net.IPAddress.Parse(neighbours[i].IPListenAddr), (ushort)neighbours[i].IPListenPort); + } } } diff --git a/OpenSim/OpenSim/OpenSimMain.cs b/OpenSim/OpenSim/OpenSimMain.cs index 66aadb0852..7c83dee6b1 100644 --- a/OpenSim/OpenSim/OpenSimMain.cs +++ b/OpenSim/OpenSim/OpenSimMain.cs @@ -61,6 +61,7 @@ namespace OpenSim private CheckSumServer checkServer; protected RegionServerCommsManager commsManager; + public OpenSimMain(bool sandBoxMode, bool startLoginServer, string physicsEngine, bool useConfigFile, bool silent, string configFile) { this.configFileSetup = useConfigFile; @@ -209,6 +210,7 @@ namespace OpenSim for (int i = 0; i < configFiles.Length; i++) { + regionDat = new RegionInfo(); if (m_sandbox) { AuthenticateSessionsLocal authen = new AuthenticateSessionsLocal(); @@ -259,7 +261,7 @@ namespace OpenSim protected override void SetupHttpListener() { - httpServer = new BaseHttpServer(regionData[0].IPListenPort); + httpServer = new BaseHttpServer(9000); //regionData[0].IPListenPort); if (!this.m_sandbox) {