diff options
author | Teravus Ovares | 2008-01-07 07:48:35 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-01-07 07:48:35 +0000 |
commit | bbac579849b4fb949f417d2ddce097553607e626 (patch) | |
tree | 09c1d43325e8fcd532680745f29de7f9bcdc70a0 /OpenSim/Grid/MessagingServer/MessageService.cs | |
parent | Very minor refactoring. Remove unused prim inventory bool returns for now (diff) | |
download | opensim-SC-bbac579849b4fb949f417d2ddce097553607e626.zip opensim-SC-bbac579849b4fb949f417d2ddce097553607e626.tar.gz opensim-SC-bbac579849b4fb949f417d2ddce097553607e626.tar.bz2 opensim-SC-bbac579849b4fb949f417d2ddce097553607e626.tar.xz |
* More message server methods
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Grid/MessagingServer/MessageService.cs | 105 |
1 files changed, 103 insertions, 2 deletions
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; | |||
30 | using System.Net.Sockets; | 30 | using System.Net.Sockets; |
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Xml; | 33 | //using System.Xml; |
34 | using libsecondlife; | 34 | using libsecondlife; |
35 | using Nwc.XmlRpc; | 35 | using Nwc.XmlRpc; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
38 | using OpenSim.Framework.Data; | 38 | using OpenSim.Framework.Data; |
39 | using OpenSim.Framework.Servers; | 39 | using OpenSim.Framework.Servers; |
40 | using FriendRights = libsecondlife.FriendRights; | ||
40 | 41 | ||
41 | namespace OpenSim.Grid.MessagingServer | 42 | namespace 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> |