aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OGS/userserver
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OGS/userserver/src/ConsoleCmds.cs (renamed from ogs/userserver/src/ConsoleCmds.cs)0
-rw-r--r--OGS/userserver/src/Main.cs (renamed from ogs/userserver/src/Main.cs)10
-rw-r--r--OGS/userserver/src/OGS-UserServer.csproj (renamed from ogs/userserver/src/OGS-UserServer.csproj)13
-rw-r--r--OGS/userserver/src/OGS-UserServer.csproj.user (renamed from ogs/userserver/src/OGS-UserServer.csproj.user)8
-rw-r--r--OGS/userserver/src/Properties/AssemblyInfo.cs (renamed from ogs/userserver/src/Properties/AssemblyInfo.cs)0
-rw-r--r--OGS/userserver/src/UserHttp.cs146
6 files changed, 157 insertions, 20 deletions
diff --git a/ogs/userserver/src/ConsoleCmds.cs b/OGS/userserver/src/ConsoleCmds.cs
index f2568fc..f2568fc 100644
--- a/ogs/userserver/src/ConsoleCmds.cs
+++ b/OGS/userserver/src/ConsoleCmds.cs
diff --git a/ogs/userserver/src/Main.cs b/OGS/userserver/src/Main.cs
index 40ef916..7e5308e 100644
--- a/ogs/userserver/src/Main.cs
+++ b/OGS/userserver/src/Main.cs
@@ -33,6 +33,9 @@ using System.Collections.Generic;
33using System.Text; 33using System.Text;
34using libsecondlife; 34using libsecondlife;
35using ServerConsole; 35using ServerConsole;
36using OpenSim.Framework.User;
37using OpenSim.Framework.Sims;
38using OpenSim.Framework.Inventory;
36 39
37namespace OpenGridServices 40namespace OpenGridServices
38{ 41{
@@ -73,16 +76,17 @@ namespace OpenGridServices
73 public void Startup() { 76 public void Startup() {
74 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings"); 77 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Please press enter to retain default settings");
75 78
76 this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid URL: "); 79 this.GridURL=ServerConsole.MainConsole.Instance.CmdPrompt("Grid URL: ");
77 this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to grid: "); 80 this.GridSendKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to send to grid: ");
78 this.GridRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from grid: "); 81 this.GridRecvKey=ServerConsole.MainConsole.Instance.CmdPrompt("Key to expect from grid: ");
79 82
80 this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!] :","Welcome to OGS!"); 83 this.DefaultStartupMsg=ServerConsole.MainConsole.Instance.CmdPrompt("Default startup message for clients [Welcome to OGS!] :","Welcome to OGS!");
81 84
82 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager"); 85 ServerConsole.MainConsole.Instance.WriteLine("Main.cs:Startup() - Creating user profile manager");
83 _profilemanager = new UserProfileManager(); 86 _profilemanager = new UserProfileManager();
84 _profilemanager.InitUserProfiles(); 87 _profilemanager.InitUserProfiles();
85 88 _profilemanager.SetKeys(GridSendKey, GridRecvKey, GridURL, DefaultStartupMsg);
89
86 90
87 string tempfirstname; 91 string tempfirstname;
88 string templastname; 92 string templastname;
diff --git a/ogs/userserver/src/OGS-UserServer.csproj b/OGS/userserver/src/OGS-UserServer.csproj
index f6737c8..f4fa8b6 100644
--- a/ogs/userserver/src/OGS-UserServer.csproj
+++ b/OGS/userserver/src/OGS-UserServer.csproj
@@ -48,21 +48,16 @@
48 <Compile Include="Main.cs" /> 48 <Compile Include="Main.cs" />
49 <Compile Include="Properties\AssemblyInfo.cs" /> 49 <Compile Include="Properties\AssemblyInfo.cs" />
50 <Compile Include="UserHttp.cs" /> 50 <Compile Include="UserHttp.cs" />
51 <Compile Include="UserProfiles.cs" />
52 <Compile Include="Util.cs" />
53 </ItemGroup> 51 </ItemGroup>
54 <ItemGroup> 52 <ItemGroup>
53 <ProjectReference Include="..\..\..\OpenSim.FrameWork\OpenSim.Framework.csproj">
54 <Project>{2E46A825-3168-492F-93BC-637126B5B72B}</Project>
55 <Name>OpenSim.Framework</Name>
56 </ProjectReference>
55 <ProjectReference Include="..\..\ServerConsole\ServerConsole.csproj"> 57 <ProjectReference Include="..\..\ServerConsole\ServerConsole.csproj">
56 <Project>{7667E6E2-F227-41A2-B1B2-315613E1BAFC}</Project> 58 <Project>{7667E6E2-F227-41A2-B1B2-315613E1BAFC}</Project>
57 <Name>ServerConsole</Name> 59 <Name>ServerConsole</Name>
58 </ProjectReference> 60 </ProjectReference>
59 </ItemGroup> 61 </ItemGroup>
60 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 62 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
61 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
62 Other similar extension points exist, see Microsoft.Common.targets.
63 <Target Name="BeforeBuild">
64 </Target>
65 <Target Name="AfterBuild">
66 </Target>
67 -->
68</Project> \ No newline at end of file 63</Project> \ No newline at end of file
diff --git a/ogs/userserver/src/OGS-UserServer.csproj.user b/OGS/userserver/src/OGS-UserServer.csproj.user
index 9c0b2d9..aa75a3d 100644
--- a/ogs/userserver/src/OGS-UserServer.csproj.user
+++ b/OGS/userserver/src/OGS-UserServer.csproj.user
@@ -1,14 +1,6 @@
1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 1<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2 <PropertyGroup> 2 <PropertyGroup>
3 <PublishUrlHistory>publish\</PublishUrlHistory> 3 <PublishUrlHistory>publish\</PublishUrlHistory>
4 <InstallUrlHistory>
5 </InstallUrlHistory>
6 <SupportUrlHistory>
7 </SupportUrlHistory>
8 <UpdateUrlHistory>
9 </UpdateUrlHistory>
10 <BootstrapperUrlHistory>
11 </BootstrapperUrlHistory>
12 <ApplicationRevision>0</ApplicationRevision> 4 <ApplicationRevision>0</ApplicationRevision>
13 <FallbackCulture>en-US</FallbackCulture> 5 <FallbackCulture>en-US</FallbackCulture>
14 <VerifyUploadedFiles>false</VerifyUploadedFiles> 6 <VerifyUploadedFiles>false</VerifyUploadedFiles>
diff --git a/ogs/userserver/src/Properties/AssemblyInfo.cs b/OGS/userserver/src/Properties/AssemblyInfo.cs
index 5d5ce8d..5d5ce8d 100644
--- a/ogs/userserver/src/Properties/AssemblyInfo.cs
+++ b/OGS/userserver/src/Properties/AssemblyInfo.cs
diff --git a/OGS/userserver/src/UserHttp.cs b/OGS/userserver/src/UserHttp.cs
new file mode 100644
index 0000000..ce3cfcd
--- /dev/null
+++ b/OGS/userserver/src/UserHttp.cs
@@ -0,0 +1,146 @@
1/*
2Copyright (c) OpenGrid project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using Nwc.XmlRpc;
33using System.Threading;
34using System.Text.RegularExpressions;
35using System.Net;
36using System.IO;
37using System.Collections;
38using System.Collections.Generic;
39using libsecondlife;
40using ServerConsole;
41using OpenSim.Framework.User;
42using OpenSim.Framework.Sims;
43using OpenSim.Framework.Inventory;
44
45namespace OpenGridServices
46{
47 public class UserHTTPServer {
48 public Thread HTTPD;
49 public HttpListener Listener;
50
51 public UserHTTPServer() {
52 ServerConsole.MainConsole.Instance.WriteLine("Starting up HTTP Server");
53 HTTPD = new Thread(new ThreadStart(StartHTTP));
54 HTTPD.Start();
55 }
56
57 public void StartHTTP() {
58 ServerConsole.MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
59 Listener = new HttpListener();
60
61 Listener.Prefixes.Add("http://+:8002/userserver/");
62 Listener.Prefixes.Add("http://+:8002/usersessions/");
63 Listener.Start();
64
65 HttpListenerContext context;
66 while(true) {
67 context = Listener.GetContext();
68 ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
69 }
70 }
71
72 static string ParseXMLRPC(string requestBody) {
73 return OpenGridServices.OpenUser_Main.userserver._profilemanager.ParseXMLRPC(requestBody);
74 }
75
76 static string ParseREST(HttpListenerRequest www_req) {
77 Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
78
79 char[] splitter = {'/'};
80 string[] rest_params = www_req.RawUrl.Split(splitter);
81 string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
82 switch(req_type) {
83 case "usersessions":
84 LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
85 if(www_req.HttpMethod=="DELETE") {
86 foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) {
87 if(OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID==sessionid) {
88 OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID=null;
89 OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID=null;
90 OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear();
91 }
92 }
93
94 }
95 return "OK";
96 break;
97 }
98
99 return "";
100 }
101
102
103 static void HandleRequest(Object stateinfo) {
104 HttpListenerContext context=(HttpListenerContext)stateinfo;
105
106 HttpListenerRequest request = context.Request;
107 HttpListenerResponse response = context.Response;
108
109 response.KeepAlive=false;
110 response.SendChunked=false;
111
112 System.IO.Stream body = request.InputStream;
113 System.Text.Encoding encoding = System.Text.Encoding.UTF8;
114 System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
115
116 string requestBody = reader.ReadToEnd();
117 body.Close();
118 reader.Close();
119
120 string responseString="";
121 switch(request.ContentType) {
122 case "text/xml":
123 // must be XML-RPC, so pass to the XML-RPC parser
124
125 responseString=ParseXMLRPC(requestBody);
126 response.AddHeader("Content-type","text/xml");
127 break;
128
129 case "text/plaintext":
130 responseString=ParseREST(request);
131 response.AddHeader("Content-type","text/plaintext");
132 break;
133 }
134
135
136 byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
137 System.IO.Stream output = response.OutputStream;
138 response.SendChunked=false;
139 response.ContentLength64=buffer.Length;
140 output.Write(buffer,0,buffer.Length);
141 output.Close();
142 }
143 }
144
145
146}