LIBOMV-492 More WinGridProxy goodies:
* Inspector has separate windows for requests and responses to make viewing packets/messages that contain both easier * Added new Edit Menu which allows selecting, removing and colorizing sessions * Filter selection is stateful across restarts of the application * Cleaned up the logic for handling output of a selected session (still needs more love) LIBOMV-477 Corrected AgentGroupDataUpdateMessage to match what the SL Grid sends git-svn-id: http://libopenmetaverse.googlecode.com/svn/libopenmetaverse/trunk@2623 52acb1d6-8a22-11de-b505-999d5b087335
This commit is contained in:
105
Programs/WinGridProxy/SettingsStore.cs
Normal file
105
Programs/WinGridProxy/SettingsStore.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using System.IO;
|
||||
|
||||
namespace WinGridProxy
|
||||
{
|
||||
class SettingsStore
|
||||
{
|
||||
public Dictionary<string, bool> MessageSessions;
|
||||
|
||||
public Dictionary<string, bool> PacketSessions;
|
||||
|
||||
public SettingsStore()
|
||||
{
|
||||
MessageSessions = new Dictionary<string, bool>();
|
||||
PacketSessions = new Dictionary<string, bool>();
|
||||
}
|
||||
|
||||
public OSDMap Serialize()
|
||||
{
|
||||
OSDMap map = new OSDMap(2);
|
||||
OSDArray messageArray = new OSDArray(MessageSessions.Count);
|
||||
foreach (KeyValuePair<string, bool> kvp in MessageSessions)
|
||||
{
|
||||
OSDMap sessionMap = new OSDMap(2);
|
||||
sessionMap["Capability"] = OSD.FromString(kvp.Key);
|
||||
sessionMap["Capture"] = OSD.FromBoolean(kvp.Value);
|
||||
messageArray.Add(sessionMap);
|
||||
}
|
||||
map["message_sessions"] = messageArray;
|
||||
|
||||
OSDArray packetArray = new OSDArray(PacketSessions.Count);
|
||||
foreach (KeyValuePair<string, bool> kvp in PacketSessions)
|
||||
{
|
||||
OSDMap sessionMap = new OSDMap(2);
|
||||
sessionMap["PacketName"] = OSD.FromString(kvp.Key);
|
||||
sessionMap["Capture"] = OSD.FromBoolean(kvp.Value);
|
||||
packetArray.Add(sessionMap);
|
||||
}
|
||||
map["packet_sessions"] = packetArray;
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public void Deserialize(OSDMap map)
|
||||
{
|
||||
|
||||
if (map.ContainsKey("message_sessions"))
|
||||
{
|
||||
OSDArray messageArray = (OSDArray)map["message_sessions"];
|
||||
|
||||
MessageSessions = new Dictionary<string, bool>(messageArray.Count);
|
||||
|
||||
for (int i = 0; i < messageArray.Count; i++)
|
||||
{
|
||||
OSDMap m = (OSDMap)messageArray[i];
|
||||
MessageSessions.Add(m["Capability"].AsString(), m["Capture"].AsBoolean());
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//MessageSessions = new Dictionary<string, bool>();
|
||||
}
|
||||
|
||||
|
||||
if (map.ContainsKey("packet_sessions"))
|
||||
{
|
||||
OSDArray packetArray = (OSDArray)map["packet_sessions"];
|
||||
|
||||
PacketSessions = new Dictionary<string, bool>(packetArray.Count);
|
||||
|
||||
for (int i = 0; i < packetArray.Count; i++)
|
||||
{
|
||||
OSDMap packetMap = (OSDMap)packetArray[i];
|
||||
|
||||
PacketSessions.Add(packetMap["PacketName"].AsString(), packetMap["Capture"].AsBoolean());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//PacketSessions = new Dictionary<string, bool>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void DeserializeFromFile(string fileName)
|
||||
{
|
||||
|
||||
if(File.Exists(fileName))
|
||||
{
|
||||
OSDMap map = (OSDMap)OSDParser.DeserializeLLSDNotation(File.ReadAllText(fileName));
|
||||
this.Deserialize(map);
|
||||
}
|
||||
}
|
||||
|
||||
public void SerializeToFile(string fileName)
|
||||
{
|
||||
File.WriteAllText(fileName, this.Serialize().ToString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user