diff --git a/OpenMetaverse/ParcelManager.cs b/OpenMetaverse/ParcelManager.cs index 8183899f..9eb1ff83 100644 --- a/OpenMetaverse/ParcelManager.cs +++ b/OpenMetaverse/ParcelManager.cs @@ -672,48 +672,7 @@ namespace OpenMetaverse req.SnapshotID = this.SnapshotID; req.UserLocation = this.UserLocation; req.UserLookAt = this.UserLookAt; - - //OSDMap body = new OSDMap(); - //body["auth_buyer_id"] = OSD.FromUUID(this.AuthBuyerID); - //body["auto_scale"] = OSD.FromBoolean(this.Media.MediaAutoScale); - //body["category"] = OSD.FromInteger((byte)this.Category); - //body["description"] = OSD.FromString(this.Desc); - //body["flags"] = OSD.FromBinary(Utils.EmptyBytes); - //body["group_id"] = OSD.FromUUID(this.GroupID); - //body["landing_type"] = OSD.FromInteger((byte)this.Landing); - //body["local_id"] = OSD.FromInteger(this.LocalID); - //body["media_desc"] = OSD.FromString(this.Media.MediaDesc); - //body["media_height"] = OSD.FromInteger(this.Media.MediaHeight); - //body["media_id"] = OSD.FromUUID(this.Media.MediaID); - //body["media_loop"] = OSD.FromInteger(this.Media.MediaLoop ? 1 : 0); - //body["media_type"] = OSD.FromString(this.Media.MediaType); - //body["media_url"] = OSD.FromString(this.Media.MediaURL); - //body["media_width"] = OSD.FromInteger(this.Media.MediaWidth); - //body["music_url"] = OSD.FromString(this.MusicURL); - //body["name"] = OSD.FromString(this.Name); - //body["obscure_media"]= OSD.FromInteger(this.ObscureMedia ? 1 : 0); - //body["obscure_music"] = OSD.FromInteger(this.ObscureMusic ? 1 : 0); - - //byte[] flags = Utils.IntToBytes((int)this.Flags); ; - //if (BitConverter.IsLittleEndian) - // Array.Reverse(flags); - //body["parcel_flags"] = OSD.FromBinary(flags); - - //body["pass_hours"] = OSD.FromReal(this.PassHours); - //body["pass_price"] = OSD.FromInteger(this.PassPrice); - //body["sale_price"] = OSD.FromInteger(this.SalePrice); - //body["snapshot_id"] = OSD.FromUUID(this.SnapshotID); - //OSDArray uloc = new OSDArray(); - //uloc.Add(OSD.FromReal(this.UserLocation.X)); - //uloc.Add(OSD.FromReal(this.UserLocation.Y)); - //uloc.Add(OSD.FromReal(this.UserLocation.Z)); - //body["user_location"] = uloc; - //OSDArray ulat = new OSDArray(); - //ulat.Add(OSD.FromReal(this.UserLocation.X)); - //ulat.Add(OSD.FromReal(this.UserLocation.Y)); - //ulat.Add(OSD.FromReal(this.UserLocation.Z)); - //body["user_look_at"] = ulat; - + OSDMap body = req.Serialize(); CapsClient capsPost = new CapsClient(url); @@ -813,117 +772,214 @@ namespace OpenMetaverse #region Delegates - /// - /// - /// - /// UUID of the requested parcel - /// Simulator-local ID of the requested parcel - /// Dwell value of the requested parcel - public delegate void ParcelDwellCallback(UUID parcelID, int localID, float dwell); - /// - /// - /// - /// - public delegate void ParcelInfoCallback(ParcelInfo parcel); - /// - /// - /// - /// Simulator the parcel is in - /// Full properties for a single parcel. If result - /// is NoData this will be incomplete or incorrect data - /// Success of the query - /// Number of primitives your avatar is currently - /// selecting and sitting on in this parcel - /// User-assigned identifier for the query - /// User-assigned boolean for the query - public delegate void ParcelPropertiesCallback(Simulator simulator, Parcel parcel, ParcelResult result, int selectedPrims, - int sequenceID, bool snapSelection); - /// - /// - /// - /// Simulator the parcel is in - /// - /// - /// - /// - public delegate void ParcelAccessListReplyCallback(Simulator simulator, int sequenceID, int localID, uint flags, - List accessEntries); + /// The event subscribers. null if no subcribers + private EventHandler m_DwellReply; - /// - /// Responses to a request for prim owners on a parcel - /// - /// simulator parcel is in - /// List containing details or prim ownership - public delegate void ParcelObjectOwnersListReplyCallback(Simulator simulator, List primOwners); + /// Raises the ParcelDwellReply event + /// A ParcelDwellReplyEventArgs object containing the + /// data returned from the simulator + protected virtual void OnParcelDwellReply(ParcelDwellReplyEventArgs e) + { + EventHandler handler = m_DwellReply; + if (handler != null) + handler(this, e); + } - /// - /// Fired when all parcels are downloaded from simulator - /// - /// Simulator the parcel is in - /// Read-only dictionary containing parcel details for the simulator - /// 64,64 array containing sim position to localID mapping - public delegate void SimParcelsDownloaded(Simulator simulator, InternalDictionary simParcels, int[,] parcelMap); + /// Thread sync lock object + private readonly object m_DwellReplyLock = new object(); + + /// Raised when the simulator responds to a request + public event EventHandler ParcelDwellReply + { + add { lock (m_DwellReplyLock) { m_DwellReply += value; } } + remove { lock (m_DwellReplyLock) { m_DwellReply -= value; } } + } - /// - /// Fired in response to SelectParcelObjects - /// - /// simulator the objects are in - /// Local IDs of the selected objects - /// If true, list is start of a new selection - public delegate void ForceSelectObjects(Simulator simulator, List objectIDs, bool resetList); + /// The event subscribers. null if no subcribers + private EventHandler m_ParcelInfo; - /// - /// Fired when a ParcelMediaUpdate packet is received, this occurs when the media on the parcel an avatar - /// is over changes - /// - /// A reference to the simulator object - /// A struct containing updated media information - public delegate void ParcelMediaUpdateReplyCallback(Simulator simulator, ParcelMedia media); + /// Raises the ParcelInfoReply event + /// A ParcelInfoReplyEventArgs object containing the + /// data returned from the simulator + protected virtual void OnParcelInfoReply(ParcelInfoReplyEventArgs e) + { + EventHandler handler = m_ParcelInfo; + if (handler != null) + handler(this, e); + } - /// - /// Fired when a ParcelMediaCommandMessage packet is received, this occurs when the media on the parcel sends a specialized event - /// - /// A reference to the simulator object - /// The sequence the parcel command belongs to - /// Updated parcel information - /// The command executed on the Parcel - /// The time operand for some parcel commands - public delegate void ParcelMediaCommandMessageCallback(Simulator simulator, uint sequence, ParcelFlags flags, ParcelMediaCommand command, float time); + /// Thread sync lock object + private readonly object m_ParcelInfoLock = new object(); + /// Raised when the simulator responds to a request + public event EventHandler ParcelInfoReply + { + add { lock (m_ParcelInfoLock) { m_ParcelInfo += value; } } + remove { lock (m_ParcelInfoLock) { m_ParcelInfo -= value; } } + } + + /// The event subscribers. null if no subcribers + private EventHandler m_ParcelProperties; + + /// Raises the ParcelProperties event + /// A ParcelPropertiesEventArgs object containing the + /// data returned from the simulator + protected virtual void OnParcelProperties(ParcelPropertiesEventArgs e) + { + EventHandler handler = m_ParcelProperties; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ParcelPropertiesLock = new object(); + + /// Raised when the simulator responds to a request + public event EventHandler ParcelProperties + { + add { lock (m_ParcelPropertiesLock) { m_ParcelProperties += value; } } + remove { lock (m_ParcelPropertiesLock) { m_ParcelProperties -= value; } } + } + + /// The event subscribers. null if no subcribers + private EventHandler m_ParcelACL; + + /// Raises the ParcelAccessListReply event + /// A ParcelAccessListReplyEventArgs object containing the + /// data returned from the simulator + protected virtual void OnParcelAccessListReply(ParcelAccessListReplyEventArgs e) + { + EventHandler handler = m_ParcelACL; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ParcelACLLock = new object(); + + /// Raised when the simulator responds to a request + public event EventHandler ParcelAccessListReply + { + add { lock (m_ParcelACLLock) { m_ParcelACL += value; } } + remove { lock (m_ParcelACLLock) { m_ParcelACL -= value; } } + } + + /// The event subscribers. null if no subcribers + private EventHandler m_ParcelObjectOwnersReply; + + /// Raises the ParcelObjectOwnersReply event + /// A ParcelObjectOwnersReplyEventArgs object containing the + /// data returned from the simulator + protected virtual void OnParcelObjectOwnersReply(ParcelObjectOwnersReplyEventArgs e) + { + EventHandler handler = m_ParcelObjectOwnersReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ParcelObjectOwnersLock = new object(); + + /// Raised when the simulator responds to a request + public event EventHandler ParcelObjectOwnersReply + { + add { lock (m_ParcelObjectOwnersLock) { m_ParcelObjectOwnersReply += value; } } + remove { lock (m_ParcelObjectOwnersLock) { m_ParcelObjectOwnersReply -= value; } } + } + + /// The event subscribers. null if no subcribers + private EventHandler m_SimParcelsDownloaded; + + /// Raises the SimParcelsDownloaded event + /// A SimParcelsDownloadedEventArgs object containing the + /// data returned from the simulator + protected virtual void OnSimParcelsDownloaded(SimParcelsDownloadedEventArgs e) + { + EventHandler handler = m_SimParcelsDownloaded; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_SimParcelsDownloadedLock = new object(); + + /// Raised when the simulator responds to a request + public event EventHandler SimParcelsDownloaded + { + add { lock (m_SimParcelsDownloadedLock) { m_SimParcelsDownloaded += value; } } + remove { lock (m_SimParcelsDownloadedLock) { m_SimParcelsDownloaded -= value; } } + } + + /// The event subscribers. null if no subcribers + private EventHandler m_ForceSelectObjects; + + /// Raises the ForceSelectObjectsReply event + /// A ForceSelectObjectsReplyEventArgs object containing the + /// data returned from the simulator + protected virtual void OnForceSelectObjectsReply(ForceSelectObjectsReplyEventArgs e) + { + EventHandler handler = m_ForceSelectObjects; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ForceSelectObjectsLock = new object(); + + /// Raised when the simulator responds to a request + public event EventHandler ForceSelectObjectsReply + { + add { lock (m_ForceSelectObjectsLock) { m_ForceSelectObjects += value; } } + remove { lock (m_ForceSelectObjectsLock) { m_ForceSelectObjects -= value; } } + } + + /// The event subscribers. null if no subcribers + private EventHandler m_ParcelMediaUpdateReply; + + /// Raises the ParcelMediaUpdateReply event + /// A ParcelMediaUpdateReplyEventArgs object containing the + /// data returned from the simulator + protected virtual void OnParcelMediaUpdateReply(ParcelMediaUpdateReplyEventArgs e) + { + EventHandler handler = m_ParcelMediaUpdateReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ParcelMediaUpdateReplyLock = new object(); + + /// Raised when the simulator responds to a Parcel Update request + public event EventHandler ParcelMediaUpdateReply + { + add { lock (m_ParcelMediaUpdateReplyLock) { m_ParcelMediaUpdateReply += value; } } + remove { lock (m_ParcelMediaUpdateReplyLock) { m_ParcelMediaUpdateReply -= value; } } + } + + /// The event subscribers. null if no subcribers + private EventHandler m_ParcelMediaCommand; + + /// Raises the ParcelMediaCommand event + /// A ParcelMediaCommandEventArgs object containing the + /// data returned from the simulator + protected virtual void OnParcelMediaCommand(ParcelMediaCommandEventArgs e) + { + EventHandler handler = m_ParcelMediaCommand; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ParcelMediaCommandLock = new object(); + + /// Raised when the parcel your agent is located sends a ParcelMediaCommand + public event EventHandler ParcelMediaCommand + { + add { lock (m_ParcelMediaCommandLock) { m_ParcelMediaCommand += value; } } + remove { lock (m_ParcelMediaCommandLock) { m_ParcelMediaCommand -= value; } } + } #endregion Delegates - #region Events - - /// Fired when a is received, - /// in response to a - public event ParcelDwellCallback OnParcelDwell; - /// Fired when a is received, - /// in response to a - public event ParcelInfoCallback OnParcelInfo; - /// Fired when a ParcelProperties Packet is received over the subsystem, - /// in response to a - public event ParcelPropertiesCallback OnParcelProperties; - /// Fired when a is received, - /// in response to a - public event ParcelAccessListReplyCallback OnAccessListReply; - /// Fired when the Agent receives a , - /// in response to - public event ParcelObjectOwnersListReplyCallback OnPrimOwnersListReply; - /// Fired when the simulator parcel dictionary is populated in response - /// to a request - public event SimParcelsDownloaded OnSimParcelsDownloaded; - /// Fired when the Agent receives a , - /// in response to a request - public event ForceSelectObjects OnParcelSelectedObjects; - /// Fired when the Agent receives a which - /// occurs when the parcel media information is changed for the current parcel the Agent is over - public event ParcelMediaUpdateReplyCallback OnParcelMediaUpdate; - /// Fired when the Agent receives a which - /// occurs when the parcel media has a specialized event like starting and looping command on the media is raised - /// for the current parcel the Agent is over - public event ParcelMediaCommandMessageCallback OnParcelMediaCommandMessage; - - #endregion Events private GridClient Client; @@ -937,6 +993,7 @@ namespace OpenMetaverse public ParcelManager(GridClient client) { Client = client; + // Setup the callbacks Client.Network.RegisterCallback(PacketType.ParcelInfoReply, new NetworkManager.PacketCallback(ParcelInfoReplyHandler)); Client.Network.RegisterEventCallback("ParcelObjectOwnersReply", new Caps.EventQueueCallback(ParcelObjectOwnersReplyHandler)); @@ -954,7 +1011,7 @@ namespace OpenMetaverse /// Request basic information for a single parcel /// /// Simulator-local ID of the parcel - public void InfoRequest(UUID parcelID) + public void RequestParcelInfo(UUID parcelID) { ParcelInfoRequestPacket request = new ParcelInfoRequestPacket(); request.AgentData.AgentID = Client.Self.AgentID; @@ -972,7 +1029,7 @@ namespace OpenMetaverse /// An arbitrary integer that will be returned /// with the ParcelProperties reply, useful for distinguishing between /// multiple simultaneous requests - public void PropertiesRequest(Simulator simulator, int localID, int sequenceID) + public void RequestParcelProperties(Simulator simulator, int localID, int sequenceID) { ParcelPropertiesRequestByIDPacket request = new ParcelPropertiesRequestByIDPacket(); @@ -994,7 +1051,7 @@ namespace OpenMetaverse /// with the ParcelAccessList reply, useful for distinguishing between /// multiple simultaneous requests /// - public void AccessListRequest(Simulator simulator, int localID, AccessList flags, int sequenceID) + public void RequestParcelAccessList(Simulator simulator, int localID, AccessList flags, int sequenceID) { ParcelAccessListRequestPacket request = new ParcelAccessListRequestPacket(); @@ -1021,7 +1078,7 @@ namespace OpenMetaverse /// A boolean that is returned with the /// ParcelProperties reply, useful for snapping focus to a single /// parcel - public void PropertiesRequest(Simulator simulator, float north, float east, float south, float west, + public void RequestParcelProperties(Simulator simulator, float north, float east, float south, float west, int sequenceID, bool snapSelection) { ParcelPropertiesRequestPacket request = new ParcelPropertiesRequestPacket(); @@ -1088,7 +1145,7 @@ namespace OpenMetaverse if (simulator.ParcelMap[y, x] == 0) { - Client.Parcels.PropertiesRequest(simulator, + Client.Parcels.RequestParcelProperties(simulator, (y + 1) * 4.0f, (x + 1) * 4.0f, y * 4.0f, x * 4.0f, int.MaxValue, false); @@ -1116,7 +1173,7 @@ namespace OpenMetaverse /// /// Simulator containing the parcel /// Simulator-local ID of the parcel - public void DwellRequest(Simulator simulator, int localID) + public void RequestDwell(Simulator simulator, int localID) { ParcelDwellRequestPacket request = new ParcelDwellRequestPacket(); request.AgentData.AgentID = Client.Self.AgentID; @@ -1197,7 +1254,7 @@ namespace OpenMetaverse /// /// Simulator parcel is in /// The parcels region specific local ID - public void ObjectOwnersRequest(Simulator simulator, int localID) + public void RequestObjectOwners(Simulator simulator, int localID) { ParcelObjectOwnersRequestPacket request = new ParcelObjectOwnersRequestPacket(); @@ -1438,22 +1495,20 @@ namespace OpenMetaverse /// List containing keys of avatars objects to select; /// if List is null will return Objects of type selectType /// Response data is returned in the event - public void SelectObjects(int localID, ObjectReturnType selectType, UUID ownerID) + public void RequestSelectObjects(int localID, ObjectReturnType selectType, UUID ownerID) { - if (OnParcelSelectedObjects != null) - { - ParcelSelectObjectsPacket select = new ParcelSelectObjectsPacket(); - select.AgentData.AgentID = Client.Self.AgentID; - select.AgentData.SessionID = Client.Self.SessionID; + ParcelSelectObjectsPacket select = new ParcelSelectObjectsPacket(); + select.AgentData.AgentID = Client.Self.AgentID; + select.AgentData.SessionID = Client.Self.SessionID; - select.ParcelData.LocalID = localID; - select.ParcelData.ReturnType = (uint)selectType; + select.ParcelData.LocalID = localID; + select.ParcelData.ReturnType = (uint)selectType; - select.ReturnIDs = new ParcelSelectObjectsPacket.ReturnIDsBlock[1]; - select.ReturnIDs[0] = new ParcelSelectObjectsPacket.ReturnIDsBlock(); - select.ReturnIDs[0].ReturnID = ownerID; - Client.Network.SendPacket(select); - } + select.ReturnIDs = new ParcelSelectObjectsPacket.ReturnIDsBlock[1]; + select.ReturnIDs[0] = new ParcelSelectObjectsPacket.ReturnIDsBlock(); + select.ReturnIDs[0].ReturnID = ownerID; + + Client.Network.SendPacket(select); } /// @@ -1544,9 +1599,13 @@ namespace OpenMetaverse #region Packet Handlers - private void ParcelDwellReplyHandler(Packet packet, Simulator simulator) - { - if (OnParcelDwell != null || Client.Settings.ALWAYS_REQUEST_PARCEL_DWELL == true) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + /// Raises the event + protected void ParcelDwellReplyHandler(Packet packet, Simulator simulator) + { + if (m_DwellReply != null || Client.Settings.ALWAYS_REQUEST_PARCEL_DWELL == true) { ParcelDwellReplyPacket dwell = (ParcelDwellReplyPacket)packet; @@ -1560,17 +1619,20 @@ namespace OpenMetaverse } } - if (OnParcelDwell != null) + if (m_DwellReply != null) { - try { OnParcelDwell(dwell.Data.ParcelID, dwell.Data.LocalID, dwell.Data.Dwell); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnParcelDwellReply(new ParcelDwellReplyEventArgs(dwell.Data.ParcelID, dwell.Data.LocalID, dwell.Data.Dwell)); } } } - private void ParcelInfoReplyHandler(Packet packet, Simulator simulator) - { - if (OnParcelInfo != null) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + /// Raises the event + protected void ParcelInfoReplyHandler(Packet packet, Simulator simulator) + { + if (m_ParcelInfo != null) { ParcelInfoReplyPacket info = (ParcelInfoReplyPacket)packet; @@ -1592,19 +1654,19 @@ namespace OpenMetaverse parcelInfo.SimName = Utils.BytesToString(info.Data.SimName); parcelInfo.SnapshotID = info.Data.SnapshotID; - try { OnParcelInfo(parcelInfo); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnParcelInfoReply(new ParcelInfoReplyEventArgs(parcelInfo)); } } - /// - /// ParcelProperties replies sent over CAPS - /// - /// Not used (will always be ParcelProperties) - /// IMessage object containing decoded data from OSD - /// Object representing simulator - private void ParcelPropertiesReplyHandler(string capsKey, IMessage message, Simulator simulator) - { - if (OnParcelProperties != null || Client.Settings.PARCEL_TRACKING == true) + + /// Process an incoming message + /// The EventQueue Key + /// The message containing the data + /// The simulator the packet originated from + /// Raises the event + /// Raises the event if all parcels in the simulator have been requested + protected void ParcelPropertiesReplyHandler(string capsKey, IMessage message, Simulator simulator) + { + if (m_ParcelProperties != null || Client.Settings.PARCEL_TRACKING == true) { ParcelPropertiesMessage msg = (ParcelPropertiesMessage)message; @@ -1700,37 +1762,34 @@ namespace OpenMetaverse // auto request acl, will be stored in parcel tracking dictionary if enabled if (Client.Settings.ALWAYS_REQUEST_PARCEL_ACL) - Client.Parcels.AccessListRequest(simulator, parcel.LocalID, + Client.Parcels.RequestParcelAccessList(simulator, parcel.LocalID, AccessList.Both, sequenceID); // auto request dwell, will be stored in parcel tracking dictionary if enables if (Client.Settings.ALWAYS_REQUEST_PARCEL_DWELL) - Client.Parcels.DwellRequest(simulator, parcel.LocalID); + Client.Parcels.RequestDwell(simulator, parcel.LocalID); // Fire the callback for parcel properties being received - if (OnParcelProperties != null) + if (m_ParcelProperties != null) { - try { OnParcelProperties(simulator, parcel, result, selectedPrims, sequenceID, snapSelection); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnParcelProperties(new ParcelPropertiesEventArgs(simulator, parcel, result, selectedPrims, sequenceID, snapSelection)); } // Check if all of the simulator parcels have been retrieved, if so fire another callback - if (simulator.IsParcelMapFull() && OnSimParcelsDownloaded != null) + if (simulator.IsParcelMapFull() && m_SimParcelsDownloaded != null) { - try { OnSimParcelsDownloaded(simulator, simulator.Parcels, simulator.ParcelMap); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnSimParcelsDownloaded(new SimParcelsDownloadedEventArgs(simulator, simulator.Parcels, simulator.ParcelMap)); } } } - /// - /// - /// - /// - /// + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + /// Raises the event protected void ParcelAccessListReplyHandler(Packet packet, Simulator simulator) { - if (OnAccessListReply != null || Client.Settings.ALWAYS_REQUEST_PARCEL_ACL == true) + if (m_ParcelACL != null || Client.Settings.ALWAYS_REQUEST_PARCEL_ACL == true) { ParcelAccessListReplyPacket reply = (ParcelAccessListReplyPacket)packet; @@ -1761,27 +1820,23 @@ namespace OpenMetaverse } - if (OnAccessListReply != null) + if (m_ParcelACL != null) { - try - { - OnAccessListReply(simulator, reply.Data.SequenceID, reply.Data.LocalID, reply.Data.Flags, - accessList); - } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnParcelAccessListReply(new ParcelAccessListReplyEventArgs(simulator, reply.Data.SequenceID, reply.Data.LocalID, + reply.Data.Flags, accessList)); } } } - /// - /// Decode the prim owner information, send the decoded object to any event subscribers - /// - /// - /// IMessage object containing decoded data from OSD - /// - private void ParcelObjectOwnersReplyHandler(string capsKey, IMessage message, Simulator simulator) + /// Process an incoming message + /// The EventQueue Key + /// The message containing the data + /// The simulator the packet originated from + /// Raises the event + /// Raises the event if all parcels in the simulator have been requested + protected void ParcelObjectOwnersReplyHandler(string capsKey, IMessage message, Simulator simulator) { - if (OnPrimOwnersListReply != null) + if (m_ParcelObjectOwnersReply != null) { List primOwners = new List(); @@ -1799,56 +1854,58 @@ namespace OpenMetaverse primOwners.Add(primOwner); } - try { OnPrimOwnersListReply(simulator, primOwners); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnParcelObjectOwnersReply(new ParcelObjectOwnersReplyEventArgs(simulator, primOwners)); } } - - /// - /// - /// - /// - /// - private void SelectParcelObjectsReplyHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + /// Raises the event + protected void SelectParcelObjectsReplyHandler(Packet packet, Simulator simulator) { - ForceObjectSelectPacket reply = (ForceObjectSelectPacket)packet; - List objectIDs = new List(reply.Data.Length); - - for (int i = 0; i < reply.Data.Length; i++) + if (m_ForceSelectObjects != null) { - objectIDs.Add(reply.Data[i].LocalID); - } + ForceObjectSelectPacket reply = (ForceObjectSelectPacket)packet; + List objectIDs = new List(reply.Data.Length); - if (OnParcelSelectedObjects != null) - { - try { OnParcelSelectedObjects(simulator, objectIDs, reply._Header.ResetList); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + for (int i = 0; i < reply.Data.Length; i++) + { + objectIDs.Add(reply.Data[i].LocalID); + } + + OnForceSelectObjectsReply(new ForceSelectObjectsReplyEventArgs(simulator, objectIDs, reply._Header.ResetList)); } } - private void ParcelMediaUpdateHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + /// Raises the event + protected void ParcelMediaUpdateHandler(Packet packet, Simulator simulator) { - ParcelMediaUpdatePacket reply = (ParcelMediaUpdatePacket)packet; - ParcelMedia media = new ParcelMedia(); - - media.MediaAutoScale = (reply.DataBlock.MediaAutoScale == (byte)0x1) ? true : false; - media.MediaID = reply.DataBlock.MediaID; - media.MediaDesc = Utils.BytesToString(reply.DataBlockExtended.MediaDesc); - media.MediaHeight = reply.DataBlockExtended.MediaHeight; - media.MediaLoop = ((reply.DataBlockExtended.MediaLoop & 1) != 0) ? true : false; - media.MediaType = Utils.BytesToString(reply.DataBlockExtended.MediaType); - media.MediaWidth = reply.DataBlockExtended.MediaWidth; - media.MediaURL = Utils.BytesToString(reply.DataBlock.MediaURL); - - if (OnParcelMediaUpdate != null) + if (m_ParcelMediaUpdateReply != null) { - try { OnParcelMediaUpdate(simulator, media); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + ParcelMediaUpdatePacket reply = (ParcelMediaUpdatePacket)packet; + ParcelMedia media = new ParcelMedia(); + + media.MediaAutoScale = (reply.DataBlock.MediaAutoScale == (byte)0x1) ? true : false; + media.MediaID = reply.DataBlock.MediaID; + media.MediaDesc = Utils.BytesToString(reply.DataBlockExtended.MediaDesc); + media.MediaHeight = reply.DataBlockExtended.MediaHeight; + media.MediaLoop = ((reply.DataBlockExtended.MediaLoop & 1) != 0) ? true : false; + media.MediaType = Utils.BytesToString(reply.DataBlockExtended.MediaType); + media.MediaWidth = reply.DataBlockExtended.MediaWidth; + media.MediaURL = Utils.BytesToString(reply.DataBlock.MediaURL); + + OnParcelMediaUpdateReply(new ParcelMediaUpdateReplyEventArgs(simulator, media)); } } - private void ParcelOverlayHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void ParcelOverlayHandler(Packet packet, Simulator simulator) { const int OVERLAY_COUNT = 4; @@ -1875,17 +1932,305 @@ namespace OpenMetaverse } } - private void ParcelMediaCommandMessagePacketHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + /// Raises the event + protected void ParcelMediaCommandMessagePacketHandler(Packet packet, Simulator simulator) { - if (OnParcelMediaCommandMessage != null) + if (m_ParcelMediaCommand != null) { ParcelMediaCommandMessagePacket pmc = (ParcelMediaCommandMessagePacket)packet; ParcelMediaCommandMessagePacket.CommandBlockBlock block = pmc.CommandBlock; - try { OnParcelMediaCommandMessage(simulator, pmc.Header.Sequence, (ParcelFlags)block.Flags, (ParcelMediaCommand)block.Command, block.Time); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + + OnParcelMediaCommand(new ParcelMediaCommandEventArgs(simulator, pmc.Header.Sequence, (ParcelFlags)block.Flags, + (ParcelMediaCommand)block.Command, block.Time)); } } #endregion Packet Handlers } + #region EventArgs classes + + /// Contains a parcels dwell data returned from the simulator in response to an + public class ParcelDwellReplyEventArgs : EventArgs + { + private readonly UUID m_ParcelID; + private readonly int m_LocalID; + private readonly float m_Dwell; + + /// Get the global ID of the parcel + public UUID ParcelID { get { return m_ParcelID; } } + /// Get the simulator specific ID of the parcel + public int LocalID { get { return m_LocalID; } } + /// Get the calculated dwell + public float Dwell { get { return m_Dwell; } } + + /// + /// Construct a new instance of the ParcelDwellReplyEventArgs class + /// + /// The global ID of the parcel + /// The simulator specific ID of the parcel + /// The calculated dwell for the parcel + public ParcelDwellReplyEventArgs(UUID parcelID, int localID, float dwell) + { + this.m_ParcelID = parcelID; + this.m_LocalID = localID; + this.m_Dwell = dwell; + } + } + + /// Contains basic parcel information data returned from the + /// simulator in response to an request + public class ParcelInfoReplyEventArgs : EventArgs + { + private readonly ParcelInfo m_Parcel; + + /// Get the object containing basic parcel info + public ParcelInfo Parcel { get { return m_Parcel; } } + + /// + /// Construct a new instance of the ParcelInfoReplyEventArgs class + /// + /// The object containing basic parcel info + public ParcelInfoReplyEventArgs(ParcelInfo parcel) + { + this.m_Parcel = parcel; + } + } + + /// Contains basic parcel information data returned from the simulator in response to an request + public class ParcelPropertiesEventArgs : EventArgs + { + private readonly Simulator m_Simulator; + private Parcel m_Parcel; + private readonly ParcelResult m_Result; + private readonly int m_SelectedPrims; + private readonly int m_SequenceID; + private readonly bool m_SnapSelection; + + /// Get the simulator the parcel is located in + public Simulator Simulator { get { return m_Simulator; } } + /// Get the object containing the details + /// If Result is NoData, this object will not contain valid data + public Parcel Parcel { get { return m_Parcel; } } + /// Get the result of the request + public ParcelResult Result { get { return m_Result; } } + /// Get the number of primitieves your agent is + /// currently selecting and or sitting on in this parcel + public int SelectedPrims { get { return m_SelectedPrims; } } + /// Get the user assigned ID used to correlate a request with + /// these results + public int SequenceID { get { return m_SequenceID; } } + /// TODO: + public bool SnapSelection { get { return m_SnapSelection; } } + + /// + /// Construct a new instance of the ParcelPropertiesEventArgs class + /// + /// The object containing the details + /// The object containing the details + /// The result of the request + /// The number of primitieves your agent is + /// currently selecting and or sitting on in this parcel + /// The user assigned ID used to correlate a request with + /// these results + /// TODO: + public ParcelPropertiesEventArgs(Simulator simulator, Parcel parcel, ParcelResult result, int selectedPrims, + int sequenceID, bool snapSelection) + { + this.m_Simulator = simulator; + this.m_Parcel = parcel; + this.m_Result = result; + this.m_SelectedPrims = selectedPrims; + this.m_SequenceID = sequenceID; + this.m_SnapSelection = snapSelection; + } + } + + /// Contains blacklist and whitelist data returned from the simulator in response to an request + public class ParcelAccessListReplyEventArgs : EventArgs + { + private readonly Simulator m_Simulator; + private readonly int m_SequenceID; + private readonly int m_LocalID; + private readonly uint m_Flags; + private readonly List m_AccessList; + + /// Get the simulator the parcel is located in + public Simulator Simulator { get { return m_Simulator; } } + /// Get the user assigned ID used to correlate a request with + /// these results + public int SequenceID { get { return m_SequenceID; } } + /// Get the simulator specific ID of the parcel + public int LocalID { get { return m_LocalID; } } + /// TODO: + public uint Flags { get { return m_Flags; } } + /// Get the list containing the white/blacklisted agents for the parcel + public List AccessList { get { return m_AccessList; } } + + /// + /// Construct a new instance of the ParcelAccessListReplyEventArgs class + /// + /// The simulator the parcel is located in + /// The user assigned ID used to correlate a request with + /// these results + /// The simulator specific ID of the parcel + /// TODO: + /// The list containing the white/blacklisted agents for the parcel + public ParcelAccessListReplyEventArgs(Simulator simulator, int sequenceID, int localID, uint flags, List accessEntries) + { + this.m_Simulator = simulator; + this.m_SequenceID = sequenceID; + this.m_LocalID = localID; + this.m_Flags = flags; + this.m_AccessList = accessEntries; + } + } + + /// Contains blacklist and whitelist data returned from the + /// simulator in response to an request + public class ParcelObjectOwnersReplyEventArgs : EventArgs + { + private readonly Simulator m_Simulator; + private readonly List m_Owners; + + /// Get the simulator the parcel is located in + public Simulator Simulator { get { return m_Simulator; } } + /// Get the list containing prim ownership counts + public List PrimOwners { get { return m_Owners; } } + + /// + /// Construct a new instance of the ParcelObjectOwnersReplyEventArgs class + /// + /// The simulator the parcel is located in + /// The list containing prim ownership counts + public ParcelObjectOwnersReplyEventArgs(Simulator simulator, List primOwners) + { + this.m_Simulator = simulator; + this.m_Owners = primOwners; + } + } + + /// Contains the data returned when all parcel data has been retrieved from a simulator + public class SimParcelsDownloadedEventArgs : EventArgs + { + private readonly Simulator m_Simulator; + private readonly InternalDictionary m_Parcels; + private readonly int[,] m_ParcelMap; + + /// Get the simulator the parcel data was retrieved from + public Simulator Simulator { get { return m_Simulator; } } + /// A dictionary containing the parcel data where the key correlates to the ParcelMap entry + public InternalDictionary Parcels { get { return m_Parcels; } } + /// Get the multidimensional array containing a x,y grid mapped + /// to each 64x64 parcel's LocalID. + public int[,] ParcelMap { get { return m_ParcelMap; } } + + /// + /// Construct a new instance of the SimParcelsDownloadedEventArgs class + /// + /// The simulator the parcel data was retrieved from + /// The dictionary containing the parcel data + /// The multidimensional array containing a x,y grid mapped + /// to each 64x64 parcel's LocalID. + public SimParcelsDownloadedEventArgs(Simulator simulator, InternalDictionary simParcels, int[,] parcelMap) + { + this.m_Simulator = simulator; + this.m_Parcels = simParcels; + this.m_ParcelMap = parcelMap; + } + } + + /// Contains the data returned when a request + public class ForceSelectObjectsReplyEventArgs : EventArgs + { + private readonly Simulator m_Simulator; + private readonly List m_ObjectIDs; + private readonly bool m_ResetList; + + /// Get the simulator the parcel data was retrieved from + public Simulator Simulator { get { return m_Simulator; } } + /// Get the list of primitive IDs + public List ObjectIDs { get { return m_ObjectIDs; } } + /// true if the list is clean and contains the information + /// only for a given request + public bool ResetList { get { return m_ResetList; } } + + /// + /// Construct a new instance of the ForceSelectObjectsReplyEventArgs class + /// + /// The simulator the parcel data was retrieved from + /// The list of primitive IDs + /// true if the list is clean and contains the information + /// only for a given request + public ForceSelectObjectsReplyEventArgs(Simulator simulator, List objectIDs, bool resetList) + { + this.m_Simulator = simulator; + this.m_ObjectIDs = objectIDs; + this.m_ResetList = resetList; + } + } + + /// Contains data when the media data for a parcel the avatar is on changes + public class ParcelMediaUpdateReplyEventArgs : EventArgs + { + private readonly Simulator m_Simulator; + private readonly ParcelMedia m_ParcelMedia; + + /// Get the simulator the parcel media data was updated in + public Simulator Simulator { get { return m_Simulator; } } + /// Get the updated media information + public ParcelMedia Media { get { return m_ParcelMedia; } } + + /// + /// Construct a new instance of the ParcelMediaUpdateReplyEventArgs class + /// + /// the simulator the parcel media data was updated in + /// The updated media information + public ParcelMediaUpdateReplyEventArgs(Simulator simulator, ParcelMedia media) + { + this.m_Simulator = simulator; + this.m_ParcelMedia = media; + } + } + + /// Contains the media command for a parcel the agent is currently on + public class ParcelMediaCommandEventArgs : EventArgs + { + private readonly Simulator m_Simulator; + private readonly uint m_Sequence; + private readonly ParcelFlags m_ParcelFlags; + private readonly ParcelMediaCommand m_MediaCommand; + private readonly float m_Time; + + /// Get the simulator the parcel media command was issued in + public Simulator Simulator { get { return m_Simulator; } } + /// + public uint Sequence { get { return m_Sequence; } } + /// + public ParcelFlags ParcelFlags { get { return m_ParcelFlags; } } + /// Get the media command that was sent + public ParcelMediaCommand MediaCommand { get { return m_MediaCommand; } } + /// + public float Time { get { return m_Time; } } + + /// + /// Construct a new instance of the ParcelMediaCommandEventArgs class + /// + /// The simulator the parcel media command was issued in + /// + /// + /// The media command that was sent + /// + public ParcelMediaCommandEventArgs(Simulator simulator, uint sequence, ParcelFlags flags, ParcelMediaCommand command, float time) + { + this.m_Simulator = simulator; + this.m_Sequence = sequence; + this.m_ParcelFlags = flags; + this.m_MediaCommand = command; + this.m_Time = time; + } + } + #endregion } diff --git a/OpenMetaverse/Simulator.cs b/OpenMetaverse/Simulator.cs index 0595776b..349aa930 100644 --- a/OpenMetaverse/Simulator.cs +++ b/OpenMetaverse/Simulator.cs @@ -358,7 +358,7 @@ namespace OpenMetaverse /// /// Provides access to an internal thread-safe multidimensional array containing a x,y grid mapped - /// each 64x64 parcel's LocalID. + /// to each 64x64 parcel's LocalID. /// public int[,] ParcelMap { diff --git a/Programs/PrimWorkshop/frmBrowser.cs b/Programs/PrimWorkshop/frmBrowser.cs index 3190e0c8..e2c1953f 100644 --- a/Programs/PrimWorkshop/frmBrowser.cs +++ b/Programs/PrimWorkshop/frmBrowser.cs @@ -164,7 +164,7 @@ namespace PrimWorkshop Client.Objects.OnNewPrim += new ObjectManager.NewPrimCallback(Objects_OnNewPrim); Client.Objects.OnObjectKilled += new ObjectManager.KillObjectCallback(Objects_OnObjectKilled); Client.Terrain.OnLandPatch += new TerrainManager.LandPatchCallback(Terrain_OnLandPatch); - Client.Parcels.OnSimParcelsDownloaded += new ParcelManager.SimParcelsDownloaded(Parcels_OnSimParcelsDownloaded); + Client.Parcels.SimParcelsDownloaded += new EventHandler(Parcels_SimParcelsDownloaded); Client.Assets.OnImageRecieveProgress += new AssetManager.ImageReceiveProgressCallback(Assets_OnImageRecieveProgress); // Initialize the camera object @@ -191,6 +191,27 @@ namespace PrimWorkshop */ } + void Parcels_SimParcelsDownloaded(object sender, SimParcelsDownloadedEventArgs e) + { + TotalPrims = 0; + + e.Parcels.ForEach( + delegate(Parcel parcel) + { + TotalPrims += parcel.TotalPrims; + }); + + UpdatePrimProgress(); TotalPrims = 0; + + e.Parcels.ForEach( + delegate(Parcel parcel) + { + TotalPrims += parcel.TotalPrims; + }); + + UpdatePrimProgress(); + } + private void InitOpenGL() { @@ -989,20 +1010,7 @@ namespace PrimWorkshop { // } - - private void Parcels_OnSimParcelsDownloaded(Simulator simulator, InternalDictionary simParcels, int[,] parcelMap) - { - TotalPrims = 0; - - simParcels.ForEach( - delegate(Parcel parcel) - { - TotalPrims += parcel.TotalPrims; - }); - - UpdatePrimProgress(); - } - + private void Terrain_OnLandPatch(Simulator simulator, int x, int y, int width, float[] data) { if (Client != null && Client.Network.CurrentSim == simulator) diff --git a/Programs/examples/TestClient/Commands/Directory/Key2NameCommand.cs b/Programs/examples/TestClient/Commands/Directory/Key2NameCommand.cs new file mode 100644 index 00000000..ce3596a1 --- /dev/null +++ b/Programs/examples/TestClient/Commands/Directory/Key2NameCommand.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenMetaverse.TestClient.Commands +{ + class key2nameCommand : Command + { + System.Threading.AutoResetEvent waitQuery = new System.Threading.AutoResetEvent(false); + StringBuilder result = new StringBuilder(); + public key2nameCommand(TestClient testClient) + { + Name = "key2name"; + Description = "resolve a UUID to an avatar or group name. Usage: key2name UUID"; + Category = CommandCategory.Search; + } + + public override string Execute(string[] args, UUID fromAgentID) + { + if (args.Length < 1) + return "Usage: key2name UUID"; + + UUID key; + if(!UUID.TryParse(args[0].Trim(), out key)) + { + return "UUID " + args[0].Trim() + " appears to be invalid"; + } + result.Remove(0, result.Length); + waitQuery.Reset(); + + Client.Avatars.OnAvatarNames += Avatars_OnAvatarNames; + Client.Groups.OnGroupProfile += Groups_OnGroupProfile; + Client.Avatars.RequestAvatarName(key); + + Client.Groups.RequestGroupProfile(key); + if (!waitQuery.WaitOne(10000, false)) + { + result.AppendLine("Timeout waiting for reply, this could mean the Key is not an avatar or a group"); + } + + Client.Avatars.OnAvatarNames -= Avatars_OnAvatarNames; + Client.Groups.OnGroupProfile -= Groups_OnGroupProfile; + return result.ToString(); + } + + void Groups_OnGroupProfile(Group group) + { + result.AppendLine("Group: " + group.Name + " " + group.ID); + waitQuery.Set(); + } + + void Avatars_OnAvatarNames(Dictionary names) + { + foreach (KeyValuePair kvp in names) + result.AppendLine("Avatar: " + kvp.Value + " " + kvp.Key); + waitQuery.Set(); + } + } +} diff --git a/Programs/examples/TestClient/Commands/Directory/SearchClassifiedsCommand.cs b/Programs/examples/TestClient/Commands/Directory/SearchClassifiedsCommand.cs index 23944575..fa1b6eba 100644 --- a/Programs/examples/TestClient/Commands/Directory/SearchClassifiedsCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/SearchClassifiedsCommand.cs @@ -12,7 +12,7 @@ namespace OpenMetaverse.TestClient.Commands { Name = "searchclassifieds"; Description = "Searches Classified Ads. Usage: searchclassifieds [search text]"; - Category = CommandCategory.Other; + Category = CommandCategory.Search; } public override string Execute(string[] args, UUID fromAgentID) diff --git a/Programs/examples/TestClient/Commands/Directory/SearchEventsCommand.cs b/Programs/examples/TestClient/Commands/Directory/SearchEventsCommand.cs index 08562992..3029b374 100644 --- a/Programs/examples/TestClient/Commands/Directory/SearchEventsCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/SearchEventsCommand.cs @@ -13,7 +13,7 @@ namespace OpenMetaverse.TestClient.Commands { Name = "searchevents"; Description = "Searches Events list. Usage: searchevents [search text]"; - Category = CommandCategory.Other; + Category = CommandCategory.Search; } public override string Execute(string[] args, UUID fromAgentID) diff --git a/Programs/examples/TestClient/Commands/Directory/SearchPeopleCommand.cs b/Programs/examples/TestClient/Commands/Directory/SearchPeopleCommand.cs index 712f44aa..a9efc771 100644 --- a/Programs/examples/TestClient/Commands/Directory/SearchPeopleCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/SearchPeopleCommand.cs @@ -13,7 +13,7 @@ namespace OpenMetaverse.TestClient.Commands { Name = "searchpeople"; Description = "Searches for other avatars. Usage: searchpeople [search text]"; - Category = CommandCategory.Friends; + Category = CommandCategory.Search; } public override string Execute(string[] args, UUID fromAgentID) diff --git a/Programs/examples/TestClient/Commands/Directory/SearchPlacesCommand.cs b/Programs/examples/TestClient/Commands/Directory/SearchPlacesCommand.cs index b9409035..93aafe85 100644 --- a/Programs/examples/TestClient/Commands/Directory/SearchPlacesCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/SearchPlacesCommand.cs @@ -12,7 +12,7 @@ namespace OpenMetaverse.TestClient.Commands { Name = "searchplaces"; Description = "Searches Places. Usage: searchplaces [search text]"; - Category = CommandCategory.Other; + Category = CommandCategory.Search; } public override string Execute(string[] args, UUID fromAgentID) diff --git a/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs b/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs index 32ce044d..790517c1 100644 --- a/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs @@ -18,7 +18,7 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell { if (args.Length < 2) { - return "Usage: give [item2] [item3] [...]"; + return "Usage: give itemname"; } UUID dest; if (!UUID.TryParse(args[0], out dest)) @@ -29,32 +29,36 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell Inventory = Manager.Store; string ret = ""; string nl = "\n"; - for (int i = 1; i < args.Length; ++i) + + string target = String.Empty; + for (int ct = 0; ct < args.Length; ct++) + target = target + args[ct] + " "; + target = target.TrimEnd(); + + string inventoryName = target; + // WARNING: Uses local copy of inventory contents, need to download them first. + List contents = Inventory.GetContents(Client.CurrentDirectory); + bool found = false; + foreach (InventoryBase b in contents) { - string inventoryName = args[i]; - // WARNING: Uses local copy of inventory contents, need to download them first. - List contents = Inventory.GetContents(Client.CurrentDirectory); - bool found = false; - foreach (InventoryBase b in contents) + if (inventoryName == b.Name || inventoryName == b.UUID.ToString()) { - if (inventoryName == b.Name || inventoryName == b.UUID.ToString()) + found = true; + if (b is InventoryItem) { - found = true; - if (b is InventoryItem) - { - InventoryItem item = b as InventoryItem; - Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true); - ret += "Gave " + item.Name + nl; - } - else - { - ret += "Unable to give folder " + b.Name + nl; - } + InventoryItem item = b as InventoryItem; + Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true); + ret += "Gave " + item.Name + " (" + item.AssetType + ")" + nl; + } + else + { + ret += "Unable to give folder " + b.Name + nl; } } - if (!found) - ret += "No inventory item named " + inventoryName + " found." + nl; } + if (!found) + ret += "No inventory item named " + inventoryName + " found." + nl; + return ret; } } diff --git a/Programs/examples/TestClient/Commands/Land/ParcelDetailsCommand.cs b/Programs/examples/TestClient/Commands/Land/ParcelDetailsCommand.cs index 88121e67..18aff2a5 100644 --- a/Programs/examples/TestClient/Commands/Land/ParcelDetailsCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/ParcelDetailsCommand.cs @@ -27,7 +27,7 @@ namespace OpenMetaverse.TestClient if (Int32.TryParse(args[0], out parcelID) && Client.Network.CurrentSim.Parcels.TryGetValue(parcelID, out parcel)) { // this request will update the parcels dictionary - Client.Parcels.PropertiesRequest(Client.Network.CurrentSim, parcelID, 0); + Client.Parcels.RequestParcelProperties(Client.Network.CurrentSim, parcelID, 0); // Use reflection to dynamically get the fields from the Parcel struct Type t = parcel.GetType(); diff --git a/Programs/examples/TestClient/Commands/Land/ParcelInfoCommand.cs b/Programs/examples/TestClient/Commands/Land/ParcelInfoCommand.cs index 8220ca75..4729c6d9 100644 --- a/Programs/examples/TestClient/Commands/Land/ParcelInfoCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/ParcelInfoCommand.cs @@ -23,14 +23,14 @@ namespace OpenMetaverse.TestClient { StringBuilder sb = new StringBuilder(); string result; - - ParcelManager.SimParcelsDownloaded del = delegate(Simulator simulator, InternalDictionary simParcels, int[,] parcelMap) + EventHandler del = delegate(object sender, SimParcelsDownloadedEventArgs e) { ParcelsDownloaded.Set(); }; + ParcelsDownloaded.Reset(); - Client.Parcels.OnSimParcelsDownloaded += del; + Client.Parcels.SimParcelsDownloaded += del; Client.Parcels.RequestAllSimParcels(Client.Network.CurrentSim); if (Client.Network.CurrentSim.IsParcelMapFull()) @@ -45,16 +45,6 @@ namespace OpenMetaverse.TestClient { sb.AppendFormat("Parcel[{0}]: Name: \"{1}\", Description: \"{2}\" ACLBlacklist Count: {3}, ACLWhiteList Count: {5} Traffic: {4}" + System.Environment.NewLine, parcel.LocalID, parcel.Name, parcel.Desc, parcel.AccessBlackList.Count, parcel.Dwell, parcel.AccessWhiteList.Count); - //foreach (ParcelManager.ParcelAccessEntry white in parcel.AccessWhiteList) - //{ - // if(white.AgentID != UUID.Zero) - // sb.AppendFormat("\tAllowed Avatar {0}" + System.Environment.NewLine, white.AgentID); - //} - //foreach (ParcelManager.ParcelAccessEntry black in parcel.AccessBlackList) - //{ - // if(black.AgentID != UUID.Zero) - // sb.AppendFormat("\t Banned Avatar {0}" + System.Environment.NewLine, black.AgentID); - //} }); result = sb.ToString(); @@ -62,7 +52,7 @@ namespace OpenMetaverse.TestClient else result = "Failed to retrieve information on all the simulator parcels"; - Client.Parcels.OnSimParcelsDownloaded -= del; + Client.Parcels.SimParcelsDownloaded -= del; return result; } diff --git a/Programs/examples/TestClient/Commands/Land/ParcelPrimOwnersCommand.cs b/Programs/examples/TestClient/Commands/Land/ParcelPrimOwnersCommand.cs index 1b6d9b5a..1cb4defd 100644 --- a/Programs/examples/TestClient/Commands/Land/ParcelPrimOwnersCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/ParcelPrimOwnersCommand.cs @@ -27,23 +27,25 @@ namespace OpenMetaverse.TestClient if (Int32.TryParse(args[0], out parcelID) && Client.Network.CurrentSim.Parcels.TryGetValue(parcelID, out parcel)) { AutoResetEvent wait = new AutoResetEvent(false); - ParcelManager.ParcelObjectOwnersListReplyCallback callback = delegate(Simulator simulator, List primOwners) + + EventHandler callback = delegate(object sender, ParcelObjectOwnersReplyEventArgs e) { - for(int i = 0; i < primOwners.Count; i++) + for (int i = 0; i < e.PrimOwners.Count; i++) { - result.AppendFormat("Owner: {0} Count: {1}" + System.Environment.NewLine, primOwners[i].OwnerID, primOwners[i].Count); + result.AppendFormat("Owner: {0} Count: {1}" + System.Environment.NewLine, e.PrimOwners[i].OwnerID, e.PrimOwners[i].Count); wait.Set(); } }; + + + Client.Parcels.ParcelObjectOwnersReply += callback; - Client.Parcels.OnPrimOwnersListReply += callback; - - Client.Parcels.ObjectOwnersRequest(Client.Network.CurrentSim, parcelID); + Client.Parcels.RequestObjectOwners(Client.Network.CurrentSim, parcelID); if (!wait.WaitOne(10000, false)) { result.AppendLine("Timed out waiting for packet."); } - Client.Parcels.OnPrimOwnersListReply -= callback; + Client.Parcels.ParcelObjectOwnersReply -= callback; return result.ToString(); } diff --git a/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs b/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs index ec14e089..afdd5ca7 100644 --- a/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs +++ b/Programs/examples/TestClient/Commands/Land/ParcelSelectObjectsCommand.cs @@ -30,30 +30,31 @@ namespace OpenMetaverse.TestClient && UUID.TryParse(args[1], out ownerUUID)) { AutoResetEvent wait = new AutoResetEvent(false); - ParcelManager.ForceSelectObjects callback = delegate(Simulator simulator, List objectIDs, bool resetList) + EventHandler callback = delegate(object sender, ForceSelectObjectsReplyEventArgs e) { - //result.AppendLine("New List: " + resetList.ToString()); - for(int i = 0; i < objectIDs.Count; i++) + + for (int i = 0; i < e.ObjectIDs.Count; i++) { - result.Append(objectIDs[i].ToString() + " "); + result.Append(e.ObjectIDs[i].ToString() + " "); counter++; } - //result.AppendLine("Got " + objectIDs.Count.ToString() + " Objects in packet"); - if(objectIDs.Count < 251) + + if (e.ObjectIDs.Count < 251) wait.Set(); }; - - Client.Parcels.OnParcelSelectedObjects += callback; - Client.Parcels.SelectObjects(parcelID, (ObjectReturnType)16, ownerUUID); - Client.Parcels.ObjectOwnersRequest(Client.Network.CurrentSim, parcelID); + Client.Parcels.ForceSelectObjectsReply += callback; + Client.Parcels.RequestSelectObjects(parcelID, (ObjectReturnType)16, ownerUUID); + + + Client.Parcels.RequestObjectOwners(Client.Network.CurrentSim, parcelID); if (!wait.WaitOne(30000, false)) { result.AppendLine("Timed out waiting for packet."); } - Client.Parcels.OnParcelSelectedObjects -= callback; + Client.Parcels.ForceSelectObjectsReply -= callback; result.AppendLine("Found a total of " + counter + " Objects"); return result.ToString(); }