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 998c19e..421cb08 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 |
@@ -250,7 +258,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
250 | // handled by group, but by prim. Legacy cruft. | 258 | // handled by group, but by prim. Legacy cruft. |
251 | // TODO: Make selection flagging per prim! | 259 | // TODO: Make selection flagging per prim! |
252 | // | 260 | // |
253 | part.ParentGroup.IsSelected = false; | 261 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) |
262 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
263 | part.ParentGroup.IsSelected = false; | ||
254 | 264 | ||
255 | if (part.ParentGroup.IsAttachment) | 265 | if (part.ParentGroup.IsAttachment) |
256 | isAttachment = true; | 266 | isAttachment = true; |
@@ -270,6 +280,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
270 | part.UUID, remoteClient.AgentId)) | 280 | part.UUID, remoteClient.AgentId)) |
271 | EventManager.TriggerParcelPrimCountTainted(); | 281 | EventManager.TriggerParcelPrimCountTainted(); |
272 | } | 282 | } |
283 | */ | ||
284 | |||
285 | bool oldgprSelect = part.ParentGroup.IsSelected; | ||
286 | |||
287 | // This is wrong, wrong, wrong. Selection should not be | ||
288 | // handled by group, but by prim. Legacy cruft. | ||
289 | // TODO: Make selection flagging per prim! | ||
290 | // | ||
291 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) | ||
292 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
293 | { | ||
294 | part.IsSelected = false; | ||
295 | if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) | ||
296 | EventManager.TriggerParcelPrimCountTainted(); | ||
297 | } | ||
298 | |||
273 | } | 299 | } |
274 | 300 | ||
275 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, | 301 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, |
@@ -424,12 +450,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
424 | } | 450 | } |
425 | }); | 451 | }); |
426 | } | 452 | } |
427 | 453 | ||
428 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) | 454 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) |
429 | { | 455 | { |
430 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; | 456 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; |
431 | } | 457 | } |
432 | 458 | ||
459 | private class DescendentsRequestData | ||
460 | { | ||
461 | public IClientAPI RemoteClient; | ||
462 | public UUID FolderID; | ||
463 | public UUID OwnerID; | ||
464 | public bool FetchFolders; | ||
465 | public bool FetchItems; | ||
466 | public int SortOrder; | ||
467 | } | ||
468 | |||
469 | private Queue<DescendentsRequestData> m_descendentsRequestQueue = new Queue<DescendentsRequestData>(); | ||
470 | private Object m_descendentsRequestLock = new Object(); | ||
471 | private bool m_descendentsRequestProcessing = false; | ||
472 | |||
433 | /// <summary> | 473 | /// <summary> |
434 | /// Tell the client about the various child items and folders contained in the requested folder. | 474 | /// Tell the client about the various child items and folders contained in the requested folder. |
435 | /// </summary> | 475 | /// </summary> |
@@ -466,17 +506,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
466 | } | 506 | } |
467 | } | 507 | } |
468 | 508 | ||
469 | // We're going to send the reply async, because there may be | 509 | lock (m_descendentsRequestLock) |
470 | // an enormous quantity of packets -- basically the entire inventory! | 510 | { |
471 | // We don't want to block the client thread while all that is happening. | 511 | if (!m_descendentsRequestProcessing) |
472 | SendInventoryDelegate d = SendInventoryAsync; | 512 | { |
473 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | 513 | m_descendentsRequestProcessing = true; |
514 | |||
515 | // We're going to send the reply async, because there may be | ||
516 | // an enormous quantity of packets -- basically the entire inventory! | ||
517 | // We don't want to block the client thread while all that is happening. | ||
518 | SendInventoryDelegate d = SendInventoryAsync; | ||
519 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | ||
520 | |||
521 | return; | ||
522 | } | ||
523 | |||
524 | DescendentsRequestData req = new DescendentsRequestData(); | ||
525 | req.RemoteClient = remoteClient; | ||
526 | req.FolderID = folderID; | ||
527 | req.OwnerID = ownerID; | ||
528 | req.FetchFolders = fetchFolders; | ||
529 | req.FetchItems = fetchItems; | ||
530 | req.SortOrder = sortOrder; | ||
531 | |||
532 | m_descendentsRequestQueue.Enqueue(req); | ||
533 | } | ||
474 | } | 534 | } |
475 | 535 | ||
476 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); | 536 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); |
477 | 537 | ||
478 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) | 538 | void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder) |
479 | { | 539 | { |
540 | Thread.Sleep(20); | ||
480 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); | 541 | SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems); |
481 | } | 542 | } |
482 | 543 | ||
@@ -484,6 +545,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
484 | { | 545 | { |
485 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; | 546 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; |
486 | d.EndInvoke(iar); | 547 | d.EndInvoke(iar); |
548 | |||
549 | lock (m_descendentsRequestLock) | ||
550 | { | ||
551 | if (m_descendentsRequestQueue.Count > 0) | ||
552 | { | ||
553 | DescendentsRequestData req = m_descendentsRequestQueue.Dequeue(); | ||
554 | |||
555 | d = SendInventoryAsync; | ||
556 | d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d); | ||
557 | |||
558 | return; | ||
559 | } | ||
560 | |||
561 | m_descendentsRequestProcessing = false; | ||
562 | } | ||
487 | } | 563 | } |
488 | 564 | ||
489 | /// <summary> | 565 | /// <summary> |