Added some error handling (and console output) to BaseHttpServer.

a few other bits of refactoring.
afrisby
MW 2007-12-02 18:49:42 +00:00
parent cac98171e5
commit 5ae8759de1
4 changed files with 34 additions and 30 deletions

View File

@ -185,26 +185,34 @@ namespace OpenSim.Framework.Servers
if (xmlRprcRequest != null) if (xmlRprcRequest != null)
{ {
string methodName = xmlRprcRequest.MethodName; string methodName = xmlRprcRequest.MethodName;
if (methodName != null)
XmlRpcResponse xmlRpcResponse;
XmlRpcMethod method;
if (m_rpcHandlers.TryGetValue(methodName, out method))
{ {
xmlRpcResponse = method(xmlRprcRequest);
XmlRpcResponse xmlRpcResponse;
XmlRpcMethod method;
if (m_rpcHandlers.TryGetValue(methodName, out method))
{
xmlRpcResponse = method(xmlRprcRequest);
}
else
{
xmlRpcResponse = new XmlRpcResponse();
Hashtable unknownMethodError = new Hashtable();
unknownMethodError["reason"] = "XmlRequest";
;
unknownMethodError["message"] = "Unknown Rpc Request [" + methodName + "]";
unknownMethodError["login"] = "false";
xmlRpcResponse.Value = unknownMethodError;
}
responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
} }
else else
{ {
xmlRpcResponse = new XmlRpcResponse(); System.Console.WriteLine("Handler not found for http request " +request.RawUrl);
Hashtable unknownMethodError = new Hashtable(); responseString = "Error";
unknownMethodError["reason"] = "XmlRequest";
;
unknownMethodError["message"] = "Unknown Rpc Request [" + methodName + "]";
unknownMethodError["login"] = "false";
xmlRpcResponse.Value = unknownMethodError;
} }
responseString = XmlRpcResponseSerializer.Singleton.Serialize(xmlRpcResponse);
} }
response.AddHeader("Content-type", "text/xml"); response.AddHeader("Content-type", "text/xml");

View File

@ -12,7 +12,7 @@ namespace OpenSim.Region.Environment.Modules
public class AvatarFactoryModule : IAvatarFactory public class AvatarFactoryModule : IAvatarFactory
{ {
private Scene m_scene = null; private Scene m_scene = null;
private Dictionary<LLUUID, AvatarWearing> m_avatarsClothes = new Dictionary<LLUUID, AvatarWearing>(); private Dictionary<LLUUID, AvatarAppearance> m_avatarsClothes = new Dictionary<LLUUID, AvatarAppearance>();
public bool TryGetIntialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables, public bool TryGetIntialAvatarAppearance(LLUUID avatarId, out AvatarWearable[] wearables,
out byte[] visualParams) out byte[] visualParams)
@ -20,13 +20,13 @@ namespace OpenSim.Region.Environment.Modules
if (!m_avatarsClothes.ContainsKey(avatarId)) if (!m_avatarsClothes.ContainsKey(avatarId))
{ {
GetDefaultAvatarAppearance(out wearables, out visualParams); GetDefaultAvatarAppearance(out wearables, out visualParams);
AvatarWearing wearing = new AvatarWearing(wearables); AvatarAppearance wearing = new AvatarAppearance(wearables);
m_avatarsClothes[avatarId] = wearing; m_avatarsClothes[avatarId] = wearing;
return true; return true;
} }
else else
{ {
visualParams = SetDefaultVisualParams(); visualParams = GetDefaultVisualParams();
wearables = m_avatarsClothes[avatarId].IsWearing; wearables = m_avatarsClothes[avatarId].IsWearing;
return true; return true;
} }
@ -91,7 +91,7 @@ namespace OpenSim.Region.Environment.Modules
//Tempoaray dictionary storage. This is be storing to a database //Tempoaray dictionary storage. This is be storing to a database
if (m_avatarsClothes.ContainsKey(clientView.AgentId)) if (m_avatarsClothes.ContainsKey(clientView.AgentId))
{ {
AvatarWearing avWearing = m_avatarsClothes[clientView.AgentId]; AvatarAppearance avWearing = m_avatarsClothes[clientView.AgentId];
avWearing.IsWearing[wear.Type].AssetID = assetId; avWearing.IsWearing[wear.Type].AssetID = assetId;
avWearing.IsWearing[wear.Type].ItemID = wear.ItemID; avWearing.IsWearing[wear.Type].ItemID = wear.ItemID;
} }
@ -103,12 +103,11 @@ namespace OpenSim.Region.Environment.Modules
public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams) public static void GetDefaultAvatarAppearance(out AvatarWearable[] wearables, out byte[] visualParams)
{ {
visualParams = SetDefaultVisualParams(); visualParams = GetDefaultVisualParams();
wearables = AvatarWearable.DefaultWearables; wearables = AvatarWearable.DefaultWearables;
} }
private static byte[] SetDefaultVisualParams() private static byte[] GetDefaultVisualParams()
{ {
byte[] visualParams; byte[] visualParams;
visualParams = new byte[218]; visualParams = new byte[218];
@ -119,11 +118,12 @@ namespace OpenSim.Region.Environment.Modules
return visualParams; return visualParams;
} }
public class AvatarWearing public class AvatarAppearance
{ {
public AvatarWearable[] IsWearing; public AvatarWearable[] IsWearing;
public byte[] VisualParams;
public AvatarWearing() public AvatarAppearance()
{ {
IsWearing = new AvatarWearable[13]; IsWearing = new AvatarWearable[13];
for (int i = 0; i < 13; i++) for (int i = 0; i < 13; i++)
@ -132,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules
} }
} }
public AvatarWearing(AvatarWearable[] wearing) public AvatarAppearance(AvatarWearable[] wearing)
{ {
if (wearing.Length == 13) if (wearing.Length == 13)
{ {

View File

@ -190,9 +190,6 @@ namespace OpenSim.Region.Environment.Scenes
} }
replyPacket.Data = searchData; replyPacket.Data = searchData;
client.SendAvatarPickerReply(replyPacket); client.SendAvatarPickerReply(replyPacket);
} }
} }
} }

View File

@ -511,8 +511,7 @@ namespace OpenSim.Region.Environment.Scenes
for (int i = 0; i < visualParam.Length; i++) for (int i = 0; i < visualParam.Length; i++)
{ {
m_visualParams[i] = visualParam[i].ParamValue; m_visualParams[i] = visualParam[i].ParamValue;
//OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "VisualData[" + i.ToString() + "]: " + visualParam[i].ParamValue.ToString() + "m"); //OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "VisualData[" + i.ToString() + "]: " + visualParam[i].ParamValue.ToString() + "m");
} }
// Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters. // Teravus : Nifty AV Height Getting Maaaaagical formula. Oh how we love turning 0-255 into meters.