From ad398971445a3aad5490ad4c3e6b7319f201bb8f Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 3 Apr 2007 16:50:17 +0000 Subject: * Script prototype --- OpenSim.RegionServer/CAPS/AdminWebFront.cs | 98 ++++++++++++++++++++++-------- 1 file changed, 72 insertions(+), 26 deletions(-) (limited to 'OpenSim.RegionServer/CAPS') diff --git a/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim.RegionServer/CAPS/AdminWebFront.cs index 7f00225..43996d0 100644 --- a/OpenSim.RegionServer/CAPS/AdminWebFront.cs +++ b/OpenSim.RegionServer/CAPS/AdminWebFront.cs @@ -7,6 +7,8 @@ using OpenSim.UserServer; using OpenSim.Servers; using OpenSim.Assets; using OpenSim.Framework.Inventory; +using libsecondlife; +using OpenSim.RegionServer.world.scripting; namespace OpenSim.CAPS { @@ -34,7 +36,10 @@ namespace OpenSim.CAPS server.AddRestHandler("GET", "/Admin", GetAdminPage); server.AddRestHandler("GET", "/Admin/Welcome", GetWelcomePage); server.AddRestHandler("GET", "/Admin/Accounts", GetAccountsPage ); - server.AddRestHandler("GET", "/Admin/Clients", GetConnectedClientsPage ); + server.AddRestHandler("GET", "/Admin/Clients", GetConnectedClientsPage); + server.AddRestHandler("GET", "/Admin/Entities", GetEntitiesPage); + server.AddRestHandler("GET", "/Admin/Scripts", GetScriptsPage); + server.AddRestHandler("GET", "/Admin/AddTestScript", AddTestScript ); server.AddRestHandler("GET", "/ClientInventory", GetClientsInventory); server.AddRestHandler("POST", "/Admin/NewAccount", PostNewAccount ); @@ -133,6 +138,68 @@ namespace OpenSim.CAPS return responseString; } + + private class TestScript : Script + { + int toggle = 0; + + public TestScript() + : base(LLUUID.Random()) + { + OnFrame += MyOnFrame; + } + + private void MyOnFrame(IScriptContext context) + { + toggle = 2 - toggle; + + LLVector3 pos = context.GetPos(); + + pos.X += (toggle - 1); + + context.MoveTo(pos); + } + } + + private string AddTestScript(string request, string path) + { + int index = path.LastIndexOf('/'); + + string lluidStr = path.Substring(index+1); + + LLUUID id; + + if( LLUUID.TryParse( lluidStr, out id ) ) + { + // This is just here for concept purposes... Remove! + m_world.AddScript( m_world.Entities[id], new TestScript()); + return String.Format("Added new script to object [{0}]", id); + } + else + { + return String.Format("Couldn't parse [{0}]", lluidStr ); + } + } + + private string GetScriptsPage(string request, string path) + { + return String.Empty; + } + + private string GetEntitiesPage(string request, string path) + { + string responseString; + responseString = "

Listing current entities

"; + return responseString; + } + private string GetClientsInventory(string request, string path) { string[] line; @@ -187,38 +254,17 @@ namespace OpenSim.CAPS try { StreamReader SR; - string lines; - AdminPage = ""; - NewAccountForm = ""; - LoginForm = ""; + SR = File.OpenText("testadmin.htm"); - - while (!SR.EndOfStream) - { - lines = SR.ReadLine(); - AdminPage += lines + "\n"; - - } + AdminPage = SR.ReadToEnd(); SR.Close(); SR = File.OpenText("newaccountform.htm"); - - while (!SR.EndOfStream) - { - lines = SR.ReadLine(); - NewAccountForm += lines + "\n"; - - } + NewAccountForm = SR.ReadToEnd(); SR.Close(); SR = File.OpenText("login.htm"); - - while (!SR.EndOfStream) - { - lines = SR.ReadLine(); - LoginForm += lines + "\n"; - - } + LoginForm = SR.ReadToEnd(); SR.Close(); } catch (Exception e) -- cgit v1.1