29 using System.Collections.Generic;
30 using System.Threading;
32 using OpenMetaverse.Packets;
33 using OpenSim.Framework;
34 using OpenSim.Services.Interfaces;
36 namespace OpenSim.
Region.Framework.Scenes
38 public partial class Scene
53 UUID fromID, UUID targetID,
bool fromAgent,
bool broadcast)
57 args.Message = Utils.BytesToString(message);
58 args.Channel = channel;
60 args.Position = fromPos;
61 args.SenderUUID = fromID;
63 args.Destination = targetID;
69 args.Sender = user.ControllingClient;
74 args.SenderObject = obj;
85 EventManager.TriggerOnChatBroadcast(
this, args);
87 EventManager.TriggerOnChatFromWorld(
this, args);
90 protected void SimChat(byte[] message,
ChatTypeEnum type,
int channel, Vector3 fromPos,
string fromName,
91 UUID fromID,
bool fromAgent,
bool broadcast)
93 SimChat(message, type, channel, fromPos, fromName, fromID, UUID.Zero, fromAgent, broadcast);
105 UUID fromID,
bool fromAgent)
107 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent,
false);
110 public void SimChat(
string message,
ChatTypeEnum type, Vector3 fromPos,
string fromName, UUID fromID,
bool fromAgent)
112 SimChat(
Utils.StringToBytes(message), type, 0, fromPos, fromName, fromID, fromAgent);
115 public void SimChat(
string message,
string fromName)
117 SimChat(message,
ChatTypeEnum.Broadcast, Vector3.Zero, fromName, UUID.Zero,
false);
129 UUID fromID,
bool fromAgent)
131 SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent,
true);
144 public void SimChatToAgent(UUID targetID, byte[] message,
int channel, Vector3 fromPos,
string fromName, UUID fromID,
bool fromAgent)
146 SimChat(message,
ChatTypeEnum.Region, channel, fromPos, fromName, fromID, targetID, fromAgent,
false);
159 sog.SendFullUpdateToClient(remoteClient);
202 part.SendPropertiesToClient(remoteClient);
207 part.SendFullUpdate(remoteClient);
210 if (Permissions.CanEditObject(sog.
UUID, remoteClient.
AgentId)
211 || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId))
213 part.IsSelected =
true;
214 EventManager.TriggerParcelPrimCountTainted();
225 private void HandleObjectGroupUpdate(
226 IClientAPI remoteClient, UUID groupID, uint objectLocalID, UUID Garbage)
228 if (m_groupsModule == null)
233 if (groupID != UUID.Zero)
247 SceneObjectGroup so = ((Scene)remoteClient.
Scene).GetGroupByPrim(objectLocalID);
250 if (so.OwnerID == remoteClient.
AgentId)
252 so.SetGroup(groupID, remoteClient);
299 bool oldgprSelect = part.ParentGroup.IsSelected;
306 || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId))
308 part.IsSelected =
false;
310 EventManager.TriggerParcelPrimCountTainted();
314 part.ScheduleTerseUpdate();
319 int transactiontype,
string description)
322 transactiontype, description);
324 EventManager.TriggerMoneyTransfer(
this, args);
327 public virtual void ProcessParcelBuy(UUID agentId, UUID groupId,
bool final,
bool groupOwned,
328 bool removeContribution,
int parcelLocalID,
int parcelArea,
int parcelPrice,
bool authenticated)
331 removeContribution, parcelLocalID, parcelArea,
332 parcelPrice, authenticated);
335 m_eventManager.TriggerValidateLandBuy(
this, args);
338 m_eventManager.TriggerLandBuy(
this, args);
351 if (surfaceArgs != null && surfaceArgs.Count > 0)
352 surfaceArg = surfaceArgs[0];
356 obj.ObjectGrabHandler(localID, offsetPos, remoteClient);
369 EventManager.TriggerObjectGrab(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
374 UUID objectID, Vector3 offset, Vector3 pos,
IClientAPI remoteClient, List<SurfaceTouchEventArgs> surfaceArgs)
383 if (surfaceArgs != null && surfaceArgs.Count > 0)
384 surfaceArg = surfaceArgs[0];
389 EventManager.TriggerObjectGrabbing(part.LocalId, 0, part.OffsetPosition, remoteClient, surfaceArg);
394 (part.PassTouches && (part.LocalId != obj.RootPart.LocalId)))
396 EventManager.TriggerObjectGrabbing(obj.RootPart.LocalId, part.LocalId, part.OffsetPosition, remoteClient, surfaceArg);
409 if (surfaceArgs != null && surfaceArgs.Count > 0)
410 surfaceArg = surfaceArgs[0];
415 EventManager.TriggerObjectDeGrab(part.LocalId, 0, remoteClient, surfaceArg);
417 EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
427 if (Permissions.CanResetScript(objectID, itemID, remoteClient.
AgentId))
429 EventManager.TriggerScriptReset(part.LocalId, itemID);
433 void ProcessViewerEffect(
IClientAPI remoteClient, List<ViewerEffectEventHandlerArg> args)
436 bool discardableEffects =
true;
437 ViewerEffectPacket.EffectBlock[] effectBlockArray =
new ViewerEffectPacket.EffectBlock[args.Count];
438 for (
int i = 0; i < args.Count; i++)
440 ViewerEffectPacket.EffectBlock effect =
new ViewerEffectPacket.EffectBlock();
441 effect.AgentID = args[i].AgentID;
442 effect.Color = args[i].Color;
443 effect.Duration = args[i].Duration;
444 effect.ID = args[i].ID;
445 effect.Type = args[i].Type;
446 effect.TypeData = args[i].TypeData;
447 effectBlockArray[i] = effect;
449 if ((EffectType)effect.Type != EffectType.LookAt && (EffectType)effect.Type != EffectType.Beam)
450 discardableEffects =
false;
455 ForEachScenePresence(sp =>
457 if (sp.ControllingClient.AgentId != remoteClient.
AgentId)
459 if (!discardableEffects ||
460 (discardableEffects && ShouldSendDiscardableEffect(remoteClient, sp)))
463 sp.ControllingClient.SendViewerEffect(effectBlockArray);
471 private bool ShouldSendDiscardableEffect(
IClientAPI thisClient, ScenePresence other)
473 return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10;
476 private class DescendentsRequestData
479 public UUID FolderID;
481 public bool FetchFolders;
482 public bool FetchItems;
483 public int SortOrder;
486 private Queue<DescendentsRequestData> m_descendentsRequestQueue =
new Queue<DescendentsRequestData>();
488 private bool m_descendentsRequestProcessing =
false;
500 bool fetchFolders,
bool fetchItems,
int sortOrder)
506 if (folderID == UUID.Zero)
515 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
517 if ((fold = LibraryService.LibraryRootFolder.
FindFolder(folderID)) != null)
519 remoteClient.SendInventoryFolderDetails(
520 fold.Owner, folderID, fold.RequestListOfItems(),
526 lock (m_descendentsRequestLock)
528 if (!m_descendentsRequestProcessing)
530 m_descendentsRequestProcessing =
true;
535 SendInventoryDelegate d = SendInventoryAsync;
536 d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d);
541 DescendentsRequestData req =
new DescendentsRequestData();
542 req.RemoteClient = remoteClient;
543 req.FolderID = folderID;
544 req.OwnerID = ownerID;
545 req.FetchFolders = fetchFolders;
546 req.FetchItems = fetchItems;
547 req.SortOrder = sortOrder;
549 m_descendentsRequestQueue.Enqueue(req);
553 delegate
void SendInventoryDelegate(
IClientAPI remoteClient, UUID folderID, UUID ownerID,
bool fetchFolders,
bool fetchItems,
int sortOrder);
555 void SendInventoryAsync(
IClientAPI remoteClient, UUID folderID, UUID ownerID,
bool fetchFolders,
bool fetchItems,
int sortOrder)
559 SendInventoryUpdate(remoteClient,
new InventoryFolderBase(folderID), fetchFolders, fetchItems);
565 "[AGENT INVENTORY]: Error in SendInventoryAsync() for {0} with folder ID {1}. Exception ", e));
570 void SendInventoryComplete(IAsyncResult iar)
572 SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState;
575 lock (m_descendentsRequestLock)
577 if (m_descendentsRequestQueue.Count > 0)
579 DescendentsRequestData req = m_descendentsRequestQueue.Dequeue();
581 d = SendInventoryAsync;
582 d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d);
587 m_descendentsRequestProcessing =
false;
600 string folderName, UUID parentID)
603 if (!InventoryService.AddFolder(folder))
606 "[AGENT INVENTORY]: Failed to create folder for user {0} {1}",
607 remoteClient.Name, remoteClient.AgentId);
631 folder = InventoryService.GetFolder(folder);
635 folder.Type = (short)type;
636 folder.ParentID = parentID;
637 if (!InventoryService.UpdateFolder(folder))
640 "[AGENT INVENTORY]: Failed to update folder for user {0} {1}",
641 remoteClient.Name, remoteClient.AgentId);
649 folder = InventoryService.GetFolder(folder);
652 folder.ParentID = parentID;
653 if (!InventoryService.MoveFolder(folder))
654 m_log.WarnFormat(
"[AGENT INVENTORY]: could not move folder {0}", folderID);
656 m_log.DebugFormat(
"[AGENT INVENTORY]: folder {0} moved to parent {1}", folderID, parentID);
660 m_log.WarnFormat(
"[AGENT INVENTORY]: request to move folder {0} but folder not found", folderID);
664 delegate
void PurgeFolderDelegate(UUID userID, UUID folder);
673 PurgeFolderDelegate d = PurgeFolderAsync;
676 d.BeginInvoke(remoteClient.AgentId, folderID, PurgeFolderCompleted, d);
680 m_log.WarnFormat(
"[AGENT INVENTORY]: Exception on purge folder for user {0}: {1}", remoteClient.AgentId, e.Message);
684 private void PurgeFolderAsync(UUID userID, UUID folderID)
688 if (InventoryService.PurgeFolder(folder))
689 m_log.DebugFormat(
"[AGENT INVENTORY]: folder {0} purged successfully", folderID);
691 m_log.WarnFormat(
"[AGENT INVENTORY]: could not purge folder {0}", folderID);
694 private void PurgeFolderCompleted(IAsyncResult iar)
696 PurgeFolderDelegate d = (PurgeFolderDelegate)iar.AsyncState;
virtual void ProcessParcelBuy(UUID agentId, UUID groupId, bool final, bool groupOwned, bool removeContribution, int parcelLocalID, int parcelArea, int parcelPrice, bool authenticated)
void HandleCreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType, string folderName, UUID parentID)
Handle an inventory folder creation request from the client.
void SimChatBroadcast(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
void SimChat(string message, ChatTypeEnum type, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
OpenSim.Server.Handlers.Simulation.Utils Utils
void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
void HandlePurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
This should delete all the items and folders in the given directory.
List< InventoryFolderBase > RequestListOfFolders()
Return a copy of the list of child folders in this folder. The folders themselves are the originals...
InventoryFolderImpl FindFolder(UUID folderID)
Returns the folder requested if it is this folder or is a descendent of this folder. The search is depth first.
virtual void ProcessObjectGrab(uint localID, Vector3 offsetPos, IClientAPI remoteClient, List< SurfaceTouchEventArgs > surfaceArgs)
void SimChatToAgent(UUID targetID, byte[] message, int channel, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent)
virtual void ProcessObjectDeGrab(uint localID, IClientAPI remoteClient, List< SurfaceTouchEventArgs > surfaceArgs)
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, UUID fromID, UUID targetID, bool fromAgent, bool broadcast)
Send chat to listeners.
void HandleMoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID)
void ProcessScriptReset(IClientAPI remoteClient, UUID objectID, UUID itemID)
void SimChat(string message, string fromName)
virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, int transactiontype, string description)
scriptEvents ScriptEvents
void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent, bool broadcast)
Vector3 AngularVelocity
Get or set angular velocity. Does not schedule update.
void SelectPrim(uint primLocalID, IClientAPI remoteClient)
Invoked when the client selects a prim.
void RequestPrim(uint primLocalID, IClientAPI remoteClient)
Invoked when the client requests a prim.
A class for triggering remote scene events.
SceneObjectGroup ParentGroup
void HandleUpdateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort type, string name, UUID parentID)
Handle a client request to update the inventory folder
void DeselectPrim(uint primLocalID, IClientAPI remoteClient)
Handle the deselection of a prim from the client.
virtual void ProcessObjectGrabUpdate(UUID objectID, Vector3 offset, Vector3 pos, IClientAPI remoteClient, List< SurfaceTouchEventArgs > surfaceArgs)
bool IsAttachment
Is this scene object acting as an attachment?
void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
Tell the client about the various child items and folders contained in the requested folder...