diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to 'OpenSim/Region/Communications/OGS1/OGS1GridServices.cs')
-rw-r--r-- | OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | 862 |
1 files changed, 431 insertions, 431 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs index e5a73fd..3cb2889 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1GridServices.cs | |||
@@ -1,431 +1,431 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections; | 2 | using System.Collections; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | using System.Net; | 4 | using System.Net; |
5 | using System.Runtime.Remoting; | 5 | using System.Runtime.Remoting; |
6 | using System.Runtime.Remoting.Channels; | 6 | using System.Runtime.Remoting.Channels; |
7 | using System.Runtime.Remoting.Channels.Tcp; | 7 | using System.Runtime.Remoting.Channels.Tcp; |
8 | using libsecondlife; | 8 | using libsecondlife; |
9 | using Nwc.XmlRpc; | 9 | using Nwc.XmlRpc; |
10 | using OpenSim.Framework; | 10 | using OpenSim.Framework; |
11 | using OpenSim.Framework.Communications; | 11 | using OpenSim.Framework.Communications; |
12 | using OpenSim.Framework.Console; | 12 | using OpenSim.Framework.Console; |
13 | using OpenSim.Framework.Servers; | 13 | using OpenSim.Framework.Servers; |
14 | using OpenSim.Framework.Types; | 14 | using OpenSim.Framework.Types; |
15 | 15 | ||
16 | namespace OpenSim.Region.Communications.OGS1 | 16 | namespace OpenSim.Region.Communications.OGS1 |
17 | { | 17 | { |
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>(); | 21 | protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>(); |
22 | 22 | ||
23 | public BaseHttpServer httpListener; | 23 | public BaseHttpServer httpListener; |
24 | public NetworkServersInfo serversInfo; | 24 | public NetworkServersInfo serversInfo; |
25 | public BaseHttpServer httpServer; | 25 | public BaseHttpServer httpServer; |
26 | 26 | ||
27 | /// <summary> | 27 | /// <summary> |
28 | /// | 28 | /// |
29 | /// </summary> | 29 | /// </summary> |
30 | /// <param name="servers_info"></param> | 30 | /// <param name="servers_info"></param> |
31 | /// <param name="httpServe"></param> | 31 | /// <param name="httpServe"></param> |
32 | public OGS1GridServices(NetworkServersInfo servers_info, BaseHttpServer httpServe) | 32 | public OGS1GridServices(NetworkServersInfo servers_info, BaseHttpServer httpServe) |
33 | { | 33 | { |
34 | serversInfo = servers_info; | 34 | serversInfo = servers_info; |
35 | httpServer = httpServe; | 35 | httpServer = httpServe; |
36 | httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser); | 36 | httpServer.AddXmlRPCHandler("expect_user", this.ExpectUser); |
37 | this.StartRemoting(); | 37 | this.StartRemoting(); |
38 | } | 38 | } |
39 | 39 | ||
40 | /// <summary> | 40 | /// <summary> |
41 | /// | 41 | /// |
42 | /// </summary> | 42 | /// </summary> |
43 | /// <param name="regionInfo"></param> | 43 | /// <param name="regionInfo"></param> |
44 | /// <returns></returns> | 44 | /// <returns></returns> |
45 | public RegionCommsListener RegisterRegion(RegionInfo regionInfo) | 45 | public RegionCommsListener RegisterRegion(RegionInfo regionInfo) |
46 | { | 46 | { |
47 | if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) | 47 | if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle)) |
48 | { | 48 | { |
49 | this.regions.Add(regionInfo.RegionHandle, regionInfo); | 49 | this.regions.Add(regionInfo.RegionHandle, regionInfo); |
50 | } | 50 | } |
51 | 51 | ||
52 | Hashtable GridParams = new Hashtable(); | 52 | Hashtable GridParams = new Hashtable(); |
53 | // Login / Authentication | 53 | // Login / Authentication |
54 | 54 | ||
55 | GridParams["authkey"] = serversInfo.GridSendKey; | 55 | GridParams["authkey"] = serversInfo.GridSendKey; |
56 | GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated(); | 56 | GridParams["UUID"] = regionInfo.SimUUID.ToStringHyphenated(); |
57 | GridParams["sim_ip"] = regionInfo.ExternalHostName; | 57 | GridParams["sim_ip"] = regionInfo.ExternalHostName; |
58 | GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); | 58 | GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString(); |
59 | GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); | 59 | GridParams["region_locx"] = regionInfo.RegionLocX.ToString(); |
60 | GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); | 60 | GridParams["region_locy"] = regionInfo.RegionLocY.ToString(); |
61 | GridParams["sim_name"] = regionInfo.RegionName; | 61 | GridParams["sim_name"] = regionInfo.RegionName; |
62 | GridParams["http_port"] = serversInfo.HttpListenerPort.ToString(); | 62 | GridParams["http_port"] = serversInfo.HttpListenerPort.ToString(); |
63 | GridParams["remoting_port"] = serversInfo.RemotingListenerPort.ToString(); | 63 | GridParams["remoting_port"] = serversInfo.RemotingListenerPort.ToString(); |
64 | GridParams["map-image-id"] = regionInfo.estateSettings.terrainImageID.ToStringHyphenated(); | 64 | GridParams["map-image-id"] = regionInfo.estateSettings.terrainImageID.ToStringHyphenated(); |
65 | 65 | ||
66 | // Package into an XMLRPC Request | 66 | // Package into an XMLRPC Request |
67 | ArrayList SendParams = new ArrayList(); | 67 | ArrayList SendParams = new ArrayList(); |
68 | SendParams.Add(GridParams); | 68 | SendParams.Add(GridParams); |
69 | 69 | ||
70 | // Send Request | 70 | // Send Request |
71 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); | 71 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams); |
72 | XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); | 72 | XmlRpcResponse GridResp = GridReq.Send(serversInfo.GridURL, 3000); |
73 | Hashtable GridRespData = (Hashtable)GridResp.Value; | 73 | Hashtable GridRespData = (Hashtable)GridResp.Value; |
74 | 74 | ||
75 | Hashtable griddatahash = GridRespData; | 75 | Hashtable griddatahash = GridRespData; |
76 | 76 | ||
77 | // Process Response | 77 | // Process Response |
78 | if (GridRespData.ContainsKey("error")) | 78 | if (GridRespData.ContainsKey("error")) |
79 | { | 79 | { |
80 | string errorstring = (string)GridRespData["error"]; | 80 | string errorstring = (string)GridRespData["error"]; |
81 | MainLog.Instance.Error("Unable to connect to grid: " + errorstring); | 81 | MainLog.Instance.Error("Unable to connect to grid: " + errorstring); |
82 | return null; | 82 | return null; |
83 | } | 83 | } |
84 | 84 | ||
85 | // Initialise the background listeners | 85 | // Initialise the background listeners |
86 | RegionCommsListener regListener = new RegionCommsListener(); | 86 | RegionCommsListener regListener = new RegionCommsListener(); |
87 | if (!this.listeners.ContainsKey(regionInfo.RegionHandle)) | 87 | if (!this.listeners.ContainsKey(regionInfo.RegionHandle)) |
88 | { | 88 | { |
89 | this.listeners.Add(regionInfo.RegionHandle, regListener); | 89 | this.listeners.Add(regionInfo.RegionHandle, regListener); |
90 | } | 90 | } |
91 | else | 91 | else |
92 | { | 92 | { |
93 | listeners[regionInfo.RegionHandle] = regListener; | 93 | listeners[regionInfo.RegionHandle] = regListener; |
94 | } | 94 | } |
95 | 95 | ||
96 | return regListener; | 96 | return regListener; |
97 | } | 97 | } |
98 | 98 | ||
99 | /// <summary> | 99 | /// <summary> |
100 | /// | 100 | /// |
101 | /// </summary> | 101 | /// </summary> |
102 | /// <param name="regionInfo"></param> | 102 | /// <param name="regionInfo"></param> |
103 | /// <returns></returns> | 103 | /// <returns></returns> |
104 | public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo) | 104 | public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo) |
105 | { | 105 | { |
106 | 106 | ||
107 | Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1); | 107 | Hashtable respData = MapBlockQuery((int)regionInfo.RegionLocX - 1, (int)regionInfo.RegionLocY - 1, (int)regionInfo.RegionLocX + 1, (int)regionInfo.RegionLocY + 1); |
108 | 108 | ||
109 | List<RegionInfo> neighbours = new List<RegionInfo>(); | 109 | List<RegionInfo> neighbours = new List<RegionInfo>(); |
110 | 110 | ||
111 | foreach (ArrayList a in respData.Values) | 111 | foreach (ArrayList a in respData.Values) |
112 | { | 112 | { |
113 | foreach (Hashtable n in a) | 113 | foreach (Hashtable n in a) |
114 | { | 114 | { |
115 | uint regX = Convert.ToUInt32(n["x"]); | 115 | uint regX = Convert.ToUInt32(n["x"]); |
116 | uint regY = Convert.ToUInt32(n["y"]); | 116 | uint regY = Convert.ToUInt32(n["y"]); |
117 | if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY)) | 117 | if ((regionInfo.RegionLocX != regX) || (regionInfo.RegionLocY != regY)) |
118 | { | 118 | { |
119 | string externalIpStr = (string)n["sim_ip"]; | 119 | string externalIpStr = (string)n["sim_ip"]; |
120 | uint port = Convert.ToUInt32(n["sim_port"]); | 120 | uint port = Convert.ToUInt32(n["sim_port"]); |
121 | string externalUri = (string)n["sim_uri"]; | 121 | string externalUri = (string)n["sim_uri"]; |
122 | 122 | ||
123 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(externalIpStr), (int)port); | 123 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(externalIpStr), (int)port); |
124 | string neighbourExternalUri = externalUri; | 124 | string neighbourExternalUri = externalUri; |
125 | RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, externalIpStr); | 125 | RegionInfo neighbour = new RegionInfo(regX, regY, neighbourInternalEndPoint, externalIpStr); |
126 | 126 | ||
127 | //OGS1 | 127 | //OGS1 |
128 | //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally | 128 | //neighbour.RegionHandle = (ulong)n["regionhandle"]; is now calculated locally |
129 | 129 | ||
130 | neighbour.RegionName = (string)n["name"]; | 130 | neighbour.RegionName = (string)n["name"]; |
131 | 131 | ||
132 | //OGS1+ | 132 | //OGS1+ |
133 | neighbour.SimUUID = (string)n["uuid"]; | 133 | neighbour.SimUUID = (string)n["uuid"]; |
134 | 134 | ||
135 | neighbours.Add(neighbour); | 135 | neighbours.Add(neighbour); |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | 139 | ||
140 | return neighbours; | 140 | return neighbours; |
141 | } | 141 | } |
142 | 142 | ||
143 | /// <summary> | 143 | /// <summary> |
144 | /// | 144 | /// |
145 | /// </summary> | 145 | /// </summary> |
146 | /// <param name="regionHandle"></param> | 146 | /// <param name="regionHandle"></param> |
147 | /// <returns></returns> | 147 | /// <returns></returns> |
148 | public RegionInfo RequestNeighbourInfo(ulong regionHandle) | 148 | public RegionInfo RequestNeighbourInfo(ulong regionHandle) |
149 | { | 149 | { |
150 | if (this.regions.ContainsKey(regionHandle)) | 150 | if (this.regions.ContainsKey(regionHandle)) |
151 | { | 151 | { |
152 | return this.regions[regionHandle]; | 152 | return this.regions[regionHandle]; |
153 | } | 153 | } |
154 | //TODO not a region in this instance so ask remote grid server | 154 | //TODO not a region in this instance so ask remote grid server |
155 | 155 | ||
156 | Hashtable requestData = new Hashtable(); | 156 | Hashtable requestData = new Hashtable(); |
157 | requestData["region_handle"] = regionHandle.ToString(); | 157 | requestData["region_handle"] = regionHandle.ToString(); |
158 | requestData["authkey"] = this.serversInfo.GridSendKey; | 158 | requestData["authkey"] = this.serversInfo.GridSendKey; |
159 | ArrayList SendParams = new ArrayList(); | 159 | ArrayList SendParams = new ArrayList(); |
160 | SendParams.Add(requestData); | 160 | SendParams.Add(requestData); |
161 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); | 161 | XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams); |
162 | XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000); | 162 | XmlRpcResponse GridResp = GridReq.Send(this.serversInfo.GridURL, 3000); |
163 | 163 | ||
164 | Hashtable responseData = (Hashtable)GridResp.Value; | 164 | Hashtable responseData = (Hashtable)GridResp.Value; |
165 | 165 | ||
166 | if (responseData.ContainsKey("error")) | 166 | if (responseData.ContainsKey("error")) |
167 | { | 167 | { |
168 | Console.WriteLine("error received from grid server" + responseData["error"]); | 168 | Console.WriteLine("error received from grid server" + responseData["error"]); |
169 | return null; | 169 | return null; |
170 | } | 170 | } |
171 | 171 | ||
172 | uint regX = Convert.ToUInt32((string)responseData["region_locx"]); | 172 | uint regX = Convert.ToUInt32((string)responseData["region_locx"]); |
173 | uint regY = Convert.ToUInt32((string)responseData["region_locy"]); | 173 | uint regY = Convert.ToUInt32((string)responseData["region_locy"]); |
174 | string internalIpStr = (string)responseData["sim_ip"]; | 174 | string internalIpStr = (string)responseData["sim_ip"]; |
175 | uint port = Convert.ToUInt32(responseData["sim_port"]); | 175 | uint port = Convert.ToUInt32(responseData["sim_port"]); |
176 | string externalUri = (string)responseData["sim_uri"]; | 176 | string externalUri = (string)responseData["sim_uri"]; |
177 | 177 | ||
178 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); | 178 | IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int)port); |
179 | string neighbourExternalUri = externalUri; | 179 | string neighbourExternalUri = externalUri; |
180 | RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); | 180 | RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr); |
181 | 181 | ||
182 | regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); | 182 | regionInfo.RemotingPort = Convert.ToUInt32((string)responseData["remoting_port"]); |
183 | regionInfo.RemotingAddress = internalIpStr; | 183 | regionInfo.RemotingAddress = internalIpStr; |
184 | 184 | ||
185 | regionInfo.SimUUID = new LLUUID((string)responseData["region_UUID"]); | 185 | regionInfo.SimUUID = new LLUUID((string)responseData["region_UUID"]); |
186 | regionInfo.RegionName = (string)responseData["region_name"]; | 186 | regionInfo.RegionName = (string)responseData["region_name"]; |
187 | 187 | ||
188 | return regionInfo; | 188 | return regionInfo; |
189 | } | 189 | } |
190 | 190 | ||
191 | /// <summary> | 191 | /// <summary> |
192 | /// | 192 | /// |
193 | /// </summary> | 193 | /// </summary> |
194 | /// <param name="minX"></param> | 194 | /// <param name="minX"></param> |
195 | /// <param name="minY"></param> | 195 | /// <param name="minY"></param> |
196 | /// <param name="maxX"></param> | 196 | /// <param name="maxX"></param> |
197 | /// <param name="maxY"></param> | 197 | /// <param name="maxY"></param> |
198 | /// <returns></returns> | 198 | /// <returns></returns> |
199 | public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) | 199 | public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY) |
200 | { | 200 | { |
201 | Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY); | 201 | Hashtable respData = MapBlockQuery(minX, minY, maxX, maxY); |
202 | 202 | ||
203 | List<MapBlockData> neighbours = new List<MapBlockData>(); | 203 | List<MapBlockData> neighbours = new List<MapBlockData>(); |
204 | 204 | ||
205 | foreach (ArrayList a in respData.Values) | 205 | foreach (ArrayList a in respData.Values) |
206 | { | 206 | { |
207 | foreach (Hashtable n in a) | 207 | foreach (Hashtable n in a) |
208 | { | 208 | { |
209 | MapBlockData neighbour = new MapBlockData(); | 209 | MapBlockData neighbour = new MapBlockData(); |
210 | 210 | ||
211 | neighbour.X = Convert.ToUInt16(n["x"]); | 211 | neighbour.X = Convert.ToUInt16(n["x"]); |
212 | neighbour.Y = Convert.ToUInt16(n["y"]); | 212 | neighbour.Y = Convert.ToUInt16(n["y"]); |
213 | 213 | ||
214 | neighbour.Name = (string)n["name"]; | 214 | neighbour.Name = (string)n["name"]; |
215 | neighbour.Access = Convert.ToByte(n["access"]); | 215 | neighbour.Access = Convert.ToByte(n["access"]); |
216 | neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]); | 216 | neighbour.RegionFlags = Convert.ToUInt32(n["region-flags"]); |
217 | neighbour.WaterHeight = Convert.ToByte(n["water-height"]); | 217 | neighbour.WaterHeight = Convert.ToByte(n["water-height"]); |
218 | neighbour.MapImageId = new LLUUID((string)n["map-image-id"]); | 218 | neighbour.MapImageId = new LLUUID((string)n["map-image-id"]); |
219 | 219 | ||
220 | neighbours.Add(neighbour); | 220 | neighbours.Add(neighbour); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | return neighbours; | 224 | return neighbours; |
225 | } | 225 | } |
226 | 226 | ||
227 | /// <summary> | 227 | /// <summary> |
228 | /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates | 228 | /// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates |
229 | /// </summary> | 229 | /// </summary> |
230 | /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks> | 230 | /// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks> |
231 | /// <param name="minX">Minimum X value</param> | 231 | /// <param name="minX">Minimum X value</param> |
232 | /// <param name="minY">Minimum Y value</param> | 232 | /// <param name="minY">Minimum Y value</param> |
233 | /// <param name="maxX">Maximum X value</param> | 233 | /// <param name="maxX">Maximum X value</param> |
234 | /// <param name="maxY">Maximum Y value</param> | 234 | /// <param name="maxY">Maximum Y value</param> |
235 | /// <returns>Hashtable of hashtables containing map data elements</returns> | 235 | /// <returns>Hashtable of hashtables containing map data elements</returns> |
236 | private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY) | 236 | private Hashtable MapBlockQuery(int minX, int minY, int maxX, int maxY) |
237 | { | 237 | { |
238 | Hashtable param = new Hashtable(); | 238 | Hashtable param = new Hashtable(); |
239 | param["xmin"] = minX; | 239 | param["xmin"] = minX; |
240 | param["ymin"] = minY; | 240 | param["ymin"] = minY; |
241 | param["xmax"] = maxX; | 241 | param["xmax"] = maxX; |
242 | param["ymax"] = maxY; | 242 | param["ymax"] = maxY; |
243 | IList parameters = new ArrayList(); | 243 | IList parameters = new ArrayList(); |
244 | parameters.Add(param); | 244 | parameters.Add(param); |
245 | XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); | 245 | XmlRpcRequest req = new XmlRpcRequest("map_block", parameters); |
246 | XmlRpcResponse resp = req.Send(serversInfo.GridURL, 3000); | 246 | XmlRpcResponse resp = req.Send(serversInfo.GridURL, 3000); |
247 | Hashtable respData = (Hashtable)resp.Value; | 247 | Hashtable respData = (Hashtable)resp.Value; |
248 | return respData; | 248 | return respData; |
249 | } | 249 | } |
250 | 250 | ||
251 | // Grid Request Processing | 251 | // Grid Request Processing |
252 | /// <summary> | 252 | /// <summary> |
253 | /// | 253 | /// |
254 | /// </summary> | 254 | /// </summary> |
255 | /// <param name="request"></param> | 255 | /// <param name="request"></param> |
256 | /// <returns></returns> | 256 | /// <returns></returns> |
257 | public XmlRpcResponse ExpectUser(XmlRpcRequest request) | 257 | public XmlRpcResponse ExpectUser(XmlRpcRequest request) |
258 | { | 258 | { |
259 | Console.WriteLine("Expecting User..."); | 259 | Console.WriteLine("Expecting User..."); |
260 | Hashtable requestData = (Hashtable)request.Params[0]; | 260 | Hashtable requestData = (Hashtable)request.Params[0]; |
261 | AgentCircuitData agentData = new AgentCircuitData(); | 261 | AgentCircuitData agentData = new AgentCircuitData(); |
262 | agentData.SessionID = new LLUUID((string)requestData["session_id"]); | 262 | agentData.SessionID = new LLUUID((string)requestData["session_id"]); |
263 | agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); | 263 | agentData.SecureSessionID = new LLUUID((string)requestData["secure_session_id"]); |
264 | agentData.firstname = (string)requestData["firstname"]; | 264 | agentData.firstname = (string)requestData["firstname"]; |
265 | agentData.lastname = (string)requestData["lastname"]; | 265 | agentData.lastname = (string)requestData["lastname"]; |
266 | agentData.AgentID = new LLUUID((string)requestData["agent_id"]); | 266 | agentData.AgentID = new LLUUID((string)requestData["agent_id"]); |
267 | agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); | 267 | agentData.circuitcode = Convert.ToUInt32(requestData["circuit_code"]); |
268 | agentData.CapsPath = (string)requestData["caps_path"]; | 268 | agentData.CapsPath = (string)requestData["caps_path"]; |
269 | 269 | ||
270 | if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) | 270 | if (requestData.ContainsKey("child_agent") && requestData["child_agent"].Equals("1")) |
271 | { | 271 | { |
272 | agentData.child = true; | 272 | agentData.child = true; |
273 | } | 273 | } |
274 | else | 274 | else |
275 | { | 275 | { |
276 | agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"])); | 276 | agentData.startpos = new LLVector3(Convert.ToUInt32(requestData["startpos_x"]), Convert.ToUInt32(requestData["startpos_y"]), Convert.ToUInt32(requestData["startpos_z"])); |
277 | agentData.child = false; | 277 | agentData.child = false; |
278 | 278 | ||
279 | } | 279 | } |
280 | 280 | ||
281 | if (listeners.ContainsKey(Convert.ToUInt64((string)requestData["regionhandle"]))) | 281 | if (listeners.ContainsKey(Convert.ToUInt64((string)requestData["regionhandle"]))) |
282 | { | 282 | { |
283 | this.listeners[Convert.ToUInt64((string)requestData["regionhandle"])].TriggerExpectUser(Convert.ToUInt64((string)requestData["regionhandle"]), agentData); | 283 | this.listeners[Convert.ToUInt64((string)requestData["regionhandle"])].TriggerExpectUser(Convert.ToUInt64((string)requestData["regionhandle"]), agentData); |
284 | } | 284 | } |
285 | else | 285 | else |
286 | { | 286 | { |
287 | MainLog.Instance.Error("ExpectUser() - Unknown region " + ((ulong)requestData["regionhandle"]).ToString()); | 287 | MainLog.Instance.Error("ExpectUser() - Unknown region " + ((ulong)requestData["regionhandle"]).ToString()); |
288 | } | 288 | } |
289 | 289 | ||
290 | MainLog.Instance.Verbose("ExpectUser() - Welcoming new user..."); | 290 | MainLog.Instance.Verbose("ExpectUser() - Welcoming new user..."); |
291 | 291 | ||
292 | return new XmlRpcResponse(); | 292 | return new XmlRpcResponse(); |
293 | } | 293 | } |
294 | 294 | ||
295 | #region InterRegion Comms | 295 | #region InterRegion Comms |
296 | /// <summary> | 296 | /// <summary> |
297 | /// | 297 | /// |
298 | /// </summary> | 298 | /// </summary> |
299 | private void StartRemoting() | 299 | private void StartRemoting() |
300 | { | 300 | { |
301 | TcpChannel ch = new TcpChannel(this.serversInfo.RemotingListenerPort); | 301 | TcpChannel ch = new TcpChannel(this.serversInfo.RemotingListenerPort); |
302 | ChannelServices.RegisterChannel(ch, true); | 302 | ChannelServices.RegisterChannel(ch, true); |
303 | 303 | ||
304 | WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton); | 304 | WellKnownServiceTypeEntry wellType = new WellKnownServiceTypeEntry(typeof(OGS1InterRegionRemoting), "InterRegions", WellKnownObjectMode.Singleton); |
305 | RemotingConfiguration.RegisterWellKnownServiceType(wellType); | 305 | RemotingConfiguration.RegisterWellKnownServiceType(wellType); |
306 | InterRegionSingleton.Instance.OnArrival += this.IncomingArrival; | 306 | InterRegionSingleton.Instance.OnArrival += this.IncomingArrival; |
307 | InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent; | 307 | InterRegionSingleton.Instance.OnChildAgent += this.IncomingChildAgent; |
308 | } | 308 | } |
309 | 309 | ||
310 | #region Methods called by regions in this instance | 310 | #region Methods called by regions in this instance |
311 | /// <summary> | 311 | /// <summary> |
312 | /// | 312 | /// |
313 | /// </summary> | 313 | /// </summary> |
314 | /// <param name="regionHandle"></param> | 314 | /// <param name="regionHandle"></param> |
315 | /// <param name="agentData"></param> | 315 | /// <param name="agentData"></param> |
316 | /// <returns></returns> | 316 | /// <returns></returns> |
317 | public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) | 317 | public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) |
318 | { | 318 | { |
319 | if (this.listeners.ContainsKey(regionHandle)) | 319 | if (this.listeners.ContainsKey(regionHandle)) |
320 | { | 320 | { |
321 | this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); | 321 | this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); |
322 | return true; | 322 | return true; |
323 | } | 323 | } |
324 | RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); | 324 | RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); |
325 | if (regInfo != null) | 325 | if (regInfo != null) |
326 | { | 326 | { |
327 | //don't want to be creating a new link to the remote instance every time like we are here | 327 | //don't want to be creating a new link to the remote instance every time like we are here |
328 | bool retValue = false; | 328 | bool retValue = false; |
329 | 329 | ||
330 | 330 | ||
331 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | 331 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( |
332 | typeof(OGS1InterRegionRemoting), | 332 | typeof(OGS1InterRegionRemoting), |
333 | "tcp://"+ regInfo.RemotingAddress+":"+regInfo.RemotingPort+"/InterRegions"); | 333 | "tcp://"+ regInfo.RemotingAddress+":"+regInfo.RemotingPort+"/InterRegions"); |
334 | if (remObject != null) | 334 | if (remObject != null) |
335 | { | 335 | { |
336 | 336 | ||
337 | retValue = remObject.InformRegionOfChildAgent(regionHandle, agentData); | 337 | retValue = remObject.InformRegionOfChildAgent(regionHandle, agentData); |
338 | } | 338 | } |
339 | else | 339 | else |
340 | { | 340 | { |
341 | Console.WriteLine("remoting object not found"); | 341 | Console.WriteLine("remoting object not found"); |
342 | } | 342 | } |
343 | remObject = null; | 343 | remObject = null; |
344 | 344 | ||
345 | 345 | ||
346 | return retValue; | 346 | return retValue; |
347 | } | 347 | } |
348 | 348 | ||
349 | return false; | 349 | return false; |
350 | } | 350 | } |
351 | 351 | ||
352 | /// <summary> | 352 | /// <summary> |
353 | /// | 353 | /// |
354 | /// </summary> | 354 | /// </summary> |
355 | /// <param name="regionHandle"></param> | 355 | /// <param name="regionHandle"></param> |
356 | /// <param name="agentID"></param> | 356 | /// <param name="agentID"></param> |
357 | /// <param name="position"></param> | 357 | /// <param name="position"></param> |
358 | /// <returns></returns> | 358 | /// <returns></returns> |
359 | public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) | 359 | public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position) |
360 | { | 360 | { |
361 | if (this.listeners.ContainsKey(regionHandle)) | 361 | if (this.listeners.ContainsKey(regionHandle)) |
362 | { | 362 | { |
363 | this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); | 363 | this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); |
364 | return true; | 364 | return true; |
365 | } | 365 | } |
366 | RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); | 366 | RegionInfo regInfo = this.RequestNeighbourInfo(regionHandle); |
367 | if (regInfo != null) | 367 | if (regInfo != null) |
368 | { | 368 | { |
369 | bool retValue = false; | 369 | bool retValue = false; |
370 | 370 | ||
371 | 371 | ||
372 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( | 372 | OGS1InterRegionRemoting remObject = (OGS1InterRegionRemoting)Activator.GetObject( |
373 | typeof(OGS1InterRegionRemoting), | 373 | typeof(OGS1InterRegionRemoting), |
374 | "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); | 374 | "tcp://" + regInfo.RemotingAddress + ":" + regInfo.RemotingPort + "/InterRegions"); |
375 | if (remObject != null) | 375 | if (remObject != null) |
376 | { | 376 | { |
377 | 377 | ||
378 | retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position); | 378 | retValue = remObject.ExpectAvatarCrossing(regionHandle, agentID, position); |
379 | } | 379 | } |
380 | else | 380 | else |
381 | { | 381 | { |
382 | Console.WriteLine("remoting object not found"); | 382 | Console.WriteLine("remoting object not found"); |
383 | } | 383 | } |
384 | remObject = null; | 384 | remObject = null; |
385 | 385 | ||
386 | 386 | ||
387 | return retValue; | 387 | return retValue; |
388 | } | 388 | } |
389 | //TODO need to see if we know about where this region is and use .net remoting | 389 | //TODO need to see if we know about where this region is and use .net remoting |
390 | // to inform it. | 390 | // to inform it. |
391 | return false; | 391 | return false; |
392 | } | 392 | } |
393 | #endregion | 393 | #endregion |
394 | 394 | ||
395 | #region Methods triggered by calls from external instances | 395 | #region Methods triggered by calls from external instances |
396 | /// <summary> | 396 | /// <summary> |
397 | /// | 397 | /// |
398 | /// </summary> | 398 | /// </summary> |
399 | /// <param name="regionHandle"></param> | 399 | /// <param name="regionHandle"></param> |
400 | /// <param name="agentData"></param> | 400 | /// <param name="agentData"></param> |
401 | /// <returns></returns> | 401 | /// <returns></returns> |
402 | public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) | 402 | public bool IncomingChildAgent(ulong regionHandle, AgentCircuitData agentData) |
403 | { | 403 | { |
404 | if (this.listeners.ContainsKey(regionHandle)) | 404 | if (this.listeners.ContainsKey(regionHandle)) |
405 | { | 405 | { |
406 | this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); | 406 | this.listeners[regionHandle].TriggerExpectUser(regionHandle, agentData); |
407 | return true; | 407 | return true; |
408 | } | 408 | } |
409 | return false; | 409 | return false; |
410 | } | 410 | } |
411 | 411 | ||
412 | /// <summary> | 412 | /// <summary> |
413 | /// | 413 | /// |
414 | /// </summary> | 414 | /// </summary> |
415 | /// <param name="regionHandle"></param> | 415 | /// <param name="regionHandle"></param> |
416 | /// <param name="agentID"></param> | 416 | /// <param name="agentID"></param> |
417 | /// <param name="position"></param> | 417 | /// <param name="position"></param> |
418 | /// <returns></returns> | 418 | /// <returns></returns> |
419 | public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position) | 419 | public bool IncomingArrival(ulong regionHandle, LLUUID agentID, LLVector3 position) |
420 | { | 420 | { |
421 | if (this.listeners.ContainsKey(regionHandle)) | 421 | if (this.listeners.ContainsKey(regionHandle)) |
422 | { | 422 | { |
423 | this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); | 423 | this.listeners[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position); |
424 | return true; | 424 | return true; |
425 | } | 425 | } |
426 | return false; | 426 | return false; |
427 | } | 427 | } |
428 | #endregion | 428 | #endregion |
429 | #endregion | 429 | #endregion |
430 | } | 430 | } |
431 | } | 431 | } |