diff options
Diffstat (limited to 'OpenSim/Region/Communications/OGS1/OGS1GridServices.cs')
-rw-r--r-- | OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | 93 |
1 files changed, 61 insertions, 32 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index b7d62ed..50a31c6 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | |||
@@ -18,40 +18,50 @@ namespace OpenSim.Region.Communications.OGS1 | |||
18 | public class OGS1GridServices : IGridServices, IInterRegionCommunications | 18 | public class OGS1GridServices : IGridServices, IInterRegionCommunications |
19 | { | 19 | { |
20 | public Dictionary<ulong, RegionCommsListener> listeners = new Dictionary<ulong, RegionCommsListener>(); | 20 | public Dictionary<ulong, RegionCommsListener> listeners = new Dictionary<ulong, RegionCommsListener>(); |
21 | protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>(); | ||
22 | |||
21 | public BaseHttpServer httpListener; | 23 | public BaseHttpServer httpListener; |
22 | public NetworkServersInfo serversInfo; | 24 | public NetworkServersInfo serversInfo; |
25 | public BaseHttpServer httpServer; | ||
23 | 26 | ||
24 | public OGS1GridServices(NetworkServersInfo servers_info) | 27 | public OGS1GridServices(NetworkServersInfo servers_info, BaseHttpServer httpServe) |
25 | { | 28 | { |
26 | serversInfo = servers_info; | 29 | serversInfo = servers_info; |
30 | httpServer = httpServe; | ||
31 | httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser); | ||
27 | } | 32 | } |
28 | 33 | ||
29 | public RegionCommsListener RegisterRegion(RegionInfo regionInfo) | 34 | public RegionCommsListener RegisterRegion(RegionInfo regionInfo) |
30 | { | 35 | { |
36 | if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) | ||
37 | { | ||
38 | this.regions.Add(regionInfo.RegionHandle, regionInfo); | ||
39 | } | ||
40 | |||
31 | Hashtable GridParams = new Hashtable(); | 41 | Hashtable GridParams = new Hashtable(); |
32 | 42 | ||
33 | 43 | ||
34 | // Login / Authentication | 44 | // Login / Authentication |
35 | 45 | ||
36 | GridParams["authkey"] = serversInfo.GridSendKey; | 46 | GridParams["authkey"] = serversInfo.GridSendKey; |
37 | GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated(); | 47 | GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated(); |
38 | GridParams["sim_ip"] = regionInfo.ExternalHostName; | 48 | GridParams["sim_ip"] = regionInfo.ExternalHostName; |
39 | GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); | 49 | GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); |
40 | GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); | 50 | GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); |
41 | GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); | 51 | GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); |
42 | GridParams["sim_name"] = regionInfo.RegionName; | 52 | GridParams["sim_name"] = regionInfo.RegionName; |
53 | GridParams["http_port"] = serversInfo.HttpListenerPort.ToString(); | ||
54 | GridParams["remoting_port"] = serversInfo.RemotingListenerPort.ToString(); | ||
43 | 55 | ||
44 | // Package into an XMLRPC Request | 56 | // Package into an XMLRPC Request |
45 | ArrayList SendParams = new ArrayList(); | 57 | ArrayList SendParams = new ArrayList(); |
46 | SendParams.Add(GridParams); | 58 | SendParams.Add(GridParams); |
47 | 59 | ||
48 | |||
49 | |||
50 | // Send Request | 60 | // Send Request |
51 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); | 61 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); |
52 | XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); | 62 | XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); |
53 | Hashtable GridRespData = (Hashtable)GridResp.Value; | 63 | Hashtable GridRespData = (Hashtable)GridResp.Value; |
54 | 64 | ||
55 | Hashtable griddatahash = GridRespData; | 65 | Hashtable griddatahash = GridRespData; |
56 | 66 | ||
57 | // Process Response | 67 | // Process Response |
@@ -60,25 +70,34 @@ namespace OpenSim.Region.Communications.OGS1 | |||
60 | string errorstring = (string)GridRespData["error"]; | 70 | string errorstring = (string)GridRespData["error"]; |
61 | MainLog.Instance.Error("Unable to connect to grid: " + errorstring); | 71 | MainLog.Instance.Error("Unable to connect to grid: " + errorstring); |
62 | return null; | 72 | return null; |
63 | } | ||
64 | |||
65 | if (!this.listeners.ContainsKey(regionInfo.RegionHandle)) | ||
66 | { | ||
67 | MainLog.Instance.Verbose("OGS1 - Registering new HTTP listener on port " + regionInfo.InternalEndPoint.Port.ToString()); | ||
68 | // initialised = true; | ||
69 | httpListener = new BaseHttpServer( regionInfo.InternalEndPoint.Port ); | ||
70 | httpListener.AddXmlRPCHandler("expect_user", this.ExpectUser); | ||
71 | httpListener.Start(); | ||
72 | } | 73 | } |
73 | 74 | ||
75 | /* if (!this.listeners.ContainsKey(regionInfo.RegionHandle)) | ||
76 | { | ||
77 | MainLog.Instance.Verbose("OGS1 - Registering new HTTP listener on port " + regionInfo.InternalEndPoint.Port.ToString()); | ||
78 | // initialised = true; | ||
79 | httpListener = new BaseHttpServer( regionInfo.InternalEndPoint.Port ); | ||
80 | httpListener.AddXmlRPCHandler("expect_user", this.ExpectUser); | ||
81 | httpListener.Start(); | ||
82 | }*/ | ||
83 | |||
74 | // Initialise the background listeners | 84 | // Initialise the background listeners |
75 | listeners[regionInfo.RegionHandle] = new RegionCommsListener(); | 85 | RegionCommsListener regListener = new RegionCommsListener(); |
86 | if (this.listeners.ContainsKey(regionInfo.RegionHandle)) | ||
87 | { | ||
88 | this.listeners.Add(regionInfo.RegionHandle, regListener); | ||
89 | } | ||
90 | else | ||
91 | { | ||
92 | listeners[regionInfo.RegionHandle] = regListener; | ||
93 | } | ||
76 | 94 | ||
77 | return listeners[regionInfo.RegionHandle]; | 95 | return regListener; |
78 | } | 96 | } |
79 | 97 | ||
80 | public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo) | 98 | public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo) |
81 | { | 99 | { |
100 | |||
82 | Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1); | 101 | Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1); |
83 | 102 | ||
84 | List<RegionInfo> neighbours = new List<RegionInfo>(); | 103 | List<RegionInfo> neighbours = new List<RegionInfo>(); |
@@ -87,24 +106,28 @@ namespace OpenSim.Region.Communications.OGS1 | |||
87 | { | 106 | { |
88 | foreach (Hashtable n in a) | 107 | foreach (Hashtable n in a) |
89 | { | 108 | { |
90 | string internalIpStr = (string)n["sim_ip"]; | 109 | uint regX = Convert.ToUInt32(n["x"]); |
91 | int port = (int)n["sim_port"]; | 110 | uint regY = Convert.ToUInt32(n["y"]); |
92 | string externalUri = (string)n["sim_uri"]; | 111 | if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY)) |
93 | 112 | { | |
94 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), port); | 113 | string internalIpStr = (string)n["sim_ip"]; |
95 | string neighbourExternalUri = externalUri; | 114 | uint port = Convert.ToUInt32(n["sim_port"]); |
115 | string externalUri = (string)n["sim_uri"]; | ||
96 | 116 | ||
97 | RegionInfo neighbour = new RegionInfo((uint)n["x"], (uint)n["y"], neighbourInternalEndPoint, neighbourExternalUri); | 117 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); |
118 | string neighbourExternalUri = externalUri; | ||
119 | RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); | ||
98 | 120 | ||
99 | //OGS1 | 121 | //OGS1 |
100 | //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally | 122 | //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally |
101 | 123 | ||
102 | neighbour.RegionName = (string)n["name"]; | 124 | neighbour.RegionName = (string)n["name"]; |
103 | 125 | ||
104 | //OGS1+ | 126 | //OGS1+ |
105 | neighbour.SimUUID = (string)n["uuid"]; | 127 | neighbour.SimUUID = (string)n["uuid"]; |
106 | 128 | ||
107 | neighbours.Add(neighbour); | 129 | neighbours.Add(neighbour); |
130 | } | ||
108 | } | 131 | } |
109 | } | 132 | } |
110 | 133 | ||
@@ -113,6 +136,11 @@ namespace OpenSim.Region.Communications.OGS1 | |||
113 | 136 | ||
114 | public RegionInfo RequestNeighbourInfo(ulong regionHandle) | 137 | public RegionInfo RequestNeighbourInfo(ulong regionHandle) |
115 | { | 138 | { |
139 | if (this.regions.ContainsKey(regionHandle)) | ||
140 | { | ||
141 | return this.regions[regionHandle]; | ||
142 | } | ||
143 | //TODO not a region in this instance so ask remote grid server | ||
116 | MainLog.Instance.Warn("Unimplemented - RequestNeighbourInfo()"); | 144 | MainLog.Instance.Warn("Unimplemented - RequestNeighbourInfo()"); |
117 | return null; | 145 | return null; |
118 | } | 146 | } |
@@ -209,7 +237,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
209 | TcpChannel ch = new TcpChannel(8895); | 237 | TcpChannel ch = new TcpChannel(8895); |
210 | ChannelServices.RegisterChannel(ch, true); | 238 | ChannelServices.RegisterChannel(ch, true); |
211 | 239 | ||
212 | WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry( Type.GetType("OGS1InterRegionRemoting"), "InterRegions", WellKnownObjectMode.Singleton); | 240 | WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(Type.GetType("OGS1InterRegionRemoting"), "InterRegions", WellKnownObjectMode.Singleton); |
213 | RemotingConfiguration.RegisterWellKnownServiceType(wellType); | 241 | RemotingConfiguration.RegisterWellKnownServiceType(wellType); |
214 | InterRegionSingleton.Instance.OnArrival += this.IncomingArrival; | 242 | InterRegionSingleton.Instance.OnArrival += this.IncomingArrival; |
215 | InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent; | 243 | InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent; |
@@ -225,6 +253,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
225 | } | 253 | } |
226 | //TODO need to see if we know about where this region is and use .net remoting | 254 | //TODO need to see if we know about where this region is and use .net remoting |
227 | // to inform it. | 255 | // to inform it. |
256 | Console.WriteLine("Inform remote region of child agent not implemented yet"); | ||
228 | return false; | 257 | return false; |
229 | } | 258 | } |
230 | 259 | ||