Skip to content
Browse files

LIBOMV-477 Corrects TeleportFailedMessage to use OSDArrays instead of…

… maps even though there doesn't seem to be any reason a viewer would receive multiple responses for the same failed message.

* Moves EventDecoder to MessageUtils utility class
LIBOMV-492 Fixes null reference when message decoder sends a null response

git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2669 52acb1d6-8a22-11de-b505-999d5b087335
  • Loading branch information...
1 parent 9fa36f6 commit 8b493316b04d3cb32a6dc74402a83cf332919e2c @jimradford jimradford committed Apr 27, 2009
View
2 OpenMetaverse/Caps.cs
@@ -214,7 +214,7 @@ private void EventQueueConnectedHandler()
/// <param name="body"></param>
private void EventQueueEventHandler(string eventName, OSDMap body)
{
- IMessage message = DecodeEvent(eventName, body);
+ IMessage message = Messages.MessageUtils.DecodeEvent(eventName, body);
if (message != null)
{
if (Simulator.Client.Settings.SYNC_PACKETCALLBACKS)
View
20 OpenMetaverse/Messages/LindenMessages.cs
@@ -250,14 +250,20 @@ public OSDMap Serialize()
OSDMap map = new OSDMap(2);
OSDMap alertInfoMap = new OSDMap(2);
+
+
alertInfoMap["ExtraParams"] = OSD.FromString(ExtraParams);
alertInfoMap["Message"] = OSD.FromString(MessageKey);
- map["AlertInfo"] = alertInfoMap;
+ OSDArray alertArray = new OSDArray();
+ alertArray.Add(alertInfoMap);
+ map["AlertInfo"] = alertArray;
OSDMap infoMap = new OSDMap(2);
infoMap["AgentID"] = OSD.FromUUID(AgentID);
infoMap["Reason"] = OSD.FromString(Reason);
- map["Info"] = infoMap;
+ OSDArray infoArray = new OSDArray();
+ infoArray.Add(infoMap);
+ map["Info"] = infoArray;
return map;
@@ -269,11 +275,15 @@ public OSDMap Serialize()
/// <param name="map"></param>
public void Deserialize(OSDMap map)
{
- OSDMap alertInfoMap = (OSDMap)map["AlertInfo"];
+
+ OSDArray alertInfoArray = (OSDArray) map["AlertInfo"];
+
+ OSDMap alertInfoMap = (OSDMap) alertInfoArray[0];
ExtraParams = alertInfoMap["ExtraParams"].AsString();
MessageKey = alertInfoMap["Message"].AsString();
- OSDMap infoMap = (OSDMap) map["Info"];
+ OSDArray infoArray = (OSDArray) map["Info"];
+ OSDMap infoMap = (OSDMap) infoArray[0];
AgentID = infoMap["AgentID"].AsUUID();
Reason = infoMap["Reason"].AsString();
}
@@ -2037,7 +2047,7 @@ public void Deserialize(OSDMap map)
QueueEvent ev = new QueueEvent();
ev.MessageKey = eventMap["message"].AsString();
- ev.EventMessage = Caps.DecodeEvent(ev.MessageKey, (OSDMap)eventMap["body"]);
+ ev.EventMessage = MessageUtils.DecodeEvent(ev.MessageKey, (OSDMap)eventMap["body"]);
MessageEvents[i] = ev;
}
}
View
8 OpenMetaverse/Messages/MessageEventDecoder.cs
@@ -31,10 +31,10 @@
using OpenMetaverse.Interfaces;
using OpenMetaverse.Messages.Linden;
-namespace OpenMetaverse
+namespace OpenMetaverse.Messages
{
-
- public partial class Caps
+
+ public static partial class MessageUtils
{
/// <summary>
/// Return a decoded capabilities message as a strongly typed object
@@ -77,7 +77,7 @@ public static IMessage DecodeEvent(string eventName, OSDMap map)
case "ViewerStats": message = new ViewerStatsMessage(); break;
case "EventQueueGet": message = new EventQueueGetMessage(); break;
case "CrossedRegion": message = new CrossedRegionMessage(); break;
- case "TelportFailed": message = new TeleportFailedMessage(); break;
+ case "TeleportFailed": message = new TeleportFailedMessage(); break;
// Capabilities TODO:
View
2 OpenMetaverse/Messages/Messages.cs
@@ -31,7 +31,7 @@
namespace OpenMetaverse.Messages
{
- public static class MessageUtils
+ public static partial class MessageUtils
{
public static IPAddress ToIP(OSD osd)
{
View
19 Programs/WinGridProxy/Form1.cs
@@ -902,6 +902,9 @@ private void exitToolStripMenuItem1_Click(object sender, EventArgs e)
/// <returns>A formatted string containing the names and values of the source object</returns>
public static string IMessageToString(object message)
{
+ if (message == null)
+ return String.Empty;
+
StringBuilder result = new StringBuilder();
// common/custom types
result.AppendFormat("Message Type {0}" + System.Environment.NewLine, message.GetType().Name);
@@ -928,7 +931,7 @@ public static string IMessageToString(object message)
foreach (FieldInfo nestedField in nestedArrayObject.GetType().GetFields())
{
- var nt = nestedField.GetValue(nestedArrayObject).GetType().Name;
+ //var nt = nestedField.GetValue(nestedArrayObject).GetType().Name;
if (nestedField.FieldType.IsEnum)
{
result.AppendFormat("{0, 30}: {1} {2} ({3})" + System.Environment.NewLine,
@@ -937,11 +940,11 @@ public static string IMessageToString(object message)
nestedField.GetValue(nestedArrayObject), "D"),
nestedField.GetValue(nestedArrayObject),
nestedField.GetValue(nestedArrayObject).GetType().Name);
- }
- else if(nestedField.FieldType.IsInterface)
- {
- result.AppendLine(IMessageToString(nestedField.GetValue(nestedArrayObject)));
- }
+ }
+ else if (nestedField.FieldType.IsInterface)
+ {
+ result.AppendLine(IMessageToString(nestedField.GetValue(nestedArrayObject)));
+ }
else
{
result.AppendFormat("{0, 30}: {1} ({2})" + System.Environment.NewLine,
@@ -1331,9 +1334,9 @@ private string TagToString(object tag, string key)
OSDMap data = (OSDMap)osd;
IMessage message;
if (data.ContainsKey("body"))
- message = Caps.DecodeEvent(key, (OSDMap)data["body"]);
+ message = OpenMetaverse.Messages.MessageUtils.DecodeEvent(key, (OSDMap)data["body"]);
else
- message = Caps.DecodeEvent(key, data);
+ message = OpenMetaverse.Messages.MessageUtils.DecodeEvent(key, data);
if (message != null)
return IMessageToString(message);

0 comments on commit 8b49331

Please sign in to comment.
Something went wrong with that request. Please try again.