diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | 61 |
1 files changed, 58 insertions, 3 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 5aa87d3..b510d0a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -26,6 +26,8 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
29 | using Nini.Config; | 31 | using Nini.Config; |
30 | using log4net; | 32 | using log4net; |
31 | using Mono.Addins; | 33 | using Mono.Addins; |
@@ -34,6 +36,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
34 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
35 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
36 | using OpenSim.Services.Connectors; | 38 | using OpenSim.Services.Connectors; |
39 | using OpenSim.Framework; | ||
37 | 40 | ||
38 | using OpenMetaverse; | 41 | using OpenMetaverse; |
39 | 42 | ||
@@ -50,7 +53,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
50 | private bool m_Enabled = false; | 53 | private bool m_Enabled = false; |
51 | private UserAccountCache m_Cache; | 54 | private UserAccountCache m_Cache; |
52 | 55 | ||
53 | public Type ReplaceableInterface | 56 | public Type ReplaceableInterface |
54 | { | 57 | { |
55 | get { return null; } | 58 | get { return null; } |
56 | } | 59 | } |
@@ -103,6 +106,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
103 | return; | 106 | return; |
104 | 107 | ||
105 | scene.RegisterModuleInterface<IUserAccountService>(this); | 108 | scene.RegisterModuleInterface<IUserAccountService>(this); |
109 | scene.RegisterModuleInterface<IUserAccountCacheModule>(m_Cache); | ||
110 | |||
111 | scene.EventManager.OnNewClient += OnNewClient; | ||
106 | } | 112 | } |
107 | 113 | ||
108 | public void RemoveRegion(Scene scene) | 114 | public void RemoveRegion(Scene scene) |
@@ -117,12 +123,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
117 | return; | 123 | return; |
118 | } | 124 | } |
119 | 125 | ||
126 | // When a user actually enters the sim, clear them from | ||
127 | // cache so the sim will have the current values for | ||
128 | // flags, title, etc. And country, don't forget country! | ||
129 | private void OnNewClient(IClientAPI client) | ||
130 | { | ||
131 | m_Cache.Remove(client.Name); | ||
132 | } | ||
133 | |||
120 | #region Overwritten methods from IUserAccountService | 134 | #region Overwritten methods from IUserAccountService |
121 | 135 | ||
122 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) | 136 | public override UserAccount GetUserAccount(UUID scopeID, UUID userID) |
123 | { | 137 | { |
124 | bool inCache = false; | 138 | bool inCache = false; |
125 | UserAccount account = m_Cache.Get(userID, out inCache); | 139 | UserAccount account; |
140 | account = m_Cache.Get(userID, out inCache); | ||
126 | if (inCache) | 141 | if (inCache) |
127 | return account; | 142 | return account; |
128 | 143 | ||
@@ -135,7 +150,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
135 | public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) | 150 | public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName) |
136 | { | 151 | { |
137 | bool inCache = false; | 152 | bool inCache = false; |
138 | UserAccount account = m_Cache.Get(firstName + " " + lastName, out inCache); | 153 | UserAccount account; |
154 | account = m_Cache.Get(firstName + " " + lastName, out inCache); | ||
139 | if (inCache) | 155 | if (inCache) |
140 | return account; | 156 | return account; |
141 | 157 | ||
@@ -146,6 +162,45 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | |||
146 | return account; | 162 | return account; |
147 | } | 163 | } |
148 | 164 | ||
165 | public override List<UserAccount> GetUserAccounts(UUID scopeID, List<string> IDs) | ||
166 | { | ||
167 | List<UserAccount> accs = new List<UserAccount>(); | ||
168 | List<string> missing = new List<string>(); | ||
169 | |||
170 | UUID uuid = UUID.Zero; | ||
171 | UserAccount account; | ||
172 | bool inCache = false; | ||
173 | |||
174 | foreach(string id in IDs) | ||
175 | { | ||
176 | if(UUID.TryParse(id, out uuid)) | ||
177 | { | ||
178 | account = m_Cache.Get(uuid, out inCache); | ||
179 | if (inCache) | ||
180 | accs.Add(account); | ||
181 | else | ||
182 | missing.Add(id); | ||
183 | } | ||
184 | } | ||
185 | |||
186 | if(missing.Count > 0) | ||
187 | { | ||
188 | List<UserAccount> ext = base.GetUserAccounts(scopeID, missing); | ||
189 | if(ext != null && ext.Count >0 ) | ||
190 | { | ||
191 | foreach(UserAccount acc in ext) | ||
192 | { | ||
193 | if(acc != null) | ||
194 | { | ||
195 | accs.Add(acc); | ||
196 | m_Cache.Cache(acc.PrincipalID, acc); | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | return accs; | ||
202 | } | ||
203 | |||
149 | public override bool StoreUserAccount(UserAccount data) | 204 | public override bool StoreUserAccount(UserAccount data) |
150 | { | 205 | { |
151 | // This remote connector refuses to serve this method | 206 | // This remote connector refuses to serve this method |