aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorTeravus Ovares2008-01-07 07:48:35 +0000
committerTeravus Ovares2008-01-07 07:48:35 +0000
commitbbac579849b4fb949f417d2ddce097553607e626 (patch)
tree09c1d43325e8fcd532680745f29de7f9bcdc70a0
parentVery minor refactoring. Remove unused prim inventory bool returns for now (diff)
downloadopensim-SC_OLD-bbac579849b4fb949f417d2ddce097553607e626.zip
opensim-SC_OLD-bbac579849b4fb949f417d2ddce097553607e626.tar.gz
opensim-SC_OLD-bbac579849b4fb949f417d2ddce097553607e626.tar.bz2
opensim-SC_OLD-bbac579849b4fb949f417d2ddce097553607e626.tar.xz
* More message server methods
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/FriendListItem.cs1
-rw-r--r--OpenSim/Grid/MessagingServer/MessageService.cs105
-rw-r--r--OpenSim/Grid/MessagingServer/UserPresenceData.cs1
3 files changed, 105 insertions, 2 deletions
diff --git a/OpenSim/Framework/FriendListItem.cs b/OpenSim/Framework/FriendListItem.cs
index 349ee97..f090ab1 100644
--- a/OpenSim/Framework/FriendListItem.cs
+++ b/OpenSim/Framework/FriendListItem.cs
@@ -34,6 +34,7 @@ namespace OpenSim.Framework
34{ 34{
35 public class FriendListItem 35 public class FriendListItem
36 { 36 {
37
37 public LLUUID FriendListOwner; 38 public LLUUID FriendListOwner;
38 public LLUUID Friend; 39 public LLUUID Friend;
39 40
diff --git a/OpenSim/Grid/MessagingServer/MessageService.cs b/OpenSim/Grid/MessagingServer/MessageService.cs
index a4362c7..d8221dc 100644
--- a/OpenSim/Grid/MessagingServer/MessageService.cs
+++ b/OpenSim/Grid/MessagingServer/MessageService.cs
@@ -30,13 +30,14 @@ using System.Net;
30using System.Net.Sockets; 30using System.Net.Sockets;
31using System.Collections; 31using System.Collections;
32using System.Collections.Generic; 32using System.Collections.Generic;
33using System.Xml; 33//using System.Xml;
34using libsecondlife; 34using libsecondlife;
35using Nwc.XmlRpc; 35using Nwc.XmlRpc;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Console; 37using OpenSim.Framework.Console;
38using OpenSim.Framework.Data; 38using OpenSim.Framework.Data;
39using OpenSim.Framework.Servers; 39using OpenSim.Framework.Servers;
40using FriendRights = libsecondlife.FriendRights;
40 41
41namespace OpenSim.Grid.MessagingServer 42namespace OpenSim.Grid.MessagingServer
42{ 43{
@@ -44,9 +45,16 @@ namespace OpenSim.Grid.MessagingServer
44 { 45 {
45 private LogBase m_log; 46 private LogBase m_log;
46 private MessageServerConfig m_cfg; 47 private MessageServerConfig m_cfg;
48
49 //A hashtable of all current presences this server knows about
47 private Hashtable m_presences = new Hashtable(); 50 private Hashtable m_presences = new Hashtable();
51
52 //a hashtable of all current regions this server knows about
48 private Hashtable m_regionInfoCache = new Hashtable(); 53 private Hashtable m_regionInfoCache = new Hashtable();
49 54
55 //A hashtable containing lists of UUIDs keyed by UUID for fast backreferencing
56 private Hashtable m_presence_BackReferences = new Hashtable();
57
50 public MessageService(LogBase log, MessageServerConfig cfg) 58 public MessageService(LogBase log, MessageServerConfig cfg)
51 { 59 {
52 m_log = log; 60 m_log = log;
@@ -80,13 +88,104 @@ namespace OpenSim.Grid.MessagingServer
80 } 88 }
81 89
82 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]); 90 ulong regionHandle = Convert.ToUInt64((string)requestData["regionhandle"]);
91
92 UserPresenceData up = new UserPresenceData();
93 up.agentData = agentData;
94 List<FriendListItem> flData = GetUserFriendList(agentData.AgentID);
95 up.friendData = flData;
96 RegionInfo riData = GetRegionInfo(regionHandle);
97 up.regionData = riData;
83 98
84 m_presences.Add(regionHandle, agentData); 99 ProcessFriendListSubscriptions(up);
85 100
86 101
87 return new XmlRpcResponse(); 102 return new XmlRpcResponse();
88 } 103 }
104 #region FriendList Methods
105
106 #region FriendListProcessing
107
108 public void ProcessFriendListSubscriptions(UserPresenceData userpresence)
109 {
110 List<FriendListItem> uFriendList = userpresence.friendData;
111 for (int i = 0; i < uFriendList.Count; i++)
112 {
113 if (m_presences.Contains(uFriendList[i].Friend))
114 {
115 UserPresenceData friendup = (UserPresenceData)m_presences[uFriendList[i]];
116 SubscribeToPresenceUpdates(userpresence, friendup, uFriendList[i],i);
117 }
118 }
119
120 m_presences.Add(userpresence.agentData.AgentID, userpresence);
121 }
122
123 public void SubscribeToPresenceUpdates(UserPresenceData userpresence, UserPresenceData friendpresence,
124 FriendListItem uFriendListItem, int uFriendListIndex)
125 {
126
127 if ((uFriendListItem.FriendListOwnerPerms & (uint)FriendRights.CanSeeOnline) != 0)
128 {
129 // Subscribe and Send Out updates
130 // Add backreference
131 m_presence_BackReferences.Add(userpresence.agentData.AgentID, friendpresence.agentData.AgentID);
132 }
133
134
135
136
137 }
138
139 /// <summary>
140 /// Adds a backreference so presence specific data doesn't have to be
141 /// enumerated for each logged in user every time someone logs on or off.
142 /// </summary>
143 /// <param name="agentID"></param>
144 /// <param name="friendID"></param>
145 public void addBackReference(LLUUID agentID, LLUUID friendID)
146 {
147 if (m_presence_BackReferences.Contains(agentID))
148 {
149 List<LLUUID> presenseBackReferences = (List<LLUUID>)m_presence_BackReferences[agentID];
150 if (!presenseBackReferences.Contains(friendID))
151 {
152 presenseBackReferences.Add(friendID);
153 }
154 m_presence_BackReferences[agentID] = presenseBackReferences;
155 }
156 else
157 {
158 List<LLUUID> presenceBackReferences = new List<LLUUID>();
159 presenceBackReferences.Add(friendID);
160 m_presence_BackReferences[agentID] = presenceBackReferences;
161 }
162 }
89 163
164 /// <summary>
165 /// Removes a backreference to free up some memory
166 /// </summary>
167 /// <param name="agentID"></param>
168 /// <param name="friendID"></param>
169 public void removeBackReference(LLUUID agentID, LLUUID friendID)
170 {
171 if (m_presence_BackReferences.Contains(agentID))
172 {
173 List<LLUUID> presenseBackReferences = (List<LLUUID>)m_presence_BackReferences[agentID];
174 if (presenseBackReferences.Contains(friendID))
175 {
176 presenseBackReferences.Remove(friendID);
177 }
178
179 // If there are no more backreferences for this agent,
180 // remove it to free up memory.
181 if (presenseBackReferences.Count == 0)
182 {
183 m_presence_BackReferences.Remove(agentID);
184 }
185 }
186 }
187
188 #endregion
90 189
91 #region FriendList Gathering 190 #region FriendList Gathering
92 191
@@ -147,6 +246,8 @@ namespace OpenSim.Grid.MessagingServer
147 } 246 }
148 #endregion 247 #endregion
149 248
249 #endregion
250
150 #region regioninfo gathering 251 #region regioninfo gathering
151 252
152 /// <summary> 253 /// <summary>
diff --git a/OpenSim/Grid/MessagingServer/UserPresenceData.cs b/OpenSim/Grid/MessagingServer/UserPresenceData.cs
index 88007ae..1391460 100644
--- a/OpenSim/Grid/MessagingServer/UserPresenceData.cs
+++ b/OpenSim/Grid/MessagingServer/UserPresenceData.cs
@@ -38,6 +38,7 @@ namespace OpenSim.Grid.MessagingServer
38 public AgentCircuitData agentData = new AgentCircuitData(); 38 public AgentCircuitData agentData = new AgentCircuitData();
39 public RegionInfo regionData = new RegionInfo(); 39 public RegionInfo regionData = new RegionInfo();
40 public List<FriendListItem> friendData = new List<FriendListItem> (); 40 public List<FriendListItem> friendData = new List<FriendListItem> ();
41 public List<LLUUID> subscriptionData = new List<LLUUID>();
41 42
42 public UserPresenceData() 43 public UserPresenceData()
43 { 44 {