aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Console
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework/Console')
-rw-r--r--OpenSim/Framework/Console/CommandConsole.cs92
-rw-r--r--OpenSim/Framework/Console/RemoteConsole.cs44
2 files changed, 124 insertions, 12 deletions
diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs
index 7af8204..3387013 100644
--- a/OpenSim/Framework/Console/CommandConsole.cs
+++ b/OpenSim/Framework/Console/CommandConsole.cs
@@ -373,10 +373,28 @@ namespace OpenSim.Framework.Console
373 373
374 public XmlElement GetXml(XmlDocument doc) 374 public XmlElement GetXml(XmlDocument doc)
375 { 375 {
376 CommandInfo help = (CommandInfo)((Dictionary<string, object>)tree["help"])[String.Empty];
377 ((Dictionary<string, object>)tree["help"]).Remove(string.Empty);
378 if (((Dictionary<string, object>)tree["help"]).Count == 0)
379 tree.Remove("help");
380
381 CommandInfo quit = (CommandInfo)((Dictionary<string, object>)tree["quit"])[String.Empty];
382 ((Dictionary<string, object>)tree["quit"]).Remove(string.Empty);
383 if (((Dictionary<string, object>)tree["quit"]).Count == 0)
384 tree.Remove("quit");
385
376 XmlElement root = doc.CreateElement("", "HelpTree", ""); 386 XmlElement root = doc.CreateElement("", "HelpTree", "");
377 387
378 ProcessTreeLevel(tree, root, doc); 388 ProcessTreeLevel(tree, root, doc);
379 389
390 if (!tree.ContainsKey("help"))
391 tree["help"] = (object) new Dictionary<string, object>();
392 ((Dictionary<string, object>)tree["help"])[String.Empty] = help;
393
394 if (!tree.ContainsKey("quit"))
395 tree["quit"] = (object) new Dictionary<string, object>();
396 ((Dictionary<string, object>)tree["quit"])[String.Empty] = quit;
397
380 return root; 398 return root;
381 } 399 }
382 400
@@ -426,8 +444,80 @@ namespace OpenSim.Framework.Console
426 } 444 }
427 } 445 }
428 446
429 public void FromXml(XmlElement root) 447 public void FromXml(XmlElement root, CommandDelegate fn)
448 {
449 CommandInfo help = (CommandInfo)((Dictionary<string, object>)tree["help"])[String.Empty];
450 ((Dictionary<string, object>)tree["help"]).Remove(string.Empty);
451 if (((Dictionary<string, object>)tree["help"]).Count == 0)
452 tree.Remove("help");
453
454 CommandInfo quit = (CommandInfo)((Dictionary<string, object>)tree["quit"])[String.Empty];
455 ((Dictionary<string, object>)tree["quit"]).Remove(string.Empty);
456 if (((Dictionary<string, object>)tree["quit"]).Count == 0)
457 tree.Remove("quit");
458
459 tree.Clear();
460
461 ReadTreeLevel(tree, root, fn);
462
463 if (!tree.ContainsKey("help"))
464 tree["help"] = (object) new Dictionary<string, object>();
465 ((Dictionary<string, object>)tree["help"])[String.Empty] = help;
466
467 if (!tree.ContainsKey("quit"))
468 tree["quit"] = (object) new Dictionary<string, object>();
469 ((Dictionary<string, object>)tree["quit"])[String.Empty] = quit;
470 }
471
472 private void ReadTreeLevel(Dictionary<string, object> level, XmlNode node, CommandDelegate fn)
430 { 473 {
474 Dictionary<string, object> next;
475 string name;
476
477 XmlNodeList nodeL = node.ChildNodes;
478 XmlNodeList cmdL;
479 CommandInfo c;
480
481 foreach (XmlNode part in nodeL)
482 {
483 switch (part.Name)
484 {
485 case "Level":
486 name = ((XmlElement)part).GetAttribute("Name");
487 next = new Dictionary<string, object>();
488 level[name] = next;
489 ReadTreeLevel(next, part, fn);
490 break;
491 case "Command":
492 cmdL = part.ChildNodes;
493 c = new CommandInfo();
494 foreach (XmlNode cmdPart in cmdL)
495 {
496 switch (cmdPart.Name)
497 {
498 case "Module":
499 c.module = cmdPart.InnerText;
500 break;
501 case "Shared":
502 c.shared = Convert.ToBoolean(cmdPart.InnerText);
503 break;
504 case "HelpText":
505 c.help_text = cmdPart.InnerText;
506 break;
507 case "LongHelp":
508 c.long_help = cmdPart.InnerText;
509 break;
510 case "Description":
511 c.descriptive_help = cmdPart.InnerText;
512 break;
513 }
514 }
515 c.fn = new List<CommandDelegate>();
516 c.fn.Add(fn);
517 level[String.Empty] = c;
518 break;
519 }
520 }
431 } 521 }
432 } 522 }
433 523
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs
index dbf8f8c..da8556a 100644
--- a/OpenSim/Framework/Console/RemoteConsole.cs
+++ b/OpenSim/Framework/Console/RemoteConsole.cs
@@ -98,7 +98,12 @@ namespace OpenSim.Framework.Console
98 m_LineNumber++; 98 m_LineNumber++;
99 m_Scrollback.Add(String.Format("{0}", m_LineNumber)+":"+level+":"+text); 99 m_Scrollback.Add(String.Format("{0}", m_LineNumber)+":"+level+":"+text);
100 } 100 }
101 System.Console.Write(text); 101 System.Console.WriteLine(text.Trim());
102 }
103
104 public override void Output(string text)
105 {
106 Output(text, "normal");
102 } 107 }
103 108
104 public override string ReadLine(string p, bool isCommand, bool e) 109 public override string ReadLine(string p, bool isCommand, bool e)
@@ -152,9 +157,8 @@ namespace OpenSim.Framework.Console
152 157
153 foreach (UUID id in expired) 158 foreach (UUID id in expired)
154 { 159 {
155 System.Console.WriteLine("Expired {0}", id.ToString());
156 CloseConnection(id);
157 m_Connections.Remove(id); 160 m_Connections.Remove(id);
161 CloseConnection(id);
158 } 162 }
159 } 163 }
160 } 164 }
@@ -244,8 +248,8 @@ namespace OpenSim.Framework.Console
244 { 248 {
245 if (m_Connections.ContainsKey(id)) 249 if (m_Connections.ContainsKey(id))
246 { 250 {
247 CloseConnection(id);
248 m_Connections.Remove(id); 251 m_Connections.Remove(id);
252 CloseConnection(id);
249 } 253 }
250 } 254 }
251 255
@@ -346,9 +350,15 @@ namespace OpenSim.Framework.Console
346 350
347 public void CloseConnection(UUID id) 351 public void CloseConnection(UUID id)
348 { 352 {
349 string uri = "/ReadResponses/" + id.ToString() + "/"; 353 try
354 {
355 string uri = "/ReadResponses/" + id.ToString() + "/";
350 356
351 m_Server.RemovePollServiceHTTPHandler("", uri); 357 m_Server.RemovePollServiceHTTPHandler("", uri);
358 }
359 catch (Exception)
360 {
361 }
352 } 362 }
353 363
354 private bool HasEvents(UUID sessionID) 364 private bool HasEvents(UUID sessionID)
@@ -394,8 +404,11 @@ namespace OpenSim.Framework.Console
394 lock (m_Scrollback) 404 lock (m_Scrollback)
395 { 405 {
396 long startLine = m_LineNumber - m_Scrollback.Count; 406 long startLine = m_LineNumber - m_Scrollback.Count;
407 long sendStart = startLine;
408 if (sendStart < c.lastLineSeen)
409 sendStart = c.lastLineSeen;
397 410
398 for (long i = startLine ; i < m_LineNumber ; i++) 411 for (long i = sendStart ; i < m_LineNumber ; i++)
399 { 412 {
400 XmlElement res = xmldoc.CreateElement("", "Line", ""); 413 XmlElement res = xmldoc.CreateElement("", "Line", "");
401 long line = i + 1; 414 long line = i + 1;
@@ -422,12 +435,21 @@ namespace OpenSim.Framework.Console
422 { 435 {
423 Hashtable result = new Hashtable(); 436 Hashtable result = new Hashtable();
424 437
425 result["int_response_code"] = 502; 438 XmlDocument xmldoc = new XmlDocument();
426 result["content_type"] = "text/plain"; 439 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
440 "", "");
441
442 xmldoc.AppendChild(xmlnode);
443 XmlElement rootElement = xmldoc.CreateElement("", "ConsoleSession",
444 "");
445
446 xmldoc.AppendChild(rootElement);
447
448 result["str_response_string"] = xmldoc.InnerXml;
449 result["int_response_code"] = 200;
450 result["content_type"] = "text/xml";
427 result["keepalive"] = false; 451 result["keepalive"] = false;
428 result["reusecontext"] = false; 452 result["reusecontext"] = false;
429 result["str_response_string"] = "Upstream error: ";
430 result["error_status_text"] = "Upstream error:";
431 453
432 return result; 454 return result;
433 } 455 }