From f0ecc1de4ccb40ed23b5bc925130bda3ff07c1a6 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 10 Jul 2007 20:52:43 +0000 Subject: preliminary inter region communications (between regions in different instances) now works, so child agents and border crossings (and teleporting) now work. The .net remoting is still very basic: we need security sinks added. And we really need the OGS 2 protocol as soon as possible. --- .../Region/Communications/OGS1/OGS1GridServices.cs | 97 ++++++++++++++++++++-- 1 file changed, 88 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Communications/OGS1/OGS1GridServices.cs') diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index 1cadf9b..66c1739 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs @@ -29,6 +29,7 @@ namespace OpenSim.Region.Communications.OGS1 serversInfo = servers_info; httpServer = httpServe; httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser); + this.StartRemoting(); } public RegionCommsListener RegisterRegion(RegionInfo regionInfo) @@ -52,6 +53,7 @@ namespace OpenSim.Region.Communications.OGS1 GridParams["sim_name"] = regionInfo.RegionName; GridParams["http_port"] = serversInfo.HttpListenerPort.ToString(); GridParams["remoting_port"] = serversInfo.RemotingListenerPort.ToString(); + GridParams["map-image-id"] = regionInfo.estateSettings.terrainImageID.ToStringHyphenated(); // Package into an XMLRPC Request ArrayList SendParams = new ArrayList(); @@ -97,7 +99,7 @@ namespace OpenSim.Region.Communications.OGS1 public List RequestNeighbours(RegionInfo regionInfo) { - + Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1); List neighbours = new List(); @@ -141,8 +143,40 @@ namespace OpenSim.Region.Communications.OGS1 return this.regions[regionHandle]; } //TODO not a region in this instance so ask remote grid server - MainLog.Instance.Warn("Unimplemented - RequestNeighbourInfo()"); - return null; + + Hashtable requestData = new Hashtable(); + requestData["region_handle"] = regionHandle.ToString(); + requestData["authkey"] = this.serversInfo.GridSendKey; + ArrayList SendParams = new ArrayList(); + SendParams.Add(requestData); + XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); + XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000); + + Hashtable responseData = (Hashtable)GridResp.Value; + + if (responseData.ContainsKey("error")) + { + Console.WriteLine("error received from grid server" + responseData["error"]); + return null; + } + + uint regX = Convert.ToUInt32((string)responseData["region_locx"]); + uint regY = Convert.ToUInt32((string)responseData["region_locy"]); + string internalIpStr = (string)responseData["sim_ip"]; + uint port = Convert.ToUInt32(responseData["sim_port"]); + string externalUri = (string)responseData["sim_uri"]; + + IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); + string neighbourExternalUri = externalUri; + RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); + + regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); + regionInfo.RemotingAddress = internalIpStr; + + regionInfo.SimUUID = new LLUUID((string)responseData["region_UUID"]); + regionInfo.RegionName = (string)responseData["region_name"]; + + return regionInfo; } public List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) @@ -164,7 +198,7 @@ namespace OpenSim.Region.Communications.OGS1 neighbour.Access = Convert.ToByte(n["access"]); neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]); neighbour.WaterHeight = Convert.ToByte(n["water-height"]); - neighbour.MapImageId = (string)n["map-image-id"]; + neighbour.MapImageId = new LLUUID((string)n["map-image-id"]); neighbours.Add(neighbour); } @@ -237,10 +271,10 @@ namespace OpenSim.Region.Communications.OGS1 #region InterRegion Comms private void StartRemoting() { - TcpChannel ch = new TcpChannel(8895); + TcpChannel ch = new TcpChannel(this.serversInfo.RemotingListenerPort); ChannelServices.RegisterChannel(ch, true); - WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(Type.GetType("OGS1InterRegionRemoting"), "InterRegions", WellKnownObjectMode.Singleton); + WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton); RemotingConfiguration.RegisterWellKnownServiceType(wellType); InterRegionSingleton.Instance.OnArrival += this.IncomingArrival; InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent; @@ -254,9 +288,31 @@ namespace OpenSim.Region.Communications.OGS1 this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); return true; } - //TODO need to see if we know about where this region is and use .net remoting - // to inform it. - Console.WriteLine("Inform remote region of child agent not implemented yet"); + RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); + if (regInfo != null) + { + //don't want to be creating a new link to the remote instance every time like we are here + bool retValue = false; + + + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( + typeof(OGS1InterRegionRemoting), + "tcp://"+ regInfo.RemotingAddress+":"+regInfo.RemotingPort+"/InterRegions"); + if (remObject != null) + { + + retValue = remObject.InformRegionOfChildAgent(regionHandle, agentData); + } + else + { + Console.WriteLine("remoting object not found"); + } + remObject = null; + + + return retValue; + } + return false; } @@ -267,6 +323,29 @@ namespace OpenSim.Region.Communications.OGS1 this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); return true; } + RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); + if (regInfo != null) + { + bool retValue = false; + + + OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( + typeof(OGS1InterRegionRemoting), + "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); + if (remObject != null) + { + + retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position); + } + else + { + Console.WriteLine("remoting object not found"); + } + remObject = null; + + + return retValue; + } //TODO need to see if we know about where this region is and use .net remoting // to inform it. return false; -- cgit v1.1