30 using System.Reflection;
32 using System.Collections.Generic;
34 using OpenMetaverse.StructuredData;
37 using OpenSim.Region.Framework;
38 using OpenSim.Region.Framework.Scenes;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Framework;
41 using OpenSim.Framework.Servers;
42 using OpenSim.Framework.Servers.HttpServer;
51 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"DynamicFloater")]
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 private Scene m_scene;
58 private Dictionary<UUID, Dictionary<int, FloaterData>> m_floaters =
new Dictionary<UUID, Dictionary<int, FloaterData>>();
62 get {
return "DynamicFloaterModule"; }
65 public Type ReplaceableInterface
81 scene.EventManager.OnNewClient += OnNewClient;
82 scene.EventManager.OnClientClosed += OnClientClosed;
96 client.OnChatFromClient += OnChatFromClient;
99 private void OnClientClosed(UUID agentID,
Scene scene)
101 m_floaters.Remove(agentID);
106 sp.ControllingClient.SendChatMessage(msg,
112 (byte)ChatSourceType.Object,
113 (byte)ChatAudibleLevel.Fully);
122 if (!m_floaters.ContainsKey(agentID))
123 m_floaters[agentID] =
new Dictionary<int, FloaterData>();
125 if (m_floaters[agentID].ContainsKey(dialogData.
Channel))
128 m_floaters[agentID].Add(dialogData.Channel, dialogData);
133 xml = dialogData.XmlText;
137 using (FileStream fs = File.Open(dialogData.XmlName +
".xml", FileMode.Open))
139 using (StreamReader sr =
new StreamReader(fs))
140 xml = sr.ReadToEnd().Replace(
"\n",
"");
144 List<string> xparts =
new List<string>();
146 while (xml.Length > 0)
151 x = x.Substring(0, 600);
152 xml = xml.Substring(600);
162 for (
int i = 0 ; i < xparts.Count ; i++)
163 SendToClient(sp,
String.Format(
"># floater {2} create {0}/{1} " + xparts[i], i + 1, xparts.Count, dialogData.
FloaterName));
165 SendToClient(sp,
String.Format(
"># floater {0} {{notify:1}} {{channel: {1}}} {{node:cancel {{notify:1}}}} {{node:ok {{notify:1}}}} {2}", dialogData.
FloaterName, (uint)dialogData.
Channel, configuration));
168 private void OnChatFromClient(
object sender,
OSChatMessage msg)
177 if (!m_floaters.ContainsKey(client.
AgentId))
180 string[] parts = msg.Message.Split(
new char[] {
':'});
181 if (parts.Length == 0)
188 Dictionary<int, FloaterData> d = m_floaters[client.AgentId];
195 if (parts[0] ==
"VALUE")
199 if(dd.
Handler(client, dd, parts))
201 m_floaters[client.AgentId].Remove(dd.Channel);
210 if (!d.ContainsKey(msg.
Channel))
215 if (parts[0] ==
"NOTIFY")
217 if (parts[1] ==
"cancel" || parts[1] == data.
FloaterName)
219 m_floaters[client.AgentId].Remove(data.Channel);
226 m_floaters[client.AgentId].Remove(data.Channel);
233 string sendData = String.Format(
"># floater {0} {1}", d.FloaterName, msg);
234 SendToClient(sp, sendData);
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...
IClientAPI Sender
The client responsible for sending the message, or null.
virtual HandlerDelegate Handler
OpenMetaverse.StructuredData.OSDMap OSDMap
OpenSim.Framework.Capabilities.Caps Caps
abstract string FloaterName
OpenMetaverse.StructuredData.OSDMap OSDMap
void DoUserFloater(UUID agentID, FloaterData dialogData, string configuration)
OpenSim.Framework.Capabilities.Caps Caps
override Vector3 AbsolutePosition
Position of this avatar relative to the region the avatar is in
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
Interactive OpenSim region server
void FloaterControl(ScenePresence sp, FloaterData d, string msg)
int Channel
Which channel was this message sent on? Different channels may have different listeners. Public chat is on channel zero.
void Initialise(IConfigSource config)
This is called to initialize the region module. For shared modules, this is called exactly once...