aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
authorDiva Canto2010-01-07 15:53:55 -0800
committerDiva Canto2010-01-07 15:53:55 -0800
commitf11a97f12d328af8bb39b92fec5cb5780983b66a (patch)
tree00f96f853b91e105786b416dd18f2c76e56fd1fd /OpenSim/Services
parentMerge branch 'master' into presence-refactor (diff)
downloadopensim-SC_OLD-f11a97f12d328af8bb39b92fec5cb5780983b66a.zip
opensim-SC_OLD-f11a97f12d328af8bb39b92fec5cb5780983b66a.tar.gz
opensim-SC_OLD-f11a97f12d328af8bb39b92fec5cb5780983b66a.tar.bz2
opensim-SC_OLD-f11a97f12d328af8bb39b92fec5cb5780983b66a.tar.xz
* Finished SimulationServiceConnector
* Started rerouting calls to UserService. * Compiles. May run.
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs169
-rw-r--r--OpenSim/Services/Interfaces/ISimulationService.cs2
2 files changed, 166 insertions, 5 deletions
diff --git a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
index dc532d0..76558aa 100644
--- a/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs
@@ -385,14 +385,89 @@ namespace OpenSim.Services.Connectors.Simulation
385 return false; 385 return false;
386 } 386 }
387 387
388 public bool ReleaseAgent(GridRegion destination, UUID id, string uri) 388 public bool ReleaseAgent(UUID origin, UUID id, string uri)
389 { 389 {
390 return false; 390 WebRequest request = WebRequest.Create(uri);
391 request.Method = "DELETE";
392 request.Timeout = 10000;
393
394 StreamReader sr = null;
395 try
396 {
397 WebResponse webResponse = request.GetResponse();
398 if (webResponse == null)
399 {
400 m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on ReleaseAgent");
401 }
402
403 sr = new StreamReader(webResponse.GetResponseStream());
404 //reply = sr.ReadToEnd().Trim();
405 sr.ReadToEnd().Trim();
406 sr.Close();
407 //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply);
408
409 }
410 catch (WebException ex)
411 {
412 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of ReleaseAgent {0}", ex.Message);
413 return false;
414 }
415 finally
416 {
417 if (sr != null)
418 sr.Close();
419 }
420
421 return true;
391 } 422 }
392 423
393 public bool CloseAgent(GridRegion destination, UUID id) 424 public bool CloseAgent(GridRegion destination, UUID id)
394 { 425 {
395 return false; 426 string uri = string.Empty;
427 try
428 {
429 uri = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/agent/" + id + "/" + destination.RegionHandle.ToString() + "/";
430 }
431 catch (Exception e)
432 {
433 m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Unable to resolve external endpoint on agent close. Reason: " + e.Message);
434 return false;
435 }
436
437 //Console.WriteLine(" >>> DoCloseAgentCall <<< " + uri);
438
439 WebRequest request = WebRequest.Create(uri);
440 request.Method = "DELETE";
441 request.Timeout = 10000;
442
443 StreamReader sr = null;
444 try
445 {
446 WebResponse webResponse = request.GetResponse();
447 if (webResponse == null)
448 {
449 m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on agent delete ");
450 }
451
452 sr = new StreamReader(webResponse.GetResponseStream());
453 //reply = sr.ReadToEnd().Trim();
454 sr.ReadToEnd().Trim();
455 sr.Close();
456 //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: ChilAgentUpdate reply was {0} ", reply);
457
458 }
459 catch (WebException ex)
460 {
461 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of agent delete {0}", ex.Message);
462 return false;
463 }
464 finally
465 {
466 if (sr != null)
467 sr.Close();
468 }
469
470 return true;
396 } 471 }
397 472
398 #endregion Agents 473 #endregion Agents
@@ -401,11 +476,97 @@ namespace OpenSim.Services.Connectors.Simulation
401 476
402 public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall) 477 public bool CreateObject(GridRegion destination, ISceneObject sog, bool isLocalCall)
403 { 478 {
404 return false; 479 string uri
480 = "http://" + destination.ExternalEndPoint.Address + ":" + destination.HttpPort + "/object/" + sog.UUID + "/";
481 //m_log.Debug(" >>> DoCreateChildAgentCall <<< " + uri);
482
483 WebRequest ObjectCreateRequest = WebRequest.Create(uri);
484 ObjectCreateRequest.Method = "POST";
485 ObjectCreateRequest.ContentType = "application/json";
486 ObjectCreateRequest.Timeout = 10000;
487
488 OSDMap args = new OSDMap(2);
489 args["sog"] = OSD.FromString(sog.ToXml2());
490 args["extra"] = OSD.FromString(sog.ExtraToXmlString());
491 string state = sog.GetStateSnapshot();
492 if (state.Length > 0)
493 args["state"] = OSD.FromString(state);
494 // Add the input general arguments
495 args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
496 args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
497 args["destination_name"] = OSD.FromString(destination.RegionName);
498 args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
499
500 string strBuffer = "";
501 byte[] buffer = new byte[1];
502 try
503 {
504 strBuffer = OSDParser.SerializeJsonString(args);
505 Encoding str = Util.UTF8;
506 buffer = str.GetBytes(strBuffer);
507
508 }
509 catch (Exception e)
510 {
511 m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR]: Exception thrown on serialization of CreateObject: {0}", e.Message);
512 // ignore. buffer will be empty, caller should check.
513 }
514
515 Stream os = null;
516 try
517 { // send the Post
518 ObjectCreateRequest.ContentLength = buffer.Length; //Count bytes to send
519 os = ObjectCreateRequest.GetRequestStream();
520 os.Write(buffer, 0, strBuffer.Length); //Send it
521 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Posted CreateObject request to remote sim {0}", uri);
522 }
523 catch (WebException ex)
524 {
525 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: Bad send on CreateObject {0}", ex.Message);
526 return false;
527 }
528 finally
529 {
530 if (os != null)
531 os.Close();
532 }
533
534 // Let's wait for the response
535 //m_log.Info("[REMOTE SIMULATION CONNECTOR]: Waiting for a reply after DoCreateChildAgentCall");
536
537 StreamReader sr = null;
538 try
539 {
540 WebResponse webResponse = ObjectCreateRequest.GetResponse();
541 if (webResponse == null)
542 {
543 m_log.Info("[REMOTE SIMULATION CONNECTOR]: Null reply on CreateObject post");
544 return false;
545 }
546
547 sr = new StreamReader(webResponse.GetResponseStream());
548 //reply = sr.ReadToEnd().Trim();
549 sr.ReadToEnd().Trim();
550 //m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: DoCreateChildAgentCall reply was {0} ", reply);
551
552 }
553 catch (WebException ex)
554 {
555 m_log.InfoFormat("[REMOTE SIMULATION CONNECTOR]: exception on reply of CreateObject {0}", ex.Message);
556 return false;
557 }
558 finally
559 {
560 if (sr != null)
561 sr.Close();
562 }
563
564 return true;
405 } 565 }
406 566
407 public bool CreateObject(GridRegion destination, UUID userID, UUID itemID) 567 public bool CreateObject(GridRegion destination, UUID userID, UUID itemID)
408 { 568 {
569 // TODO, not that urgent
409 return false; 570 return false;
410 } 571 }
411 572
diff --git a/OpenSim/Services/Interfaces/ISimulationService.cs b/OpenSim/Services/Interfaces/ISimulationService.cs
index 14f462c..ec24d90 100644
--- a/OpenSim/Services/Interfaces/ISimulationService.cs
+++ b/OpenSim/Services/Interfaces/ISimulationService.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Services.Interfaces
67 /// <param name="id"></param> 67 /// <param name="id"></param>
68 /// <param name="uri"></param> 68 /// <param name="uri"></param>
69 /// <returns></returns> 69 /// <returns></returns>
70 bool ReleaseAgent(GridRegion destination, UUID id, string uri); 70 bool ReleaseAgent(UUID originRegion, UUID id, string uri);
71 71
72 /// <summary> 72 /// <summary>
73 /// Close agent. 73 /// Close agent.