aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer/MessageServersConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer/MessageServersConnector.cs')
-rw-r--r--OpenSim/Grid/UserServer/MessageServersConnector.cs87
1 files changed, 86 insertions, 1 deletions
diff --git a/OpenSim/Grid/UserServer/MessageServersConnector.cs b/OpenSim/Grid/UserServer/MessageServersConnector.cs
index 8fecd5b..61f125e 100644
--- a/OpenSim/Grid/UserServer/MessageServersConnector.cs
+++ b/OpenSim/Grid/UserServer/MessageServersConnector.cs
@@ -32,19 +32,49 @@ using System.Reflection;
32using OpenMetaverse; 32using OpenMetaverse;
33using log4net; 33using log4net;
34using Nwc.XmlRpc; 34using Nwc.XmlRpc;
35using OpenSim.Framework;
35using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
37using System.Threading;
36 38
37namespace OpenSim.Grid.UserServer 39namespace OpenSim.Grid.UserServer
38{ 40{
41 public enum NotificationRequest : int
42 {
43 Login = 0,
44 Logout = 1,
45 Shutdown = 2
46 }
47
48 public struct PresenceNotification
49 {
50 public NotificationRequest request;
51 public UUID agentID;
52 public UUID sessionID;
53 public UUID RegionID;
54 public ulong regionhandle;
55 public float positionX;
56 public float positionY;
57 public float positionZ;
58 public string firstname;
59 public string lastname;
60 };
61
39 public class MessageServersConnector 62 public class MessageServersConnector
40 { 63 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 64 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42 65
43 public Dictionary<string, MessageServerInfo> MessageServers; 66 public Dictionary<string, MessageServerInfo> MessageServers;
44 67
68 private BlockingQueue<PresenceNotification> m_NotifyQueue =
69 new BlockingQueue<PresenceNotification>();
70
71 Thread m_NotifyThread;
72
45 public MessageServersConnector() 73 public MessageServersConnector()
46 { 74 {
47 MessageServers = new Dictionary<string, MessageServerInfo>(); 75 MessageServers = new Dictionary<string, MessageServerInfo>();
76 m_NotifyThread = new Thread(new ThreadStart(NotifyQueueRunner));
77 m_NotifyThread.Start();
48 } 78 }
49 79
50 public void RegisterMessageServer(string URI, MessageServerInfo serverData) 80 public void RegisterMessageServer(string URI, MessageServerInfo serverData)
@@ -159,6 +189,26 @@ namespace OpenSim.Grid.UserServer
159 ulong regionhandle, float positionX, float positionY, 189 ulong regionhandle, float positionX, float positionY,
160 float positionZ, string firstname, string lastname) 190 float positionZ, string firstname, string lastname)
161 { 191 {
192 PresenceNotification notification = new PresenceNotification();
193
194 notification.request = NotificationRequest.Login;
195 notification.agentID = agentID;
196 notification.sessionID = sessionID;
197 notification.RegionID = RegionID;
198 notification.regionhandle = regionhandle;
199 notification.positionX = positionX;
200 notification.positionY = positionY;
201 notification.positionZ = positionZ;
202 notification.firstname = firstname;
203 notification.lastname = lastname;
204
205 m_NotifyQueue.Enqueue(notification);
206 }
207
208 private void TellMessageServersAboutUserInternal(UUID agentID, UUID sessionID, UUID RegionID,
209 ulong regionhandle, float positionX, float positionY,
210 float positionZ, string firstname, string lastname)
211 {
162 // Loop over registered Message Servers (AND THERE WILL BE MORE THEN ONE :D) 212 // Loop over registered Message Servers (AND THERE WILL BE MORE THEN ONE :D)
163 lock (MessageServers) 213 lock (MessageServers)
164 { 214 {
@@ -179,7 +229,7 @@ namespace OpenSim.Grid.UserServer
179 } 229 }
180 } 230 }
181 231
182 public void TellMessageServersAboutUserLogoff(UUID agentID) 232 private void TellMessageServersAboutUserLogoffInternal(UUID agentID)
183 { 233 {
184 lock (MessageServers) 234 lock (MessageServers)
185 { 235 {
@@ -198,6 +248,16 @@ namespace OpenSim.Grid.UserServer
198 } 248 }
199 } 249 }
200 250
251 public void TellMessageServersAboutUserLogoff(UUID agentID)
252 {
253 PresenceNotification notification = new PresenceNotification();
254
255 notification.request = NotificationRequest.Logout;
256 notification.agentID = agentID;
257
258 m_NotifyQueue.Enqueue(notification);
259 }
260
201 private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID) 261 private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID)
202 { 262 {
203 Hashtable reqparams = new Hashtable(); 263 Hashtable reqparams = new Hashtable();
@@ -252,5 +312,30 @@ namespace OpenSim.Grid.UserServer
252 } 312 }
253 313
254 } 314 }
315
316 private void NotifyQueueRunner()
317 {
318 while (true)
319 {
320 PresenceNotification presence = m_NotifyQueue.Dequeue();
321
322 if (presence.request == NotificationRequest.Shutdown)
323 return;
324
325 if (presence.request == NotificationRequest.Login)
326 {
327 TellMessageServersAboutUserInternal(presence.agentID,
328 presence.sessionID, presence.RegionID,
329 presence.regionhandle, presence.positionX,
330 presence.positionY, presence.positionZ,
331 presence.firstname, presence.lastname);
332 }
333
334 if (presence.request == NotificationRequest.Logout)
335 {
336 TellMessageServersAboutUserLogoffInternal(presence.agentID);
337 }
338 }
339 }
255 } 340 }
256} 341}