One more utility. Not used yet.

0.6.6-post-fixes
diva 2009-05-25 19:20:27 +00:00
parent ca9432d110
commit 896c206718
1 changed files with 22 additions and 2 deletions

View File

@ -45,6 +45,7 @@ using log4net;
using Nini.Config;
using Nwc.XmlRpc;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
namespace OpenSim.Framework
{
@ -1088,8 +1089,27 @@ namespace OpenSim.Framework
}
/// <summary>
/// Produces an OSDMap from its string representation on a stream
/// </summary>
/// <param name="data">The stream</param>
/// <param name="length">The size of the data on the stream</param>
/// <returns>The OSDMap or an exception</returns>
public static OSDMap GetOSDMap(Stream stream, int length)
{
byte[] data = new byte[length];
stream.Read(data, 0, length);
string strdata = Encoding.UTF8.GetString(data);
OSDMap args = null;
OSD buffer;
buffer = OSDParser.DeserializeJson(strdata);
if (buffer.Type == OSDType.Map)
{
args = (OSDMap)buffer;
return args;
}
return null;
}
}
}