diff --git a/gridserver/default.build b/gridserver/default.build index c199514557..5112148388 100644 --- a/gridserver/default.build +++ b/gridserver/default.build @@ -52,6 +52,7 @@ + diff --git a/gridserver/src/GridHttp.cs b/gridserver/src/GridHttp.cs new file mode 100644 index 0000000000..623e9bf76a --- /dev/null +++ b/gridserver/src/GridHttp.cs @@ -0,0 +1,91 @@ +/* +Copyright (c) OpenGrid project, http://osgrid.org/ + + +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +using System; +using System.Text; +using System.Threading; +using System.Net; +using System.IO; +using System.Collections; +using System.Collections.Generic; +using libsecondlife; +using ServerConsole; + +namespace OpenGridServices +{ + public class GridHTTPServer { + public Thread HTTPD; + public HttpListener Listener; + + public GridHTTPServer() { + ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server"); + HTTPD = new Thread(new ThreadStart(StartHTTP)); + HTTPD.Start(); + } + + public void StartHTTP() { + ServerConsole.MainConsole.Instance.WriteLine("GridHttp.cs:StartHTTP() - Spawned main thread OK"); + Listener = new HttpListener(); + + Listener.Prefixes.Add("http://+:8080/gridserver/"); + Listener.Start(); + + HttpListenerContext context; + while(true) { + context = Listener.GetContext(); + new Thread( new ThreadStart( new HttpWorker(context).Startup ) ).Start(); + } + } + + } + + public class HttpWorker { + public HttpListenerContext context; + + public HttpWorker(HttpListenerContext context) { + this.context=context; + } + + public string HandleRequest(HttpListenerRequest request) { + ServerConsole.MainConsole.Instance.WriteLine(request.Url.ToString()); + return ""; + } + + public void Startup() { + HttpListenerRequest request = context.Request; + HttpListenerResponse response = context.Response; + string responseString=HandleRequest(request); + byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); + System.IO.Stream output = response.OutputStream; + output.Write(buffer,0,buffer.Length); + output.Close(); + } + } + +} diff --git a/gridserver/src/Main.cs b/gridserver/src/Main.cs index 9dda2a2e4a..3d3efa9010 100644 --- a/gridserver/src/Main.cs +++ b/gridserver/src/Main.cs @@ -44,6 +44,8 @@ namespace OpenGridServices public string DefaultStartupMsg; public string DefaultAssetServer; public string DefaultUserServer; + + public GridHTTPServer _httpd; public UserProfileManager _profilemanager; public UserProfile GridGod; public LLUUID HighestUUID; @@ -100,6 +102,10 @@ namespace OpenGridServices tempMD5Passwd = "$1$" + s.ToString(); GridGod=_profilemanager.CreateNewProfile(tempfirstname,templastname,tempMD5Passwd); - } + _profilemanager.SetGod(GridGod.UUID); + + ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Starting HTTP process"); + _httpd = new GridHTTPServer(); + } } } diff --git a/gridserver/src/UserProfiles.cs b/gridserver/src/UserProfiles.cs index dd4a3361f0..6ab7eb3659 100644 --- a/gridserver/src/UserProfiles.cs +++ b/gridserver/src/UserProfiles.cs @@ -60,12 +60,17 @@ namespace OpenGridServices return UserProfiles[ProfileLLUUID]; } + public void SetGod(LLUUID GodID) { + this.UserProfiles[GodID].IsGridGod=true; + } + public UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) { UserProfile newprofile = new UserProfile(); newprofile.firstname=firstname; newprofile.lastname=lastname; newprofile.MD5passwd=MD5passwd; UserProfiles.Add(OpenGrid_Main.thegrid.HighestUUID,newprofile); + newprofile.UUID=OpenGrid_Main.thegrid.HighestUUID; OpenGrid_Main.thegrid.HighestUUID=LLUUID.Random(); // FIXME: Increment, don't set random! return newprofile; } @@ -78,7 +83,9 @@ namespace OpenGridServices public string lastname; public bool IsGridGod; public string MD5passwd; - + + public LLUUID UUID; + public UserProfile() { }