aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTeravus Ovares2008-04-10 18:30:34 +0000
committerTeravus Ovares2008-04-10 18:30:34 +0000
commit50c5e6af1086df7c0f17c4f75091dbcadb776846 (patch)
treecb2d95a5409f6af3643733122aed1b3494128af4 /OpenSim/Region
parent* Minor: really just comment and subsequent indentation adjustment. Preparat... (diff)
downloadopensim-SC_OLD-50c5e6af1086df7c0f17c4f75091dbcadb776846.zip
opensim-SC_OLD-50c5e6af1086df7c0f17c4f75091dbcadb776846.tar.gz
opensim-SC_OLD-50c5e6af1086df7c0f17c4f75091dbcadb776846.tar.bz2
opensim-SC_OLD-50c5e6af1086df7c0f17c4f75091dbcadb776846.tar.xz
* With Grid Comms up in the air.. I decided have the friends module update you when your friends come online if they're at least a child agent on the sim. offline status works the same also. So does Instant Message.
* This is until Grid Comms matures a bit more on this. * This should also work in Standalone as it uses the IUserData interface.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Communications/OGS1/OGS1UserServices.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/FriendsModule.cs138
-rw-r--r--OpenSim/Region/Environment/Modules/InstantMessageModule.cs20
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs7
4 files changed, 166 insertions, 1 deletions
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
index 906101b..5873eb8 100644
--- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
+++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs
@@ -516,7 +516,7 @@ namespace OpenSim.Region.Communications.OGS1
516 IList parameters = new ArrayList(); 516 IList parameters = new ArrayList();
517 parameters.Add(param); 517 parameters.Add(param);
518 XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters); 518 XmlRpcRequest req = new XmlRpcRequest("get_user_friend_list", parameters);
519 XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 3000); 519 XmlRpcResponse resp = req.Send(m_parent.NetworkServersInfo.UserURL, 8000);
520 Hashtable respData = (Hashtable) resp.Value; 520 Hashtable respData = (Hashtable) resp.Value;
521 521
522 if (respData.Contains("avcount")) 522 if (respData.Contains("avcount"))
diff --git a/OpenSim/Region/Environment/Modules/FriendsModule.cs b/OpenSim/Region/Environment/Modules/FriendsModule.cs
index 7560c90..fc14df7 100644
--- a/OpenSim/Region/Environment/Modules/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/FriendsModule.cs
@@ -27,6 +27,7 @@
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using libsecondlife; 29using libsecondlife;
30using libsecondlife.Packets;
30using Nini.Config; 31using Nini.Config;
31using Nwc.XmlRpc; 32using Nwc.XmlRpc;
32using OpenSim.Framework; 33using OpenSim.Framework;
@@ -45,6 +46,8 @@ namespace OpenSim.Region.Environment.Modules
45 46
46 Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>(); 47 Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
47 48
49 Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
50
48 public void Initialise(Scene scene, IConfigSource config) 51 public void Initialise(Scene scene, IConfigSource config)
49 { 52 {
50 lock (m_scene) 53 lock (m_scene)
@@ -78,11 +81,92 @@ namespace OpenSim.Region.Environment.Modules
78 // Generated by LoginService. The friends are retreived from the database by the UserManager 81 // Generated by LoginService. The friends are retreived from the database by the UserManager
79 82
80 // Subscribe to instant messages 83 // Subscribe to instant messages
84
81 client.OnInstantMessage += OnInstantMessage; 85 client.OnInstantMessage += OnInstantMessage;
82 client.OnApproveFriendRequest += OnApprovedFriendRequest; 86 client.OnApproveFriendRequest += OnApprovedFriendRequest;
83 client.OnDenyFriendRequest += OnDenyFriendRequest; 87 client.OnDenyFriendRequest += OnDenyFriendRequest;
84 client.OnTerminateFriendship += OnTerminateFriendship; 88 client.OnTerminateFriendship += OnTerminateFriendship;
89
90 List<FriendListItem> fl = new List<FriendListItem>();
91 lock (FriendLists)
92 {
93 if (FriendLists.ContainsKey(client.AgentId))
94 {
95 fl = FriendLists[client.AgentId];
96 }
97 else
98 {
99 fl = m_scene[0].GetFriendList(client.AgentId);
100 lock (FriendLists)
101 {
102 if (!FriendLists.ContainsKey(client.AgentId))
103 FriendLists.Add(client.AgentId, fl);
104 }
105 }
106 }
85 107
108 List<LLUUID> UpdateUsers = new List<LLUUID>();
109
110 foreach (FriendListItem f in fl)
111 {
112 if (m_rootAgents.ContainsKey(f.Friend))
113 {
114 if (f.onlinestatus == false)
115 {
116 UpdateUsers.Add(f.Friend);
117 f.onlinestatus = true;
118 }
119 }
120 }
121 foreach (LLUUID user in UpdateUsers)
122 {
123 ScenePresence av = GetPresenceFromAgentID(user);
124 if (av != null)
125 {
126 List<FriendListItem> usrfl = new List<FriendListItem>();
127
128 lock (FriendLists)
129 {
130 usrfl = FriendLists[user];
131 }
132
133 lock (usrfl)
134 {
135 foreach (FriendListItem fli in usrfl)
136 {
137 if (fli.Friend == client.AgentId)
138 {
139 fli.onlinestatus = true;
140 OnlineNotificationPacket onp = new OnlineNotificationPacket();
141 OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[1];
142 OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
143 onpbl.AgentID = client.AgentId;
144 onpb[0] = onpbl;
145 onp.AgentBlock = onpb;
146 av.ControllingClient.OutPacket(onp, ThrottleOutPacketType.Task);
147 }
148 }
149 }
150 }
151 }
152
153 if (UpdateUsers.Count > 0)
154 {
155 OnlineNotificationPacket onp = new OnlineNotificationPacket();
156 OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[UpdateUsers.Count];
157 for (int i = 0; i < UpdateUsers.Count; i++)
158 {
159 OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
160 onpbl.AgentID = UpdateUsers[i];
161 onpb[i] = onpbl;
162 }
163 onp.AgentBlock = onpb;
164 client.OutPacket(onp, ThrottleOutPacketType.Task);
165 }
166
167
168
169
86 } 170 }
87 171
88 private void ClientLoggedOut(LLUUID AgentId) 172 private void ClientLoggedOut(LLUUID AgentId)
@@ -95,6 +179,60 @@ namespace OpenSim.Region.Environment.Modules
95 m_log.Info("[FRIEND]: Removing " + AgentId + ". Agent logged out."); 179 m_log.Info("[FRIEND]: Removing " + AgentId + ". Agent logged out.");
96 } 180 }
97 } 181 }
182 List<FriendListItem> lfli = new List<FriendListItem>();
183 lock (FriendLists)
184 {
185 if (FriendLists.ContainsKey(AgentId))
186 {
187 lfli = FriendLists[AgentId];
188 }
189 }
190 List<LLUUID> updateUsers = new List<LLUUID>();
191 foreach (FriendListItem fli in lfli)
192 {
193 if (fli.onlinestatus = true)
194 {
195 updateUsers.Add(fli.Friend);
196 }
197 }
198 for (int i = 0; i < updateUsers.Count; i++)
199 {
200 List<FriendListItem> flfli = new List<FriendListItem>();
201 lock (FriendLists)
202 {
203 if (FriendLists.ContainsKey(updateUsers[i]))
204 flfli = FriendLists[updateUsers[i]];
205 }
206 for (int j = 0; j < flfli.Count; j++)
207 {
208 if (flfli[i].Friend == AgentId)
209 {
210 flfli[i].onlinestatus = false;
211 }
212
213 }
214
215 }
216 for (int i = 0; i < updateUsers.Count; i++)
217 {
218 ScenePresence av = GetPresenceFromAgentID(updateUsers[i]);
219 if (av != null)
220 {
221
222 OfflineNotificationPacket onp = new OfflineNotificationPacket();
223 OfflineNotificationPacket.AgentBlockBlock[] onpb = new OfflineNotificationPacket.AgentBlockBlock[1];
224 OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
225 onpbl.AgentID = AgentId;
226 onpb[0] = onpbl;
227 onp.AgentBlock = onpb;
228 av.ControllingClient.OutPacket(onp, ThrottleOutPacketType.Task);
229 }
230 }
231 lock (FriendLists)
232 {
233 FriendLists.Remove(AgentId);
234 }
235
98 } 236 }
99 237
100 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID) 238 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
diff --git a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
index 6f7235e..6e13b73 100644
--- a/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
+++ b/OpenSim/Region/Environment/Modules/InstantMessageModule.cs
@@ -82,6 +82,7 @@ namespace OpenSim.Region.Environment.Modules
82 // Don't send a Friend Dialog IM with a LLUUID.Zero session. 82 // Don't send a Friend Dialog IM with a LLUUID.Zero session.
83 if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero)) 83 if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero))
84 { 84 {
85 // Try root avatar only first
85 foreach (Scene scene in m_scenes) 86 foreach (Scene scene in m_scenes)
86 { 87 {
87 if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) 88 if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
@@ -98,8 +99,27 @@ namespace OpenSim.Region.Environment.Modules
98 } 99 }
99 } 100 }
100 } 101 }
102
103 // try child avatar second
104 foreach (Scene scene in m_scenes)
105 {
106 if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
107 {
108 // Local message
109 ScenePresence user = (ScenePresence)scene.Entities[toAgentID];
110
111 user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
112 toAgentID, imSessionID, fromAgentName, dialog,
113 timestamp);
114 // Message sent
115 return;
116
117 }
118 }
119
101 } 120 }
102 121
122
103 // Still here, try send via Grid 123 // Still here, try send via Grid
104 // TODO 124 // TODO
105 } 125 }
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 6816ad6..20cdb46 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -2145,8 +2145,15 @@ namespace OpenSim.Region.Environment.Scenes
2145 m_statsReporter.SetObjectCapacity(objects); 2145 m_statsReporter.SetObjectCapacity(objects);
2146 } 2146 }
2147 objectCapacity = objects; 2147 objectCapacity = objects;
2148
2148 } 2149 }
2149 2150
2151 public List<FriendListItem> GetFriendList(LLUUID avatarID)
2152 {
2153 return CommsManager.GetUserFriendList(avatarID);
2154 }
2155
2156
2150 #endregion 2157 #endregion
2151 2158
2152 #region Other Methods 2159 #region Other Methods