When you change the name of a inventory item, it should no longer revert after a logout / login

This commit is contained in:
MW
2007-03-29 20:55:44 +00:00
parent feaf036aa2
commit b2ae86dd6a
6 changed files with 139 additions and 91 deletions

View File

@@ -44,102 +44,114 @@ using OpenSim.Framework.Console;
namespace OpenGridServices.UserServer
{
public class UserHTTPServer {
public Thread HTTPD;
public HttpListener Listener;
public UserHTTPServer() {
MainConsole.Instance.WriteLine("Starting up HTTP Server");
HTTPD = new Thread(new ThreadStart(StartHTTP));
HTTPD.Start();
}
public class UserHTTPServer
{
public Thread HTTPD;
public HttpListener Listener;
public void StartHTTP() {
MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
Listener = new HttpListener();
public UserHTTPServer()
{
MainConsole.Instance.WriteLine("Starting up HTTP Server");
HTTPD = new Thread(new ThreadStart(StartHTTP));
HTTPD.Start();
}
Listener.Prefixes.Add("http://+:8002/userserver/");
Listener.Prefixes.Add("http://+:8002/usersessions/");
Listener.Start();
public void StartHTTP()
{
MainConsole.Instance.WriteLine("UserHttp.cs:StartHTTP() - Spawned main thread OK");
Listener = new HttpListener();
HttpListenerContext context;
while(true) {
context = Listener.GetContext();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
}
}
Listener.Prefixes.Add("http://+:8002/userserver/");
Listener.Prefixes.Add("http://+:8002/usersessions/");
Listener.Start();
static string ParseXMLRPC(string requestBody) {
HttpListenerContext context;
while (true)
{
context = Listener.GetContext();
ThreadPool.QueueUserWorkItem(new WaitCallback(HandleRequest), context);
}
}
static string ParseXMLRPC(string requestBody)
{
return OpenUser_Main.userserver._profilemanager.ParseXMLRPC(requestBody);
}
static string ParseREST(HttpListenerRequest www_req) {
Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
char[] splitter = {'/'};
string[] rest_params = www_req.RawUrl.Split(splitter);
string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
switch(req_type) {
case "usersessions":
LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
if(www_req.HttpMethod=="DELETE") {
foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys) {
if(OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID==sessionid) {
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID=null;
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID=null;
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear();
}
}
}
}
return "OK";
}
static string ParseREST(HttpListenerRequest www_req)
{
Console.WriteLine("INCOMING REST - " + www_req.RawUrl);
return "";
}
char[] splitter = { '/' };
string[] rest_params = www_req.RawUrl.Split(splitter);
string req_type = rest_params[1]; // First part of the URL is the type of request - usersessions/userprofiles/inventory/blabla
switch (req_type)
{
case "usersessions":
LLUUID sessionid = new LLUUID(rest_params[2]); // get usersessions/sessionid
if (www_req.HttpMethod == "DELETE")
{
foreach (libsecondlife.LLUUID UUID in OpenUser_Main.userserver._profilemanager.UserProfiles.Keys)
{
if (OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID == sessionid)
{
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSessionID = null;
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].CurrentSecureSessionID = null;
OpenUser_Main.userserver._profilemanager.UserProfiles[UUID].Circuits.Clear();
}
}
}
return "OK";
}
return "";
}
static void HandleRequest(Object stateinfo) {
HttpListenerContext context=(HttpListenerContext)stateinfo;
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
static void HandleRequest(Object stateinfo)
{
HttpListenerContext context = (HttpListenerContext)stateinfo;
response.KeepAlive=false;
response.SendChunked=false;
HttpListenerRequest request = context.Request;
HttpListenerResponse response = context.Response;
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
string requestBody = reader.ReadToEnd();
body.Close();
reader.Close();
response.KeepAlive = false;
response.SendChunked = false;
string responseString="";
switch(request.ContentType) {
case "text/xml":
// must be XML-RPC, so pass to the XML-RPC parser
responseString=ParseXMLRPC(requestBody);
response.AddHeader("Content-type","text/xml");
break;
case "text/plaintext":
responseString=ParseREST(request);
response.AddHeader("Content-type","text/plaintext");
break;
}
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
System.IO.Stream output = response.OutputStream;
response.SendChunked=false;
response.ContentLength64=buffer.Length;
output.Write(buffer,0,buffer.Length);
output.Close();
}
}
System.IO.Stream body = request.InputStream;
System.Text.Encoding encoding = System.Text.Encoding.UTF8;
System.IO.StreamReader reader = new System.IO.StreamReader(body, encoding);
string requestBody = reader.ReadToEnd();
body.Close();
reader.Close();
string responseString = "";
switch (request.ContentType)
{
case "text/xml":
// must be XML-RPC, so pass to the XML-RPC parser
responseString = ParseXMLRPC(requestBody);
response.AddHeader("Content-type", "text/xml");
break;
case "text/plaintext":
responseString = ParseREST(request);
response.AddHeader("Content-type", "text/plaintext");
break;
}
byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString);
System.IO.Stream output = response.OutputStream;
response.SendChunked = false;
response.ContentLength64 = buffer.Length;
output.Write(buffer, 0, buffer.Length);
output.Close();
}
}
}