* Extracted request-response handling

adam
lbsa71 2007-03-16 20:46:53 +00:00
parent 3147def23f
commit 59e7586558
1 changed files with 119 additions and 112 deletions

View File

@ -168,117 +168,9 @@ namespace OpenSim.GridServers
XmlRpcRequest request = (XmlRpcRequest)(new XmlRpcRequestDeserializer()).Deserialize(new String(content));
if(request.MethodName == "login_to_simulator")
{
Hashtable requestData = (Hashtable)request.Params[0];
string first;
string last;
string passwd;
LLUUID Agent;
LLUUID Session;
//get login name
if(requestData.Contains("first"))
{
first = (string)requestData["first"];
}
else
{
first = "test";
}
if(requestData.Contains("last"))
{
last = (string)requestData["last"];
}
else
{
last = "User"+NumClients.ToString();
}
if(requestData.Contains("passwd"))
{
passwd = (string)requestData["passwd"];
}
else
{
passwd = "notfound";
}
XmlRpcResponse response = ProcessRequest(request);
XmlRpcResponse response =(XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
Hashtable responseData = (Hashtable)response.Value;
if( !Authenticate(first, last, passwd))
{
responseData["reason"] = "key";
responseData["message"] = "You have entered an invalid name/password combination. Check Caps/lock.";
responseData["login"] = "false";
}
else
{
NumClients++;
//create a agent and session LLUUID
Agent = GetAgentId( first, last );
int SessionRand = this.RandomClass.Next(1,999);
Session = new LLUUID("aaaabbbb-0200-"+SessionRand.ToString("0000")+"-8664-58f53e442797");
//create some login info
Hashtable LoginFlagsHash = new Hashtable();
LoginFlagsHash["daylight_savings"]="N";
LoginFlagsHash["stipend_since_login"]="N";
LoginFlagsHash["gendered"]="Y";
LoginFlagsHash["ever_logged_in"]="Y";
ArrayList LoginFlags=new ArrayList();
LoginFlags.Add(LoginFlagsHash);
Hashtable GlobalT = new Hashtable();
GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
ArrayList GlobalTextures = new ArrayList();
GlobalTextures.Add(GlobalT);
responseData["sim_port"] = OpenSim_Main.cfg.IPListenPort;
responseData["sim_ip"] = OpenSim_Main.cfg.IPListenAddr;
responseData["agent_id"] = Agent.ToStringHyphenated();
responseData["session_id"] = Session.ToStringHyphenated();
responseData["seconds_since_epoch"]=(Int32)(DateTime.UtcNow - new DateTime(1970,1,1)).TotalSeconds;
responseData["login-flags"]=LoginFlags;
responseData["global-textures"]=GlobalTextures;
//inventory
ArrayList InventoryList = (ArrayList) responseData["inventory-skeleton"];
Hashtable Inventory1 = (Hashtable)InventoryList[0];
Hashtable Inventory2 = (Hashtable)InventoryList[1];
LLUUID BaseFolderID = LLUUID.Random();
LLUUID InventoryFolderID = LLUUID.Random();
Inventory2["name"] = "Base";
Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated();
Inventory2["type_default"] =6;
Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated();
ArrayList InventoryRoot = (ArrayList) responseData["inventory-root"];
Hashtable Inventoryroot = (Hashtable)InventoryRoot[0];
Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated();
CustomiseLoginResponse( responseData, first, last );
this._login = new Login();
//copy data to login object
_login.First = first;
_login.Last = last;
_login.Agent = Agent;
_login.Session = Session;
_login.BaseFolder = BaseFolderID;
_login.InventoryFolder = InventoryFolderID;
//working on local computer if so lets add to the gridserver's list of sessions?
if(OpenSim_Main.gridServers.GridServer.GetName() == "Local")
{
((LocalGridBase)this._gridServer).AddNewSession(_login);
}
}
// forward the XML-RPC response to the client
// forward the XML-RPC response to the client
writer.WriteLine("HTTP/1.0 200 OK");
writer.WriteLine("Content-type: text/xml");
writer.WriteLine();
@ -294,8 +186,123 @@ namespace OpenSim.GridServers
}
}
}
protected virtual void CustomiseLoginResponse( Hashtable responseData, string first, string last )
private XmlRpcResponse ProcessRequest(XmlRpcRequest request)
{
XmlRpcResponse response = (XmlRpcResponse)(new XmlRpcResponseDeserializer()).Deserialize(this._defaultResponse);
Hashtable responseData = (Hashtable)response.Value;
Hashtable requestData = (Hashtable)request.Params[0];
string first;
string last;
string passwd;
LLUUID Agent;
LLUUID Session;
//get login name
if(requestData.Contains("first"))
{
first = (string)requestData["first"];
}
else
{
first = "test";
}
if(requestData.Contains("last"))
{
last = (string)requestData["last"];
}
else
{
last = "User"+NumClients.ToString();
}
if(requestData.Contains("passwd"))
{
passwd = (string)requestData["passwd"];
}
else
{
passwd = "notfound";
}
if( !Authenticate(first, last, passwd))
{
responseData["reason"] = "key";
responseData["message"] = "You have entered an invalid name/password combination. Check Caps/lock.";
responseData["login"] = "false";
}
else
{
NumClients++;
//create a agent and session LLUUID
Agent = GetAgentId( first, last );
int SessionRand = this.RandomClass.Next(1,999);
Session = new LLUUID("aaaabbbb-0200-"+SessionRand.ToString("0000")+"-8664-58f53e442797");
//create some login info
Hashtable LoginFlagsHash = new Hashtable();
LoginFlagsHash["daylight_savings"]="N";
LoginFlagsHash["stipend_since_login"]="N";
LoginFlagsHash["gendered"]="Y";
LoginFlagsHash["ever_logged_in"]="Y";
ArrayList LoginFlags=new ArrayList();
LoginFlags.Add(LoginFlagsHash);
Hashtable GlobalT = new Hashtable();
GlobalT["sun_texture_id"] = "cce0f112-878f-4586-a2e2-a8f104bba271";
GlobalT["cloud_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
GlobalT["moon_texture_id"] = "fc4b9f0b-d008-45c6-96a4-01dd947ac621";
ArrayList GlobalTextures = new ArrayList();
GlobalTextures.Add(GlobalT);
responseData["sim_port"] = OpenSim_Main.cfg.IPListenPort;
responseData["sim_ip"] = OpenSim_Main.cfg.IPListenAddr;
responseData["agent_id"] = Agent.ToStringHyphenated();
responseData["session_id"] = Session.ToStringHyphenated();
responseData["seconds_since_epoch"]=(Int32)(DateTime.UtcNow - new DateTime(1970,1,1)).TotalSeconds;
responseData["login-flags"]=LoginFlags;
responseData["global-textures"]=GlobalTextures;
//inventory
ArrayList InventoryList = (ArrayList) responseData["inventory-skeleton"];
Hashtable Inventory1 = (Hashtable)InventoryList[0];
Hashtable Inventory2 = (Hashtable)InventoryList[1];
LLUUID BaseFolderID = LLUUID.Random();
LLUUID InventoryFolderID = LLUUID.Random();
Inventory2["name"] = "Base";
Inventory2["folder_id"] = BaseFolderID.ToStringHyphenated();
Inventory2["type_default"] =6;
Inventory1["folder_id"] = InventoryFolderID.ToStringHyphenated();
ArrayList InventoryRoot = (ArrayList) responseData["inventory-root"];
Hashtable Inventoryroot = (Hashtable)InventoryRoot[0];
Inventoryroot["folder_id"] = InventoryFolderID.ToStringHyphenated();
CustomiseLoginResponse( responseData, first, last );
this._login = new Login();
//copy data to login object
_login.First = first;
_login.Last = last;
_login.Agent = Agent;
_login.Session = Session;
_login.BaseFolder = BaseFolderID;
_login.InventoryFolder = InventoryFolderID;
//working on local computer if so lets add to the gridserver's list of sessions?
if(OpenSim_Main.gridServers.GridServer.GetName() == "Local")
{
((LocalGridBase)this._gridServer).AddNewSession(_login);
}
}
return response;
}
protected virtual void CustomiseLoginResponse( Hashtable responseData, string first, string last )
{
}