aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs860
1 files changed, 430 insertions, 430 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs
index 5990fa6..10561a6 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsMessaging.cs
@@ -1,430 +1,430 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29//using System.Collections; 29//using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32 32
33 33
34using log4net; 34using log4net;
35using Nini.Config; 35using Nini.Config;
36 36
37using OpenMetaverse; 37using OpenMetaverse;
38using OpenMetaverse.StructuredData; 38using OpenMetaverse.StructuredData;
39 39
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Region.CoreModules.Framework.EventQueue; 41using OpenSim.Region.CoreModules.Framework.EventQueue;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
44 44
45 45
46using Caps = OpenSim.Framework.Communications.Capabilities.Caps; 46using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
47 47
48namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 48namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
49{ 49{
50 public class XmlRpcGroupsMessaging : INonSharedRegionModule 50 public class XmlRpcGroupsMessaging : INonSharedRegionModule
51 { 51 {
52 52
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 54
55 private List<Scene> m_SceneList = new List<Scene>(); 55 private List<Scene> m_SceneList = new List<Scene>();
56 56
57 // must be NonShared for this to work, otherewise we may actually get multiple active clients 57 // must be NonShared for this to work, otherewise we may actually get multiple active clients
58 private Dictionary<Guid, IClientAPI> m_ActiveClients = new Dictionary<Guid, IClientAPI>(); 58 private Dictionary<Guid, IClientAPI> m_ActiveClients = new Dictionary<Guid, IClientAPI>();
59 59
60 private IMessageTransferModule m_MsgTransferModule = null; 60 private IMessageTransferModule m_MsgTransferModule = null;
61 61
62 private IGroupsModule m_GroupsModule = null; 62 private IGroupsModule m_GroupsModule = null;
63 63
64 // Config Options 64 // Config Options
65 private bool m_GroupMessagingEnabled = true; 65 private bool m_GroupMessagingEnabled = true;
66 private bool m_debugEnabled = true; 66 private bool m_debugEnabled = true;
67 67
68 #region IRegionModule Members 68 #region IRegionModule Members
69 69
70 public void Initialise(IConfigSource config) 70 public void Initialise(IConfigSource config)
71 { 71 {
72 IConfig groupsConfig = config.Configs["Groups"]; 72 IConfig groupsConfig = config.Configs["Groups"];
73 73
74 m_log.Info("[GROUPS-MESSAGING]: Initializing XmlRpcGroupsMessaging"); 74 m_log.Info("[GROUPS-MESSAGING]: Initializing XmlRpcGroupsMessaging");
75 75
76 if (groupsConfig == null) 76 if (groupsConfig == null)
77 { 77 {
78 // Do not run this module by default. 78 // Do not run this module by default.
79 m_log.Info("[GROUPS-MESSAGING]: No config found in OpenSim.ini -- not enabling XmlRpcGroupsMessaging"); 79 m_log.Info("[GROUPS-MESSAGING]: No config found in OpenSim.ini -- not enabling XmlRpcGroupsMessaging");
80 return; 80 return;
81 } 81 }
82 else 82 else
83 { 83 {
84 if (!groupsConfig.GetBoolean("Enabled", false)) 84 if (!groupsConfig.GetBoolean("Enabled", false))
85 { 85 {
86 m_log.Info("[GROUPS-MESSAGING]: Groups disabled in configuration"); 86 m_log.Info("[GROUPS-MESSAGING]: Groups disabled in configuration");
87 return; 87 return;
88 } 88 }
89 89
90 if (groupsConfig.GetString("Module", "Default") != "XmlRpcGroups") 90 if (groupsConfig.GetString("Module", "Default") != "XmlRpcGroups")
91 { 91 {
92 m_log.Info("[GROUPS-MESSAGING]: Config Groups Module not set to XmlRpcGroups"); 92 m_log.Info("[GROUPS-MESSAGING]: Config Groups Module not set to XmlRpcGroups");
93 m_GroupMessagingEnabled = false; 93 m_GroupMessagingEnabled = false;
94 94
95 return; 95 return;
96 } 96 }
97 97
98 m_GroupMessagingEnabled = groupsConfig.GetBoolean("XmlRpcMessagingEnabled", true); 98 m_GroupMessagingEnabled = groupsConfig.GetBoolean("XmlRpcMessagingEnabled", true);
99 99
100 if (!m_GroupMessagingEnabled) 100 if (!m_GroupMessagingEnabled)
101 { 101 {
102 m_log.Info("[GROUPS-MESSAGING]: XmlRpcGroups Messaging disabled."); 102 m_log.Info("[GROUPS-MESSAGING]: XmlRpcGroups Messaging disabled.");
103 return; 103 return;
104 } 104 }
105 105
106 m_debugEnabled = groupsConfig.GetBoolean("XmlRpcDebugEnabled", true); 106 m_debugEnabled = groupsConfig.GetBoolean("XmlRpcDebugEnabled", true);
107 107
108 } 108 }
109 109
110 m_log.Info("[GROUPS-MESSAGING]: XmlRpcGroupsMessaging starting up"); 110 m_log.Info("[GROUPS-MESSAGING]: XmlRpcGroupsMessaging starting up");
111 111
112 } 112 }
113 113
114 public void AddRegion(Scene scene) 114 public void AddRegion(Scene scene)
115 { 115 {
116 } 116 }
117 public void RegionLoaded(Scene scene) 117 public void RegionLoaded(Scene scene)
118 { 118 {
119 if (!m_GroupMessagingEnabled) 119 if (!m_GroupMessagingEnabled)
120 return; 120 return;
121 121
122 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 122 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
123 123
124 124
125 m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>(); 125 m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
126 126
127 // No groups module, no groups messaging 127 // No groups module, no groups messaging
128 if (m_GroupsModule == null) 128 if (m_GroupsModule == null)
129 { 129 {
130 m_GroupMessagingEnabled = false; 130 m_GroupMessagingEnabled = false;
131 m_log.Info("[GROUPS-MESSAGING]: Could not get IGroupsModule, XmlRpcGroupsMessaging is now disabled."); 131 m_log.Info("[GROUPS-MESSAGING]: Could not get IGroupsModule, XmlRpcGroupsMessaging is now disabled.");
132 Close(); 132 Close();
133 return; 133 return;
134 } 134 }
135 135
136 m_MsgTransferModule = scene.RequestModuleInterface<IMessageTransferModule>(); 136 m_MsgTransferModule = scene.RequestModuleInterface<IMessageTransferModule>();
137 137
138 // No message transfer module, no groups messaging 138 // No message transfer module, no groups messaging
139 if (m_MsgTransferModule == null) 139 if (m_MsgTransferModule == null)
140 { 140 {
141 m_GroupMessagingEnabled = false; 141 m_GroupMessagingEnabled = false;
142 m_log.Info("[GROUPS-MESSAGING]: Could not get MessageTransferModule"); 142 m_log.Info("[GROUPS-MESSAGING]: Could not get MessageTransferModule");
143 Close(); 143 Close();
144 return; 144 return;
145 } 145 }
146 146
147 147
148 m_SceneList.Add(scene); 148 m_SceneList.Add(scene);
149 149
150 scene.EventManager.OnNewClient += OnNewClient; 150 scene.EventManager.OnNewClient += OnNewClient;
151 scene.EventManager.OnClientClosed += OnClientClosed; 151 scene.EventManager.OnClientClosed += OnClientClosed;
152 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 152 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
153 153
154 } 154 }
155 155
156 public void RemoveRegion(Scene scene) 156 public void RemoveRegion(Scene scene)
157 { 157 {
158 if (!m_GroupMessagingEnabled) 158 if (!m_GroupMessagingEnabled)
159 return; 159 return;
160 160
161 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 161 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
162 162
163 m_SceneList.Remove(scene); 163 m_SceneList.Remove(scene);
164 } 164 }
165 165
166 166
167 public void Close() 167 public void Close()
168 { 168 {
169 if (!m_GroupMessagingEnabled) 169 if (!m_GroupMessagingEnabled)
170 return; 170 return;
171 171
172 m_log.Debug("[GROUPS-MESSAGING]: Shutting down XmlRpcGroupsMessaging module."); 172 m_log.Debug("[GROUPS-MESSAGING]: Shutting down XmlRpcGroupsMessaging module.");
173 173
174 174
175 foreach (Scene scene in m_SceneList) 175 foreach (Scene scene in m_SceneList)
176 { 176 {
177 scene.EventManager.OnNewClient -= OnNewClient; 177 scene.EventManager.OnNewClient -= OnNewClient;
178 scene.EventManager.OnClientClosed -= OnClientClosed; 178 scene.EventManager.OnClientClosed -= OnClientClosed;
179 scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; 179 scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
180 } 180 }
181 181
182 m_SceneList.Clear(); 182 m_SceneList.Clear();
183 183
184 m_GroupsModule = null; 184 m_GroupsModule = null;
185 m_MsgTransferModule = null; 185 m_MsgTransferModule = null;
186 } 186 }
187 187
188 public string Name 188 public string Name
189 { 189 {
190 get { return "XmlRpcGroupsMessaging"; } 190 get { return "XmlRpcGroupsMessaging"; }
191 } 191 }
192 192
193 #endregion 193 #endregion
194 194
195 #region SimGridEventHandlers 195 #region SimGridEventHandlers
196 196
197 private void OnNewClient(IClientAPI client) 197 private void OnNewClient(IClientAPI client)
198 { 198 {
199 RegisterClientAgent(client); 199 RegisterClientAgent(client);
200 } 200 }
201 private void OnClientClosed(UUID AgentId) 201 private void OnClientClosed(UUID AgentId)
202 { 202 {
203 UnregisterClientAgent(AgentId); 203 UnregisterClientAgent(AgentId);
204 } 204 }
205 205
206 private void OnGridInstantMessage(GridInstantMessage msg) 206 private void OnGridInstantMessage(GridInstantMessage msg)
207 { 207 {
208 m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 208 m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
209 209
210 DebugGridInstantMessage(msg); 210 DebugGridInstantMessage(msg);
211 211
212 // Incoming message from a group 212 // Incoming message from a group
213 if ((msg.dialog == (byte)InstantMessageDialog.SessionSend) && (msg.fromGroup == true)) 213 if ((msg.dialog == (byte)InstantMessageDialog.SessionSend) && (msg.fromGroup == true))
214 { 214 {
215 if (m_ActiveClients.ContainsKey(msg.toAgentID)) 215 if (m_ActiveClients.ContainsKey(msg.toAgentID))
216 { 216 {
217 UUID GroupID = new UUID(msg.fromAgentID); 217 UUID GroupID = new UUID(msg.fromAgentID);
218 // SendMessageToGroup(im); 218 // SendMessageToGroup(im);
219 219
220 GroupRecord GroupInfo = m_GroupsModule.GetGroupRecord(GroupID); 220 GroupRecord GroupInfo = m_GroupsModule.GetGroupRecord(GroupID);
221 if (GroupInfo != null) 221 if (GroupInfo != null)
222 { 222 {
223 223
224 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] Sending chatterbox invite instant message"); 224 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] Sending chatterbox invite instant message");
225 225
226 // Force? open the group session dialog??? 226 // Force? open the group session dialog???
227 IEventQueue eq = m_ActiveClients[msg.toAgentID].Scene.RequestModuleInterface<IEventQueue>(); 227 IEventQueue eq = m_ActiveClients[msg.toAgentID].Scene.RequestModuleInterface<IEventQueue>();
228 eq.ChatterboxInvitation( 228 eq.ChatterboxInvitation(
229 GroupID 229 GroupID
230 , GroupInfo.GroupName 230 , GroupInfo.GroupName
231 , new UUID(msg.fromAgentID) 231 , new UUID(msg.fromAgentID)
232 , msg.message, new UUID(msg.toAgentID) 232 , msg.message, new UUID(msg.toAgentID)
233 , msg.fromAgentName 233 , msg.fromAgentName
234 , msg.dialog 234 , msg.dialog
235 , msg.timestamp 235 , msg.timestamp
236 , msg.offline==1 236 , msg.offline==1
237 , (int)msg.ParentEstateID 237 , (int)msg.ParentEstateID
238 , msg.Position 238 , msg.Position
239 , 1 239 , 1
240 , new UUID(msg.imSessionID) 240 , new UUID(msg.imSessionID)
241 , msg.fromGroup 241 , msg.fromGroup
242 , Utils.StringToBytes(GroupInfo.GroupName) 242 , Utils.StringToBytes(GroupInfo.GroupName)
243 ); 243 );
244 244
245 eq.ChatterBoxSessionAgentListUpdates( 245 eq.ChatterBoxSessionAgentListUpdates(
246 new UUID(GroupID) 246 new UUID(GroupID)
247 , new UUID(msg.fromAgentID) 247 , new UUID(msg.fromAgentID)
248 , new UUID(msg.toAgentID) 248 , new UUID(msg.toAgentID)
249 , false //canVoiceChat 249 , false //canVoiceChat
250 , false //isModerator 250 , false //isModerator
251 , false //text mute 251 , false //text mute
252 ); 252 );
253 253
254 } 254 }
255 } 255 }
256 } 256 }
257 257
258 } 258 }
259 259
260 #endregion 260 #endregion
261 261
262 #region ClientEvents 262 #region ClientEvents
263 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 263 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
264 { 264 {
265 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 265 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
266 266
267 DebugGridInstantMessage(im); 267 DebugGridInstantMessage(im);
268 268
269 // Start group IM session 269 // Start group IM session
270 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) 270 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
271 { 271 {
272 UUID GroupID = new UUID(im.toAgentID); 272 UUID GroupID = new UUID(im.toAgentID);
273 273
274 GroupRecord GroupInfo = m_GroupsModule.GetGroupRecord(GroupID); 274 GroupRecord GroupInfo = m_GroupsModule.GetGroupRecord(GroupID);
275 if (GroupInfo != null) 275 if (GroupInfo != null)
276 { 276 {
277 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] Start Group Session for {0}", GroupInfo.GroupName); 277 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] Start Group Session for {0}", GroupInfo.GroupName);
278 278
279 // remoteClient.SendInstantMessage(new GridInstantMessage(remoteClient.Scene, GroupID, GroupProfile.Name, remoteClient.AgentId, (byte)OpenMetaverse.InstantMessageDialog.SessionSend, true, "Welcome", GroupID, false, new Vector3(), new byte[0])); 279 // remoteClient.SendInstantMessage(new GridInstantMessage(remoteClient.Scene, GroupID, GroupProfile.Name, remoteClient.AgentId, (byte)OpenMetaverse.InstantMessageDialog.SessionSend, true, "Welcome", GroupID, false, new Vector3(), new byte[0]));
280 280
281 ChatterBoxSessionStartReplyViaCaps(remoteClient, GroupInfo.GroupName, GroupID); 281 ChatterBoxSessionStartReplyViaCaps(remoteClient, GroupInfo.GroupName, GroupID);
282 282
283 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 283 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
284 queue.ChatterBoxSessionAgentListUpdates( 284 queue.ChatterBoxSessionAgentListUpdates(
285 new UUID(GroupID) 285 new UUID(GroupID)
286 , new UUID(im.fromAgentID) 286 , new UUID(im.fromAgentID)
287 , new UUID(im.toAgentID) 287 , new UUID(im.toAgentID)
288 , false //canVoiceChat 288 , false //canVoiceChat
289 , false //isModerator 289 , false //isModerator
290 , false //text mute 290 , false //text mute
291 ); 291 );
292 } 292 }
293 } 293 }
294 294
295 // Send a message to a group 295 // Send a message to a group
296 if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) 296 if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
297 { 297 {
298 UUID GroupID = new UUID(im.toAgentID); 298 UUID GroupID = new UUID(im.toAgentID);
299 299
300 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] Send message to session for group {0}", GroupID); 300 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] Send message to session for group {0}", GroupID);
301 301
302 SendMessageToGroup(im, GroupID); 302 SendMessageToGroup(im, GroupID);
303 } 303 }
304 304
305 // Incoming message from a group 305 // Incoming message from a group
306 if ((im.dialog == (byte)InstantMessageDialog.SessionSend) && (im.fromGroup == true)) 306 if ((im.dialog == (byte)InstantMessageDialog.SessionSend) && (im.fromGroup == true))
307 { 307 {
308 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] Message from group session {0} going to agent {1}", im.fromAgentID, im.toAgentID); 308 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] Message from group session {0} going to agent {1}", im.fromAgentID, im.toAgentID);
309 } 309 }
310 } 310 }
311 #endregion 311 #endregion
312 312
313 private void RegisterClientAgent(IClientAPI client) 313 private void RegisterClientAgent(IClientAPI client)
314 { 314 {
315 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 315 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
316 316
317 lock (m_ActiveClients) 317 lock (m_ActiveClients)
318 { 318 {
319 if (!m_ActiveClients.ContainsKey(client.AgentId.Guid)) 319 if (!m_ActiveClients.ContainsKey(client.AgentId.Guid))
320 { 320 {
321 client.OnInstantMessage += OnInstantMessage; 321 client.OnInstantMessage += OnInstantMessage;
322 322
323 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] OnInstantMessage registered for {0}", client.Name); 323 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] OnInstantMessage registered for {0}", client.Name);
324 324
325 m_ActiveClients.Add(client.AgentId.Guid, client); 325 m_ActiveClients.Add(client.AgentId.Guid, client);
326 } 326 }
327 else 327 else
328 { 328 {
329 // Remove old client connection for this agent 329 // Remove old client connection for this agent
330 UnregisterClientAgent(client.AgentId); 330 UnregisterClientAgent(client.AgentId);
331 331
332 // Add new client connection 332 // Add new client connection
333 RegisterClientAgent(client); 333 RegisterClientAgent(client);
334 } 334 }
335 } 335 }
336 } 336 }
337 private void UnregisterClientAgent(UUID agentID) 337 private void UnregisterClientAgent(UUID agentID)
338 { 338 {
339 lock (m_ActiveClients) 339 lock (m_ActiveClients)
340 { 340 {
341 if (m_ActiveClients.ContainsKey(agentID.Guid)) 341 if (m_ActiveClients.ContainsKey(agentID.Guid))
342 { 342 {
343 IClientAPI client = m_ActiveClients[agentID.Guid]; 343 IClientAPI client = m_ActiveClients[agentID.Guid];
344 client.OnInstantMessage -= OnInstantMessage; 344 client.OnInstantMessage -= OnInstantMessage;
345 345
346 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] OnInstantMessage unregistered for {0}", client.Name); 346 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] OnInstantMessage unregistered for {0}", client.Name);
347 347
348 m_ActiveClients.Remove(agentID.Guid); 348 m_ActiveClients.Remove(agentID.Guid);
349 } 349 }
350 else 350 else
351 { 351 {
352 m_log.InfoFormat("[GROUPS-MESSAGING] Client closed that wasn't registered here."); 352 m_log.InfoFormat("[GROUPS-MESSAGING] Client closed that wasn't registered here.");
353 } 353 }
354 } 354 }
355 } 355 }
356 356
357 private void SendMessageToGroup(GridInstantMessage im, UUID groupID) 357 private void SendMessageToGroup(GridInstantMessage im, UUID groupID)
358 { 358 {
359 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 359 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
360 360
361 GridInstantMessage msg = new GridInstantMessage(); 361 GridInstantMessage msg = new GridInstantMessage();
362 msg.imSessionID = im.imSessionID; 362 msg.imSessionID = im.imSessionID;
363 msg.fromAgentID = im.imSessionID; // GroupID 363 msg.fromAgentID = im.imSessionID; // GroupID
364 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 364 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();
365 msg.fromAgentName = im.fromAgentName; 365 msg.fromAgentName = im.fromAgentName;
366 msg.message = im.message; 366 msg.message = im.message;
367 msg.dialog = im.dialog; 367 msg.dialog = im.dialog;
368 msg.fromGroup = true; 368 msg.fromGroup = true;
369 msg.offline = (byte)0; 369 msg.offline = (byte)0;
370 msg.ParentEstateID = im.ParentEstateID; 370 msg.ParentEstateID = im.ParentEstateID;
371 msg.Position = im.Position; 371 msg.Position = im.Position;
372 msg.RegionID = im.RegionID; 372 msg.RegionID = im.RegionID;
373 msg.binaryBucket = new byte[1] { 0 }; 373 msg.binaryBucket = new byte[1] { 0 };
374 374
375 foreach (GroupMembersData member in m_GroupsModule.GroupMembersRequest(null, groupID)) 375 foreach (GroupMembersData member in m_GroupsModule.GroupMembersRequest(null, groupID))
376 { 376 {
377 msg.toAgentID = member.AgentID.Guid; 377 msg.toAgentID = member.AgentID.Guid;
378 m_MsgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); 378 m_MsgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
379 } 379 }
380 } 380 }
381 381
382 void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID) 382 void ChatterBoxSessionStartReplyViaCaps(IClientAPI remoteClient, string groupName, UUID groupID)
383 { 383 {
384 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 384 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
385 385
386 OSDMap moderatedMap = new OSDMap(4); 386 OSDMap moderatedMap = new OSDMap(4);
387 moderatedMap.Add("voice", OSD.FromBoolean(false)); 387 moderatedMap.Add("voice", OSD.FromBoolean(false));
388 388
389 OSDMap sessionMap = new OSDMap(4); 389 OSDMap sessionMap = new OSDMap(4);
390 sessionMap.Add("moderated_mode", moderatedMap); 390 sessionMap.Add("moderated_mode", moderatedMap);
391 sessionMap.Add("session_name", OSD.FromString(groupName)); 391 sessionMap.Add("session_name", OSD.FromString(groupName));
392 sessionMap.Add("type", OSD.FromInteger(0)); 392 sessionMap.Add("type", OSD.FromInteger(0));
393 sessionMap.Add("voice_enabled", OSD.FromBoolean(false)); 393 sessionMap.Add("voice_enabled", OSD.FromBoolean(false));
394 394
395 395
396 OSDMap bodyMap = new OSDMap(4); 396 OSDMap bodyMap = new OSDMap(4);
397 bodyMap.Add("session_id", OSD.FromUUID(groupID)); 397 bodyMap.Add("session_id", OSD.FromUUID(groupID));
398 bodyMap.Add("temp_session_id", OSD.FromUUID(groupID)); 398 bodyMap.Add("temp_session_id", OSD.FromUUID(groupID));
399 bodyMap.Add("success", OSD.FromBoolean(true)); 399 bodyMap.Add("success", OSD.FromBoolean(true));
400 bodyMap.Add("session_info", sessionMap); 400 bodyMap.Add("session_info", sessionMap);
401 401
402 402
403 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 403 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
404 404
405 if (queue != null) 405 if (queue != null)
406 { 406 {
407 queue.Enqueue(EventQueueHelper.buildEvent("ChatterBoxSessionStartReply", bodyMap), remoteClient.AgentId); 407 queue.Enqueue(EventQueueHelper.buildEvent("ChatterBoxSessionStartReply", bodyMap), remoteClient.AgentId);
408 } 408 }
409 409
410 } 410 }
411 411
412 412
413 private void DebugGridInstantMessage(GridInstantMessage im) 413 private void DebugGridInstantMessage(GridInstantMessage im)
414 { 414 {
415 if (m_debugEnabled) 415 if (m_debugEnabled)
416 { 416 {
417 m_log.WarnFormat("[GROUPS-MESSAGING] IM: fromGroup({0})", im.fromGroup ? "True" : "False"); 417 m_log.WarnFormat("[GROUPS-MESSAGING] IM: fromGroup({0})", im.fromGroup ? "True" : "False");
418 m_log.WarnFormat("[GROUPS-MESSAGING] IM: Dialog({0})", ((InstantMessageDialog)im.dialog).ToString()); 418 m_log.WarnFormat("[GROUPS-MESSAGING] IM: Dialog({0})", ((InstantMessageDialog)im.dialog).ToString());
419 m_log.WarnFormat("[GROUPS-MESSAGING] IM: fromAgentID({0})", im.fromAgentID.ToString()); 419 m_log.WarnFormat("[GROUPS-MESSAGING] IM: fromAgentID({0})", im.fromAgentID.ToString());
420 m_log.WarnFormat("[GROUPS-MESSAGING] IM: fromAgentName({0})", im.fromAgentName.ToString()); 420 m_log.WarnFormat("[GROUPS-MESSAGING] IM: fromAgentName({0})", im.fromAgentName.ToString());
421 m_log.WarnFormat("[GROUPS-MESSAGING] IM: imSessionID({0})", im.imSessionID.ToString()); 421 m_log.WarnFormat("[GROUPS-MESSAGING] IM: imSessionID({0})", im.imSessionID.ToString());
422 m_log.WarnFormat("[GROUPS-MESSAGING] IM: message({0})", im.message.ToString()); 422 m_log.WarnFormat("[GROUPS-MESSAGING] IM: message({0})", im.message.ToString());
423 m_log.WarnFormat("[GROUPS-MESSAGING] IM: offline({0})", im.offline.ToString()); 423 m_log.WarnFormat("[GROUPS-MESSAGING] IM: offline({0})", im.offline.ToString());
424 m_log.WarnFormat("[GROUPS-MESSAGING] IM: toAgentID({0})", im.toAgentID.ToString()); 424 m_log.WarnFormat("[GROUPS-MESSAGING] IM: toAgentID({0})", im.toAgentID.ToString());
425 m_log.WarnFormat("[GROUPS-MESSAGING] IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket")); 425 m_log.WarnFormat("[GROUPS-MESSAGING] IM: binaryBucket({0})", OpenMetaverse.Utils.BytesToHexString(im.binaryBucket, "BinaryBucket"));
426 } 426 }
427 } 427 }
428 428
429 } 429 }
430} 430}