diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 152 |
1 files changed, 114 insertions, 38 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index cddf818..46b2d2e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
50 | /// <param name='targetID'></param> | 50 | /// <param name='targetID'></param> |
51 | /// <param name='fromAgent'></param> | 51 | /// <param name='fromAgent'></param> |
52 | /// <param name='broadcast'></param> | 52 | /// <param name='broadcast'></param> |
53 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 53 | public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
54 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) | 54 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) |
55 | { | 55 | { |
56 | OSChatMessage args = new OSChatMessage(); | 56 | OSChatMessage args = new OSChatMessage(); |
@@ -61,6 +61,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
61 | args.Position = fromPos; | 61 | args.Position = fromPos; |
62 | args.SenderUUID = fromID; | 62 | args.SenderUUID = fromID; |
63 | args.Scene = this; | 63 | args.Scene = this; |
64 | args.Destination = targetID; | ||
64 | 65 | ||
65 | if (fromAgent) | 66 | if (fromAgent) |
66 | { | 67 | { |
@@ -75,7 +76,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
75 | } | 76 | } |
76 | 77 | ||
77 | args.From = fromName; | 78 | args.From = fromName; |
78 | args.TargetUUID = targetID; | 79 | //args. |
79 | 80 | ||
80 | // m_log.DebugFormat( | 81 | // m_log.DebugFormat( |
81 | // "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}", | 82 | // "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}", |
@@ -86,7 +87,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
86 | else | 87 | else |
87 | EventManager.TriggerOnChatFromWorld(this, args); | 88 | EventManager.TriggerOnChatFromWorld(this, args); |
88 | } | 89 | } |
89 | 90 | ||
90 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 91 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
91 | UUID fromID, bool fromAgent, bool broadcast) | 92 | UUID fromID, bool fromAgent, bool broadcast) |
92 | { | 93 | { |
@@ -130,19 +131,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
130 | { | 131 | { |
131 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); | 132 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); |
132 | } | 133 | } |
133 | /// <summary> | ||
134 | /// | ||
135 | /// </summary> | ||
136 | /// <param name="message"></param> | ||
137 | /// <param name="type"></param> | ||
138 | /// <param name="fromPos"></param> | ||
139 | /// <param name="fromName"></param> | ||
140 | /// <param name="fromAgentID"></param> | ||
141 | /// <param name="targetID"></param> | ||
142 | public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent) | ||
143 | { | ||
144 | SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false); | ||
145 | } | ||
146 | 134 | ||
147 | /// <summary> | 135 | /// <summary> |
148 | /// Invoked when the client requests a prim. | 136 | /// Invoked when the client requests a prim. |
@@ -164,27 +152,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
164 | /// <param name="remoteClient"></param> | 152 | /// <param name="remoteClient"></param> |
165 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) | 153 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) |
166 | { | 154 | { |
155 | /* | ||
156 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | ||
157 | |||
158 | if (null == part) | ||
159 | return; | ||
160 | |||
161 | if (part.IsRoot) | ||
162 | { | ||
163 | SceneObjectGroup sog = part.ParentGroup; | ||
164 | sog.SendPropertiesToClient(remoteClient); | ||
165 | |||
166 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | ||
167 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | ||
168 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | ||
169 | { | ||
170 | sog.IsSelected = true; | ||
171 | EventManager.TriggerParcelPrimCountTainted(); | ||
172 | } | ||
173 | } | ||
174 | else | ||
175 | { | ||
176 | part.SendPropertiesToClient(remoteClient); | ||
177 | } | ||
178 | */ | ||
167 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 179 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
168 | 180 | ||
169 | if (null == part) | 181 | if (null == part) |
170 | return; | 182 | return; |
171 | 183 | ||
172 | if (part.IsRoot) | 184 | SceneObjectGroup sog = part.ParentGroup; |
173 | { | 185 | if (sog == null) |
174 | SceneObjectGroup sog = part.ParentGroup; | 186 | return; |
175 | sog.SendPropertiesToClient(remoteClient); | ||
176 | sog.IsSelected = true; | ||
177 | 187 | ||
178 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | 188 | part.SendPropertiesToClient(remoteClient); |
179 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | 189 | |
180 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | 190 | // A prim is only tainted if it's allowed to be edited by the person clicking it. |
181 | { | 191 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) |
182 | EventManager.TriggerParcelPrimCountTainted(); | 192 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) |
183 | } | ||
184 | } | ||
185 | else | ||
186 | { | 193 | { |
187 | part.SendPropertiesToClient(remoteClient); | 194 | part.IsSelected = true; |
195 | EventManager.TriggerParcelPrimCountTainted(); | ||
188 | } | 196 | } |
189 | } | 197 | } |
190 | 198 | ||
@@ -237,7 +245,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
237 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 245 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
238 | if (part == null) | 246 | if (part == null) |
239 | return; | 247 | return; |
240 | 248 | /* | |
241 | // A deselect packet contains all the local prims being deselected. However, since selection is still | 249 | // A deselect packet contains all the local prims being deselected. However, since selection is still |
242 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims | 250 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims |
243 | // we end up sending many duplicate ObjectUpdates | 251 | // we end up sending many duplicate ObjectUpdates |
@@ -248,7 +256,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
248 | // handled by group, but by prim. Legacy cruft. | 256 | // handled by group, but by prim. Legacy cruft. |
249 | // TODO: Make selection flagging per prim! | 257 | // TODO: Make selection flagging per prim! |
250 | // | 258 | // |
251 | part.ParentGroup.IsSelected = false; | 259 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) |
260 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
261 | part.ParentGroup.IsSelected = false; | ||
252 | 262 | ||
253 | part.ParentGroup.ScheduleGroupForFullUpdate(); | 263 | part.ParentGroup.ScheduleGroupForFullUpdate(); |
254 | 264 | ||
@@ -265,6 +275,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | part.UUID, remoteClient.AgentId)) | 275 | part.UUID, remoteClient.AgentId)) |
266 | EventManager.TriggerParcelPrimCountTainted(); | 276 | EventManager.TriggerParcelPrimCountTainted(); |
267 | } | 277 | } |
278 | */ | ||
279 | |||
280 | bool oldgprSelect = part.ParentGroup.IsSelected; | ||
281 | |||
282 | // This is wrong, wrong, wrong. Selection should not be | ||
283 | // handled by group, but by prim. Legacy cruft. | ||
284 | // TODO: Make selection flagging per prim! | ||
285 | // | ||
286 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) | ||
287 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
288 | { | ||
289 | part.IsSelected = false; | ||
290 | if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) | ||
291 | EventManager.TriggerParcelPrimCountTainted(); | ||
292 | } | ||
293 | |||
268 | } | 294 | } |
269 | 295 | ||
270 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, | 296 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, |
@@ -419,12 +445,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
419 | } | 445 | } |
420 | }); | 446 | }); |
421 | } | 447 | } |
422 | 448 | ||
423 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) | 449 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) |
424 | { | 450 | { |
425 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; | 451 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; |
426 | } | 452 | } |
427 | 453 | ||
454 | private class DescendentsRequestData | ||
455 | { | ||
456 | public IClientAPI RemoteClient; | ||
457 | public UUID FolderID; | ||
458 | public UUID OwnerID; | ||
459 | public bool FetchFolders; | ||
460 | public bool FetchItems; | ||
461 | public int SortOrder; | ||
462 | } | ||
463 | |||
464 | private Queue<DescendentsRequestData> m_descendentsRequestQueue = new Queue<DescendentsRequestData>(); | ||
465 | private Object m_descendentsRequestLock = new Object(); | ||
466 | private bool m_descendentsRequestProcessing = false; | ||
467 | |||
428 | /// <summary> | 468 | /// <summary> |
429 | /// Tell the client about the various child items and folders contained in the requested folder. | 469 | /// Tell the client about the various child items and folders contained in the requested folder. |
430 | /// </summary> | 470 | /// </summary> |
@@ -461,17 +501,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
461 | } | 501 | } |
462 | } | 502 | } |
463 | 503 | ||
464 | // We're going to send the reply async, because there may be | 504 | lock (m_descendentsRequestLock) |
465 | // an enormous quantity of packets -- basically the entire inventory! | 505 | { |
466 | // We don't want to block the client thread while all that is happening. | 506 | if (!m_descendentsRequestProcessing) |
467 | SendInventoryDelegate d = SendInventoryAsync; | 507 | { |
468 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | 508 | m_descendentsRequestProcessing = true; |
509 | |||
510 | // We're going to send the reply async, because there may be | ||
511 | // an enormous quantity of packets -- basically the entire inventory! | ||
512 | // We don't want to block the client thread while all that is happening. | ||
513 | SendInventoryDelegate d = SendInventoryAsync; | ||
514 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | ||
515 | |||
516 | return; | ||
517 | } | ||
518 | |||
519 | DescendentsRequestData req = new DescendentsRequestData(); | ||
520 | req.RemoteClient = remoteClient; | ||
521 | req.FolderID = folderID; | ||
522 | req.OwnerID = ownerID; | ||
523 | req.FetchFolders = fetchFolders; | ||
524 | req.FetchItems = fetchItems; | ||
525 | req.SortOrder = sortOrder; | ||
526 | |||
527 | m_descendentsRequestQueue.Enqueue(req); | ||
528 | } | ||
469 | } | 529 | } |
470 | 530 | ||
471 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); | 531 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); |
472 | 532 | ||
473 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) | 533 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) |
474 | { | 534 | { |
535 | Thread.Sleep(20); | ||
475 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); | 536 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); |
476 | } | 537 | } |
477 | 538 | ||
@@ -479,6 +540,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
479 | { | 540 | { |
480 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; | 541 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; |
481 | d.EndInvoke(iar); | 542 | d.EndInvoke(iar); |
543 | |||
544 | lock (m_descendentsRequestLock) | ||
545 | { | ||
546 | if (m_descendentsRequestQueue.Count > 0) | ||
547 | { | ||
548 | DescendentsRequestData req = m_descendentsRequestQueue.Dequeue(); | ||
549 | |||
550 | d = SendInventoryAsync; | ||
551 | d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d); | ||
552 | |||
553 | return; | ||
554 | } | ||
555 | |||
556 | m_descendentsRequestProcessing = false; | ||
557 | } | ||
482 | } | 558 | } |
483 | 559 | ||
484 | /// <summary> | 560 | /// <summary> |