From 0ac2b3848a261a427dfbbe0488f491f600a5215a Mon Sep 17 00:00:00 2001 From: John Hurliman Date: Fri, 27 Apr 2007 01:21:23 +0000 Subject: [PATCH] * LoginCommand can optionally take a starting sim now * If Settings.DEBUG is enabled, loginreply.xml will be dumped to the hard drive git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@1153 52acb1d6-8a22-11de-b505-999d5b087335 --- libsecondlife/Login.cs | 19 ++++++++--- .../examples/TestClient/ClientManager.cs | 32 +++++++++---------- .../TestClient/Commands/LoginCommand.cs | 4 +-- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/libsecondlife/Login.cs b/libsecondlife/Login.cs index ba38b0ae..85cf8952 100644 --- a/libsecondlife/Login.cs +++ b/libsecondlife/Login.cs @@ -425,11 +425,17 @@ namespace libsecondlife try { HttpWebResponse response = (HttpWebResponse)myContext.Request.EndGetResponse(result); - //StreamReader sr = new StreamReader(response.GetResponseStream()); - //string str; - //StreamWriter wr = new StreamWriter("C:\\doh.txt"); - //while ((str = sr.ReadLine()) != null) - // wr.WriteLine(str); + + if (Client.Settings.DEBUG) + { + StreamReader sr = new StreamReader(response.GetResponseStream()); + string str; + StreamWriter wr = new StreamWriter("loginreply.xml"); + while ((str = sr.ReadLine()) != null) + wr.WriteLine(str); + wr.Close(); + } + XmlReader reader = XmlReader.Create(response.GetResponseStream()); // Parse the incoming xml @@ -446,6 +452,8 @@ namespace libsecondlife if (!reader.IsStartElement("fault")) { + #region XML Parsing + reader.ReadStartElement("params"); reader.ReadStartElement("param"); reader.ReadStartElement("value"); @@ -870,6 +878,7 @@ namespace libsecondlife reader.ReadEndElement(); reader.ReadEndElement(); + #endregion XML Parsing if (redirect) { diff --git a/libsecondlife/examples/TestClient/ClientManager.cs b/libsecondlife/examples/TestClient/ClientManager.cs index aaa59430..e62e392c 100644 --- a/libsecondlife/examples/TestClient/ClientManager.cs +++ b/libsecondlife/examples/TestClient/ClientManager.cs @@ -14,6 +14,7 @@ namespace libsecondlife.TestClient public string FirstName; public string LastName; public string Password; + public string StartLocation; public string MasterName; public LLUUID MasterKey; } @@ -42,7 +43,6 @@ namespace libsecondlife.TestClient public bool Running = true; string contactPerson = String.Empty; - StartPosition startpos = new StartPosition(); private LLUUID resolvedMasterKey = LLUUID.Zero; private ManualResetEvent keyResolution = new ManualResetEvent(false); @@ -62,12 +62,13 @@ namespace libsecondlife.TestClient this.contactPerson = c; char sep = '/'; string[] startbits = s.Split(sep); - this.startpos.sim = startbits[0]; - this.startpos.x = int.Parse(startbits[1]); - this.startpos.y = int.Parse(startbits[2]); - this.startpos.z = int.Parse(startbits[3]); + foreach (LoginDetails account in accounts) + { + account.StartLocation = NetworkManager.StartLocation(startbits[0], Int32.Parse(startbits[1]), + Int32.Parse(startbits[2]), Int32.Parse(startbits[3])); Login(account); + } } /// /// @@ -98,20 +99,14 @@ namespace libsecondlife.TestClient client.MasterName = account.MasterName; client.MasterKey = account.MasterKey; - if (!String.IsNullOrEmpty(this.startpos.sim)) + if (!String.IsNullOrEmpty(account.StartLocation)) { - if (this.startpos.x == 0 || this.startpos.y == 0 || this.startpos.z == 0) + if (!client.Network.Login(account.FirstName, account.LastName, account.Password, "TestClient", + account.StartLocation, contactPerson)) { - this.startpos.x = 128; - this.startpos.y = 128; - this.startpos.z = 1; + Console.WriteLine("Failed to login " + account.FirstName + " " + account.LastName + ": " + + client.Network.LoginMessage); } - - string startLoc = NetworkManager.StartLocation(this.startpos.sim, this.startpos.x, this.startpos.y, - this.startpos.z); - Console.WriteLine(startLoc); - client.Network.Login(account.FirstName, account.LastName, account.Password, "TestClient", startLoc, - contactPerson); } else { @@ -199,6 +194,11 @@ namespace libsecondlife.TestClient account.LastName = args[1]; account.Password = args[2]; + if (args.Length == 4) + { + account.StartLocation = NetworkManager.StartLocation(args[3], 128, 128, 40); + } + return Login(account); } diff --git a/libsecondlife/examples/TestClient/Commands/LoginCommand.cs b/libsecondlife/examples/TestClient/Commands/LoginCommand.cs index a68b8856..aaf60f69 100644 --- a/libsecondlife/examples/TestClient/Commands/LoginCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/LoginCommand.cs @@ -16,8 +16,8 @@ namespace libsecondlife.TestClient public override string Execute(string[] args, LLUUID fromAgentID) { - if (args.Length != 3) - return "usage: login firstname lastname password"; + if (args.Length != 3 && args.Length != 4) + return "usage: login firstname lastname password [simname]"; SecondLife newClient = Client.ClientManager.Login(args);