diff options
author | Melanie | 2010-02-08 15:53:20 +0000 |
---|---|---|
committer | Melanie | 2010-02-08 15:53:38 +0000 |
commit | baaf660511214e52ea4ed20b8e80ec8e1ff06a3a (patch) | |
tree | 1e90c7a22ea3354d6bfd5d2b3f8f64f199dbd477 /OpenSim/Framework | |
parent | Added missing configs to Standalone.ini (diff) | |
parent | Adding the Careminster "Configger" tool to OpenSim. The tool will, when launched (diff) | |
download | opensim-SC_OLD-baaf660511214e52ea4ed20b8e80ec8e1ff06a3a.zip opensim-SC_OLD-baaf660511214e52ea4ed20b8e80ec8e1ff06a3a.tar.gz opensim-SC_OLD-baaf660511214e52ea4ed20b8e80ec8e1ff06a3a.tar.bz2 opensim-SC_OLD-baaf660511214e52ea4ed20b8e80ec8e1ff06a3a.tar.xz |
Merge branch 'master' into presence-refactor
This was a large, heavily conflicted merge and things MAY have got broken.
Please check!
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Communications/Clients/RegionClient.cs | 755 | ||||
-rwxr-xr-x[-rw-r--r--] | OpenSim/Framework/Console/ConsoleBase.cs | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | OpenSim/Framework/Console/ConsolePluginCommand.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Console/RemoteConsole.cs | 6 |
4 files changed, 763 insertions, 2 deletions
diff --git a/OpenSim/Framework/Communications/Clients/RegionClient.cs b/OpenSim/Framework/Communications/Clients/RegionClient.cs new file mode 100644 index 0000000..ee7dec8 --- /dev/null +++ b/OpenSim/Framework/Communications/Clients/RegionClient.cs | |||
@@ -0,0 +1,755 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.IO; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | |||
35 | using OpenMetaverse; | ||
36 | using OpenMetaverse.StructuredData; | ||
37 | |||
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
39 | |||
40 | using log4net; | ||
41 | |||
42 | namespace OpenSim.Framework.Communications.Clients | ||
43 | { | ||
44 | public class RegionClient | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | public bool DoCreateChildAgentCall(GridRegion region, AgentCircuitData aCircuit, string authKey, uint teleportFlags, out string reason) | ||
49 | { | ||
50 | reason = String.Empty; | ||
51 | |||
52 | // Eventually, we want to use a caps url instead of the agentID | ||
53 | string uri = string.Empty; | ||
54 | try | ||
55 | { | ||
56 | uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + aCircuit.AgentID + "/"; | ||
57 | } | ||
58 | catch (Exception e) | ||
59 | { | ||
60 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent create. Reason: " + e.Message); | ||
61 | reason = e.Message; | ||
62 | return false; | ||
63 | } | ||
64 | |||
65 | //Console.WriteLine(" >>> DoCreateChildAgentCall <<< " + uri); | ||
66 | |||
67 | HttpWebRequest AgentCreateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
68 | AgentCreateRequest.Method = "POST"; | ||
69 | AgentCreateRequest.ContentType = "application/json"; | ||
70 | AgentCreateRequest.Timeout = 10000; | ||
71 | //AgentCreateRequest.KeepAlive = false; | ||
72 | AgentCreateRequest.Headers.Add("Authorization", authKey); | ||
73 | |||
74 | // Fill it in | ||
75 | OSDMap args = null; | ||
76 | try | ||
77 | { | ||
78 | args = aCircuit.PackAgentCircuitData(); | ||
79 | } | ||
80 | catch (Exception e) | ||
81 | { | ||
82 | m_log.Debug("[REST COMMS]: PackAgentCircuitData failed with exception: " + e.Message); | ||
83 | } | ||
84 | // Add the regionhandle of the destination region | ||
85 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
86 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | ||
87 | args["teleport_flags"] = OSD.FromString(teleportFlags.ToString()); | ||
88 | |||
89 | string strBuffer = ""; | ||
90 | byte[] buffer = new byte[1]; | ||
91 | try | ||
92 | { | ||
93 | strBuffer = OSDParser.SerializeJsonString(args); | ||
94 | Encoding str = Util.UTF8; | ||
95 | buffer = str.GetBytes(strBuffer); | ||
96 | |||
97 | } | ||
98 | catch (Exception e) | ||
99 | { | ||
100 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildCreate: {0}", e.Message); | ||
101 | // ignore. buffer will be empty, caller should check. | ||
102 | } | ||
103 | |||
104 | Stream os = null; | ||
105 | try | ||
106 | { // send the Post | ||
107 | AgentCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
108 | os = AgentCreateRequest.GetRequestStream(); | ||
109 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
110 | //m_log.InfoFormat("[REST COMMS]: Posted CreateChildAgent request to remote sim {0}", uri); | ||
111 | } | ||
112 | //catch (WebException ex) | ||
113 | catch | ||
114 | { | ||
115 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
116 | reason = "cannot contact remote region"; | ||
117 | return false; | ||
118 | } | ||
119 | finally | ||
120 | { | ||
121 | if (os != null) | ||
122 | os.Close(); | ||
123 | } | ||
124 | |||
125 | // Let's wait for the response | ||
126 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | ||
127 | |||
128 | WebResponse webResponse = null; | ||
129 | StreamReader sr = null; | ||
130 | try | ||
131 | { | ||
132 | webResponse = AgentCreateRequest.GetResponse(); | ||
133 | if (webResponse == null) | ||
134 | { | ||
135 | m_log.Info("[REST COMMS]: Null reply on DoCreateChildAgentCall post"); | ||
136 | } | ||
137 | else | ||
138 | { | ||
139 | |||
140 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
141 | string response = sr.ReadToEnd().Trim(); | ||
142 | m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", response); | ||
143 | |||
144 | if (!String.IsNullOrEmpty(response)) | ||
145 | { | ||
146 | try | ||
147 | { | ||
148 | // we assume we got an OSDMap back | ||
149 | OSDMap r = GetOSDMap(response); | ||
150 | bool success = r["success"].AsBoolean(); | ||
151 | reason = r["reason"].AsString(); | ||
152 | return success; | ||
153 | } | ||
154 | catch (NullReferenceException e) | ||
155 | { | ||
156 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", e.Message); | ||
157 | |||
158 | // check for old style response | ||
159 | if (response.ToLower().StartsWith("true")) | ||
160 | return true; | ||
161 | |||
162 | return false; | ||
163 | } | ||
164 | } | ||
165 | } | ||
166 | } | ||
167 | catch (WebException ex) | ||
168 | { | ||
169 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateChildAgentCall {0}", ex.Message); | ||
170 | // ignore, really | ||
171 | } | ||
172 | finally | ||
173 | { | ||
174 | if (sr != null) | ||
175 | sr.Close(); | ||
176 | } | ||
177 | |||
178 | return true; | ||
179 | |||
180 | } | ||
181 | |||
182 | public bool DoChildAgentUpdateCall(GridRegion region, IAgentData cAgentData) | ||
183 | { | ||
184 | // Eventually, we want to use a caps url instead of the agentID | ||
185 | string uri = string.Empty; | ||
186 | try | ||
187 | { | ||
188 | uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + cAgentData.AgentID + "/"; | ||
189 | } | ||
190 | catch (Exception e) | ||
191 | { | ||
192 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent update. Reason: " + e.Message); | ||
193 | return false; | ||
194 | } | ||
195 | //Console.WriteLine(" >>> DoChildAgentUpdateCall <<< " + uri); | ||
196 | |||
197 | HttpWebRequest ChildUpdateRequest = (HttpWebRequest)WebRequest.Create(uri); | ||
198 | ChildUpdateRequest.Method = "PUT"; | ||
199 | ChildUpdateRequest.ContentType = "application/json"; | ||
200 | ChildUpdateRequest.Timeout = 10000; | ||
201 | //ChildUpdateRequest.KeepAlive = false; | ||
202 | |||
203 | // Fill it in | ||
204 | OSDMap args = null; | ||
205 | try | ||
206 | { | ||
207 | args = cAgentData.Pack(); | ||
208 | } | ||
209 | catch (Exception e) | ||
210 | { | ||
211 | m_log.Debug("[REST COMMS]: PackUpdateMessage failed with exception: " + e.Message); | ||
212 | } | ||
213 | // Add the regionhandle of the destination region | ||
214 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
215 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | ||
216 | |||
217 | string strBuffer = ""; | ||
218 | byte[] buffer = new byte[1]; | ||
219 | try | ||
220 | { | ||
221 | strBuffer = OSDParser.SerializeJsonString(args); | ||
222 | Encoding str = Util.UTF8; | ||
223 | buffer = str.GetBytes(strBuffer); | ||
224 | |||
225 | } | ||
226 | catch (Exception e) | ||
227 | { | ||
228 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of ChildUpdate: {0}", e.Message); | ||
229 | // ignore. buffer will be empty, caller should check. | ||
230 | } | ||
231 | |||
232 | Stream os = null; | ||
233 | try | ||
234 | { // send the Post | ||
235 | ChildUpdateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
236 | os = ChildUpdateRequest.GetRequestStream(); | ||
237 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
238 | //m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); | ||
239 | } | ||
240 | //catch (WebException ex) | ||
241 | catch | ||
242 | { | ||
243 | //m_log.InfoFormat("[REST COMMS]: Bad send on ChildAgentUpdate {0}", ex.Message); | ||
244 | |||
245 | return false; | ||
246 | } | ||
247 | finally | ||
248 | { | ||
249 | if (os != null) | ||
250 | os.Close(); | ||
251 | } | ||
252 | |||
253 | // Let's wait for the response | ||
254 | //m_log.Info("[REST COMMS]: Waiting for a reply after ChildAgentUpdate"); | ||
255 | |||
256 | WebResponse webResponse = null; | ||
257 | StreamReader sr = null; | ||
258 | try | ||
259 | { | ||
260 | webResponse = ChildUpdateRequest.GetResponse(); | ||
261 | if (webResponse == null) | ||
262 | { | ||
263 | m_log.Info("[REST COMMS]: Null reply on ChilAgentUpdate post"); | ||
264 | } | ||
265 | |||
266 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
267 | //reply = sr.ReadToEnd().Trim(); | ||
268 | sr.ReadToEnd().Trim(); | ||
269 | sr.Close(); | ||
270 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | ||
271 | |||
272 | } | ||
273 | catch (WebException ex) | ||
274 | { | ||
275 | m_log.InfoFormat("[REST COMMS]: exception on reply of ChilAgentUpdate {0}", ex.Message); | ||
276 | // ignore, really | ||
277 | } | ||
278 | finally | ||
279 | { | ||
280 | if (sr != null) | ||
281 | sr.Close(); | ||
282 | } | ||
283 | |||
284 | return true; | ||
285 | } | ||
286 | |||
287 | public bool DoRetrieveRootAgentCall(GridRegion region, UUID id, out IAgentData agent) | ||
288 | { | ||
289 | agent = null; | ||
290 | // Eventually, we want to use a caps url instead of the agentID | ||
291 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; | ||
292 | //Console.WriteLine(" >>> DoRetrieveRootAgentCall <<< " + uri); | ||
293 | |||
294 | HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); | ||
295 | request.Method = "GET"; | ||
296 | request.Timeout = 10000; | ||
297 | //request.Headers.Add("authorization", ""); // coming soon | ||
298 | |||
299 | HttpWebResponse webResponse = null; | ||
300 | string reply = string.Empty; | ||
301 | StreamReader sr = null; | ||
302 | try | ||
303 | { | ||
304 | webResponse = (HttpWebResponse)request.GetResponse(); | ||
305 | if (webResponse == null) | ||
306 | { | ||
307 | m_log.Info("[REST COMMS]: Null reply on agent get "); | ||
308 | } | ||
309 | |||
310 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
311 | reply = sr.ReadToEnd().Trim(); | ||
312 | |||
313 | //Console.WriteLine("[REST COMMS]: ChilAgentUpdate reply was " + reply); | ||
314 | |||
315 | } | ||
316 | catch (WebException ex) | ||
317 | { | ||
318 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent get {0}", ex.Message); | ||
319 | // ignore, really | ||
320 | return false; | ||
321 | } | ||
322 | finally | ||
323 | { | ||
324 | if (sr != null) | ||
325 | sr.Close(); | ||
326 | } | ||
327 | |||
328 | if (webResponse.StatusCode == HttpStatusCode.OK) | ||
329 | { | ||
330 | // we know it's jason | ||
331 | OSDMap args = GetOSDMap(reply); | ||
332 | if (args == null) | ||
333 | { | ||
334 | //Console.WriteLine("[REST COMMS]: Error getting OSDMap from reply"); | ||
335 | return false; | ||
336 | } | ||
337 | |||
338 | agent = new CompleteAgentData(); | ||
339 | agent.Unpack(args); | ||
340 | return true; | ||
341 | } | ||
342 | |||
343 | //Console.WriteLine("[REST COMMS]: DoRetrieveRootAgentCall returned status " + webResponse.StatusCode); | ||
344 | return false; | ||
345 | } | ||
346 | |||
347 | public bool DoReleaseAgentCall(ulong regionHandle, UUID id, string uri) | ||
348 | { | ||
349 | //m_log.Debug(" >>> DoReleaseAgentCall <<< " + uri); | ||
350 | |||
351 | WebRequest request = WebRequest.Create(uri); | ||
352 | request.Method = "DELETE"; | ||
353 | request.Timeout = 10000; | ||
354 | |||
355 | StreamReader sr = null; | ||
356 | try | ||
357 | { | ||
358 | WebResponse webResponse = request.GetResponse(); | ||
359 | if (webResponse == null) | ||
360 | { | ||
361 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | ||
362 | } | ||
363 | |||
364 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
365 | //reply = sr.ReadToEnd().Trim(); | ||
366 | sr.ReadToEnd().Trim(); | ||
367 | sr.Close(); | ||
368 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | ||
369 | |||
370 | } | ||
371 | catch (WebException ex) | ||
372 | { | ||
373 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | ||
374 | // ignore, really | ||
375 | } | ||
376 | finally | ||
377 | { | ||
378 | if (sr != null) | ||
379 | sr.Close(); | ||
380 | } | ||
381 | |||
382 | return true; | ||
383 | } | ||
384 | |||
385 | |||
386 | public bool DoCloseAgentCall(GridRegion region, UUID id) | ||
387 | { | ||
388 | string uri = string.Empty; | ||
389 | try | ||
390 | { | ||
391 | uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/agent/" + id + "/" + region.RegionHandle.ToString() + "/"; | ||
392 | } | ||
393 | catch (Exception e) | ||
394 | { | ||
395 | m_log.Debug("[REST COMMS]: Unable to resolve external endpoint on agent close. Reason: " + e.Message); | ||
396 | return false; | ||
397 | } | ||
398 | |||
399 | //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri); | ||
400 | |||
401 | WebRequest request = WebRequest.Create(uri); | ||
402 | request.Method = "DELETE"; | ||
403 | request.Timeout = 10000; | ||
404 | |||
405 | StreamReader sr = null; | ||
406 | try | ||
407 | { | ||
408 | WebResponse webResponse = request.GetResponse(); | ||
409 | if (webResponse == null) | ||
410 | { | ||
411 | m_log.Info("[REST COMMS]: Null reply on agent delete "); | ||
412 | } | ||
413 | |||
414 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
415 | //reply = sr.ReadToEnd().Trim(); | ||
416 | sr.ReadToEnd().Trim(); | ||
417 | sr.Close(); | ||
418 | //m_log.InfoFormat("[REST COMMS]: ChilAgentUpdate reply was {0} ", reply); | ||
419 | |||
420 | } | ||
421 | catch (WebException ex) | ||
422 | { | ||
423 | m_log.InfoFormat("[REST COMMS]: exception on reply of agent delete {0}", ex.Message); | ||
424 | // ignore, really | ||
425 | } | ||
426 | finally | ||
427 | { | ||
428 | if (sr != null) | ||
429 | sr.Close(); | ||
430 | } | ||
431 | |||
432 | return true; | ||
433 | } | ||
434 | |||
435 | public bool DoCreateObjectCall(GridRegion region, ISceneObject sog, string sogXml2, bool allowScriptCrossing) | ||
436 | { | ||
437 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
438 | string uri | ||
439 | = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort | ||
440 | + "/object/" + sog.UUID + "/" + regionHandle.ToString() + "/"; | ||
441 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); | ||
442 | |||
443 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); | ||
444 | ObjectCreateRequest.Method = "POST"; | ||
445 | ObjectCreateRequest.ContentType = "application/json"; | ||
446 | ObjectCreateRequest.Timeout = 10000; | ||
447 | |||
448 | OSDMap args = new OSDMap(2); | ||
449 | args["sog"] = OSD.FromString(sogXml2); | ||
450 | args["extra"] = OSD.FromString(sog.ExtraToXmlString()); | ||
451 | if (allowScriptCrossing) | ||
452 | { | ||
453 | string state = sog.GetStateSnapshot(); | ||
454 | if (state.Length > 0) | ||
455 | args["state"] = OSD.FromString(state); | ||
456 | } | ||
457 | |||
458 | string strBuffer = ""; | ||
459 | byte[] buffer = new byte[1]; | ||
460 | try | ||
461 | { | ||
462 | strBuffer = OSDParser.SerializeJsonString(args); | ||
463 | Encoding str = Util.UTF8; | ||
464 | buffer = str.GetBytes(strBuffer); | ||
465 | |||
466 | } | ||
467 | catch (Exception e) | ||
468 | { | ||
469 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | ||
470 | // ignore. buffer will be empty, caller should check. | ||
471 | } | ||
472 | |||
473 | Stream os = null; | ||
474 | try | ||
475 | { // send the Post | ||
476 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
477 | os = ObjectCreateRequest.GetRequestStream(); | ||
478 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
479 | m_log.InfoFormat("[REST COMMS]: Posted ChildAgentUpdate request to remote sim {0}", uri); | ||
480 | } | ||
481 | //catch (WebException ex) | ||
482 | catch | ||
483 | { | ||
484 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); | ||
485 | |||
486 | return false; | ||
487 | } | ||
488 | finally | ||
489 | { | ||
490 | if (os != null) | ||
491 | os.Close(); | ||
492 | } | ||
493 | |||
494 | // Let's wait for the response | ||
495 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | ||
496 | |||
497 | StreamReader sr = null; | ||
498 | try | ||
499 | { | ||
500 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | ||
501 | if (webResponse == null) | ||
502 | { | ||
503 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | ||
504 | } | ||
505 | |||
506 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
507 | //reply = sr.ReadToEnd().Trim(); | ||
508 | sr.ReadToEnd().Trim(); | ||
509 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | ||
510 | |||
511 | } | ||
512 | catch (WebException ex) | ||
513 | { | ||
514 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | ||
515 | // ignore, really | ||
516 | } | ||
517 | finally | ||
518 | { | ||
519 | if (sr != null) | ||
520 | sr.Close(); | ||
521 | } | ||
522 | |||
523 | return true; | ||
524 | |||
525 | } | ||
526 | |||
527 | public bool DoCreateObjectCall(GridRegion region, UUID userID, UUID itemID) | ||
528 | { | ||
529 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
530 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/object/" + UUID.Zero + "/" + regionHandle.ToString() + "/"; | ||
531 | //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri); | ||
532 | |||
533 | WebRequest ObjectCreateRequest = WebRequest.Create(uri); | ||
534 | ObjectCreateRequest.Method = "PUT"; | ||
535 | ObjectCreateRequest.ContentType = "application/json"; | ||
536 | ObjectCreateRequest.Timeout = 10000; | ||
537 | |||
538 | OSDMap args = new OSDMap(2); | ||
539 | args["userid"] = OSD.FromUUID(userID); | ||
540 | args["itemid"] = OSD.FromUUID(itemID); | ||
541 | |||
542 | string strBuffer = ""; | ||
543 | byte[] buffer = new byte[1]; | ||
544 | try | ||
545 | { | ||
546 | strBuffer = OSDParser.SerializeJsonString(args); | ||
547 | Encoding str = Util.UTF8; | ||
548 | buffer = str.GetBytes(strBuffer); | ||
549 | |||
550 | } | ||
551 | catch (Exception e) | ||
552 | { | ||
553 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of CreateObject: {0}", e.Message); | ||
554 | // ignore. buffer will be empty, caller should check. | ||
555 | } | ||
556 | |||
557 | Stream os = null; | ||
558 | try | ||
559 | { // send the Post | ||
560 | ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send | ||
561 | os = ObjectCreateRequest.GetRequestStream(); | ||
562 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
563 | //m_log.InfoFormat("[REST COMMS]: Posted CreateObject request to remote sim {0}", uri); | ||
564 | } | ||
565 | //catch (WebException ex) | ||
566 | catch | ||
567 | { | ||
568 | // m_log.InfoFormat("[REST COMMS]: Bad send on CreateObject {0}", ex.Message); | ||
569 | |||
570 | return false; | ||
571 | } | ||
572 | finally | ||
573 | { | ||
574 | if (os != null) | ||
575 | os.Close(); | ||
576 | } | ||
577 | |||
578 | // Let's wait for the response | ||
579 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoCreateChildAgentCall"); | ||
580 | |||
581 | StreamReader sr = null; | ||
582 | try | ||
583 | { | ||
584 | WebResponse webResponse = ObjectCreateRequest.GetResponse(); | ||
585 | if (webResponse == null) | ||
586 | { | ||
587 | m_log.Info("[REST COMMS]: Null reply on DoCreateObjectCall post"); | ||
588 | } | ||
589 | |||
590 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
591 | sr.ReadToEnd().Trim(); | ||
592 | sr.ReadToEnd().Trim(); | ||
593 | |||
594 | //m_log.InfoFormat("[REST COMMS]: DoCreateChildAgentCall reply was {0} ", reply); | ||
595 | |||
596 | } | ||
597 | catch (WebException ex) | ||
598 | { | ||
599 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoCreateObjectCall {0}", ex.Message); | ||
600 | // ignore, really | ||
601 | } | ||
602 | finally | ||
603 | { | ||
604 | if (sr != null) | ||
605 | sr.Close(); | ||
606 | } | ||
607 | |||
608 | return true; | ||
609 | |||
610 | } | ||
611 | |||
612 | public bool DoHelloNeighbourCall(RegionInfo region, RegionInfo thisRegion) | ||
613 | { | ||
614 | string uri = "http://" + region.ExternalEndPoint.Address + ":" + region.HttpPort + "/region/" + thisRegion.RegionID + "/"; | ||
615 | //m_log.Debug(" >>> DoHelloNeighbourCall <<< " + uri); | ||
616 | |||
617 | WebRequest HelloNeighbourRequest = WebRequest.Create(uri); | ||
618 | HelloNeighbourRequest.Method = "POST"; | ||
619 | HelloNeighbourRequest.ContentType = "application/json"; | ||
620 | HelloNeighbourRequest.Timeout = 10000; | ||
621 | |||
622 | // Fill it in | ||
623 | OSDMap args = null; | ||
624 | try | ||
625 | { | ||
626 | args = thisRegion.PackRegionInfoData(); | ||
627 | } | ||
628 | catch (Exception e) | ||
629 | { | ||
630 | m_log.Debug("[REST COMMS]: PackRegionInfoData failed with exception: " + e.Message); | ||
631 | } | ||
632 | // Add the regionhandle of the destination region | ||
633 | ulong regionHandle = GetRegionHandle(region.RegionHandle); | ||
634 | args["destination_handle"] = OSD.FromString(regionHandle.ToString()); | ||
635 | |||
636 | string strBuffer = ""; | ||
637 | byte[] buffer = new byte[1]; | ||
638 | try | ||
639 | { | ||
640 | strBuffer = OSDParser.SerializeJsonString(args); | ||
641 | Encoding str = Util.UTF8; | ||
642 | buffer = str.GetBytes(strBuffer); | ||
643 | |||
644 | } | ||
645 | catch (Exception e) | ||
646 | { | ||
647 | m_log.WarnFormat("[REST COMMS]: Exception thrown on serialization of HelloNeighbour: {0}", e.Message); | ||
648 | // ignore. buffer will be empty, caller should check. | ||
649 | } | ||
650 | |||
651 | Stream os = null; | ||
652 | try | ||
653 | { // send the Post | ||
654 | HelloNeighbourRequest.ContentLength = buffer.Length; //Count bytes to send | ||
655 | os = HelloNeighbourRequest.GetRequestStream(); | ||
656 | os.Write(buffer, 0, strBuffer.Length); //Send it | ||
657 | //m_log.InfoFormat("[REST COMMS]: Posted HelloNeighbour request to remote sim {0}", uri); | ||
658 | } | ||
659 | //catch (WebException ex) | ||
660 | catch | ||
661 | { | ||
662 | //m_log.InfoFormat("[REST COMMS]: Bad send on HelloNeighbour {0}", ex.Message); | ||
663 | |||
664 | return false; | ||
665 | } | ||
666 | finally | ||
667 | { | ||
668 | if (os != null) | ||
669 | os.Close(); | ||
670 | } | ||
671 | // Let's wait for the response | ||
672 | //m_log.Info("[REST COMMS]: Waiting for a reply after DoHelloNeighbourCall"); | ||
673 | |||
674 | StreamReader sr = null; | ||
675 | try | ||
676 | { | ||
677 | WebResponse webResponse = HelloNeighbourRequest.GetResponse(); | ||
678 | if (webResponse == null) | ||
679 | { | ||
680 | m_log.Info("[REST COMMS]: Null reply on DoHelloNeighbourCall post"); | ||
681 | } | ||
682 | |||
683 | sr = new StreamReader(webResponse.GetResponseStream()); | ||
684 | //reply = sr.ReadToEnd().Trim(); | ||
685 | sr.ReadToEnd().Trim(); | ||
686 | //m_log.InfoFormat("[REST COMMS]: DoHelloNeighbourCall reply was {0} ", reply); | ||
687 | |||
688 | } | ||
689 | catch (WebException ex) | ||
690 | { | ||
691 | m_log.InfoFormat("[REST COMMS]: exception on reply of DoHelloNeighbourCall {0}", ex.Message); | ||
692 | // ignore, really | ||
693 | } | ||
694 | finally | ||
695 | { | ||
696 | if (sr != null) | ||
697 | sr.Close(); | ||
698 | } | ||
699 | |||
700 | return true; | ||
701 | |||
702 | } | ||
703 | |||
704 | #region Hyperlinks | ||
705 | |||
706 | public virtual ulong GetRegionHandle(ulong handle) | ||
707 | { | ||
708 | return handle; | ||
709 | } | ||
710 | |||
711 | public virtual bool IsHyperlink(ulong handle) | ||
712 | { | ||
713 | return false; | ||
714 | } | ||
715 | |||
716 | public virtual void SendUserInformation(GridRegion regInfo, AgentCircuitData aCircuit) | ||
717 | { | ||
718 | } | ||
719 | |||
720 | public virtual void AdjustUserInformation(AgentCircuitData aCircuit) | ||
721 | { | ||
722 | } | ||
723 | |||
724 | #endregion /* Hyperlinks */ | ||
725 | |||
726 | public static OSDMap GetOSDMap(string data) | ||
727 | { | ||
728 | OSDMap args = null; | ||
729 | try | ||
730 | { | ||
731 | OSD buffer; | ||
732 | // We should pay attention to the content-type, but let's assume we know it's Json | ||
733 | buffer = OSDParser.DeserializeJson(data); | ||
734 | if (buffer.Type == OSDType.Map) | ||
735 | { | ||
736 | args = (OSDMap)buffer; | ||
737 | return args; | ||
738 | } | ||
739 | else | ||
740 | { | ||
741 | // uh? | ||
742 | System.Console.WriteLine("[REST COMMS]: Got OSD of type " + buffer.Type.ToString()); | ||
743 | return null; | ||
744 | } | ||
745 | } | ||
746 | catch (Exception ex) | ||
747 | { | ||
748 | System.Console.WriteLine("[REST COMMS]: exception on parse of REST message " + ex.Message); | ||
749 | return null; | ||
750 | } | ||
751 | } | ||
752 | |||
753 | |||
754 | } | ||
755 | } | ||
diff --git a/OpenSim/Framework/Console/ConsoleBase.cs b/OpenSim/Framework/Console/ConsoleBase.cs index 0a51266..b70d1db 100644..100755 --- a/OpenSim/Framework/Console/ConsoleBase.cs +++ b/OpenSim/Framework/Console/ConsoleBase.cs | |||
@@ -73,7 +73,7 @@ namespace OpenSim.Framework.Console | |||
73 | 73 | ||
74 | public virtual void Output(string text) | 74 | public virtual void Output(string text) |
75 | { | 75 | { |
76 | System.Console.Write(text); | 76 | System.Console.WriteLine(text); |
77 | } | 77 | } |
78 | 78 | ||
79 | public string CmdPrompt(string p) | 79 | public string CmdPrompt(string p) |
diff --git a/OpenSim/Framework/Console/ConsolePluginCommand.cs b/OpenSim/Framework/Console/ConsolePluginCommand.cs index a2f31ea..f4d3687 100644..100755 --- a/OpenSim/Framework/Console/ConsolePluginCommand.cs +++ b/OpenSim/Framework/Console/ConsolePluginCommand.cs | |||
@@ -124,7 +124,7 @@ namespace OpenSim.Framework.Console | |||
124 | /// </summary> | 124 | /// </summary> |
125 | public void ShowHelp(ConsoleBase console) | 125 | public void ShowHelp(ConsoleBase console) |
126 | { | 126 | { |
127 | console.Output(String.Join(" ", m_cmdText) + " - " + m_helpText); | 127 | console.Output(String.Join(" ", m_cmdText) + " - " + m_helpText + "\n"); |
128 | } | 128 | } |
129 | 129 | ||
130 | /// <summary> | 130 | /// <summary> |
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index c27072c..9fdd1b8 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs | |||
@@ -302,6 +302,12 @@ namespace OpenSim.Framework.Console | |||
302 | if (!UUID.TryParse(post["ID"].ToString(), out id)) | 302 | if (!UUID.TryParse(post["ID"].ToString(), out id)) |
303 | return reply; | 303 | return reply; |
304 | 304 | ||
305 | lock(m_Connections) | ||
306 | { | ||
307 | if(!m_Connections.ContainsKey(id)) | ||
308 | return reply; | ||
309 | } | ||
310 | |||
305 | if (post["COMMAND"] == null || post["COMMAND"].ToString() == String.Empty) | 311 | if (post["COMMAND"] == null || post["COMMAND"].ToString() == String.Empty) |
306 | return reply; | 312 | return reply; |
307 | 313 | ||