diff --git a/OpenMetaverse.GUI/AvatarList.cs b/OpenMetaverse.GUI/AvatarList.cs index 4e3934e6..c7c89d4b 100644 --- a/OpenMetaverse.GUI/AvatarList.cs +++ b/OpenMetaverse.GUI/AvatarList.cs @@ -153,14 +153,40 @@ namespace OpenMetaverse.GUI private void InitializeClient(GridClient client) { _Client = client; - _Client.Avatars.OnAvatarAppearance += new AvatarManager.AvatarAppearanceCallback(Avatars_OnAvatarAppearance); - _Client.Avatars.OnAvatarNames += new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames); + _Client.Avatars.AvatarAppearance += Avatars_OnAvatarAppearance; + _Client.Avatars.UUIDNameReply += new EventHandler(Avatars_UUIDNameReply); _Client.Grid.CoarseLocationUpdate += Grid_CoarseLocationUpdate; _Client.Network.OnCurrentSimChanged += new NetworkManager.CurrentSimChangedCallback(Network_OnCurrentSimChanged); _Client.Objects.OnNewAvatar += new ObjectManager.NewAvatarCallback(Objects_OnNewAvatar); _Client.Objects.OnObjectUpdated += new ObjectManager.ObjectUpdatedCallback(Objects_OnObjectUpdated); } + void Avatars_UUIDNameReply(object sender, UUIDNameReplyEventArgs e) + { + lock (_UntrackedAvatars) + { + foreach (KeyValuePair name in e.Names) + { + TrackedAvatar trackedAvatar; + if (_UntrackedAvatars.TryGetValue(name.Key, out trackedAvatar)) + { + trackedAvatar.Name = name.Value; + + if (OnAvatarAdded != null && trackedAvatar.ListViewItem.Text == "(Loading...)") + { + try { OnAvatarAdded(trackedAvatar); } + catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } + } + + this.BeginInvoke((MethodInvoker)delegate + { + trackedAvatar.ListViewItem.Text = name.Value; + }); + } + } + } + } + void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e) { UpdateCoarseInfo(e.Simulator, e.NewEntries, e.RemovedEntries); @@ -387,50 +413,23 @@ namespace OpenMetaverse.GUI } } - void Avatars_OnAvatarAppearance(UUID avatarID, bool isTrial, Primitive.TextureEntryFace defaultTexture, Primitive.TextureEntryFace[] faceTextures, List visualParams) + void Avatars_OnAvatarAppearance(object sender, AvatarAppearanceEventArgs e) { - if (visualParams.Count > 31) + if (e.VisualParams.Count > 31) { lock (_TrackedAvatars) { TrackedAvatar trackedAvatar; - if (_TrackedAvatars.TryGetValue(avatarID, out trackedAvatar)) + if (_TrackedAvatars.TryGetValue(e.AvatarID, out trackedAvatar)) { this.BeginInvoke((MethodInvoker)delegate { - byte param = visualParams[31]; + byte param = e.VisualParams[31]; if (param > 0) trackedAvatar.ListViewItem.ForeColor = Color.Blue; else trackedAvatar.ListViewItem.ForeColor = Color.Magenta; - }); - - } - } - } - } - - void Avatars_OnAvatarNames(Dictionary names) - { - lock (_UntrackedAvatars) - { - foreach (KeyValuePair name in names) - { - TrackedAvatar trackedAvatar; - if (_UntrackedAvatars.TryGetValue(name.Key, out trackedAvatar)) - { - trackedAvatar.Name = name.Value; - - if (OnAvatarAdded != null && trackedAvatar.ListViewItem.Text == "(Loading...)") - { - try { OnAvatarAdded(trackedAvatar); } - catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } - } - - this.BeginInvoke((MethodInvoker)delegate - { - trackedAvatar.ListViewItem.Text = name.Value; - }); + }); } } } diff --git a/OpenMetaverse/AvatarManager.cs b/OpenMetaverse/AvatarManager.cs index 2fd68058..3f7f63f5 100644 --- a/OpenMetaverse/AvatarManager.cs +++ b/OpenMetaverse/AvatarManager.cs @@ -55,6 +55,20 @@ namespace OpenMetaverse public bool ListInProfile; } + /// + /// Contains an animation currently being played by an agent + /// + public struct Animation + { + /// The ID of the animation asset + public UUID AnimationID; + /// A number to indicate start order of currently playing animations + /// On Linden Grids this number is unique per region, with OpenSim it is per client + public int AnimationSequence; + /// + public UUID AnimationSourceObjectID; + } + /// /// Holds group information on an individual profile pick /// @@ -86,7 +100,7 @@ namespace OpenMetaverse public byte ClassifiedFlags; public int Price; public string Name; - public string Desc; + public string Desc; } #endregion @@ -98,135 +112,341 @@ namespace OpenMetaverse { const int MAX_UUIDS_PER_PACKET = 100; - /// - /// Triggered when an avatar animation signal is received - /// - /// UUID of the avatar sending the animation - /// UUID of the animation, and animation sequence number - public delegate void AvatarAnimationCallback(UUID avatarID, InternalDictionary anims); - /// - /// Triggered when AvatarAppearance is received - /// - /// - /// - /// - /// - /// - public delegate void AvatarAppearanceCallback(UUID avatarID, bool isTrial, Primitive.TextureEntryFace defaultTexture, Primitive.TextureEntryFace[] faceTextures, List visualParams); - /// - /// Triggered when a UUIDNameReply is received - /// - /// - public delegate void AvatarNamesCallback(Dictionary names); - /// - /// Triggered when a response for avatar interests is returned - /// - /// - /// - public delegate void AvatarInterestsCallback(UUID avatarID, Avatar.Interests interests); - /// - /// Triggered when avatar properties are received (AvatarPropertiesReply) - /// - /// - /// - public delegate void AvatarPropertiesCallback(UUID avatarID, Avatar.AvatarProperties properties); - /// - /// Triggered when an avatar group list is received (AvatarGroupsReply) - /// - /// - /// - public delegate void AvatarGroupsCallback(UUID avatarID, List avatarGroups); - /// - /// Triggered when a name search reply is received (AvatarPickerReply) - /// - /// - /// - public delegate void AvatarNameSearchCallback(UUID queryID, Dictionary avatars); - /// - /// - /// - /// - /// - /// - /// - /// - /// - public delegate void PointAtCallback(UUID sourceID, UUID targetID, Vector3d targetPos, - PointAtType pointType, float duration, UUID id); - /// - /// - /// - /// - /// - /// - /// - /// - /// - public delegate void LookAtCallback(UUID sourceID, UUID targetID, Vector3d targetPos, - LookAtType lookType, float duration, UUID id); - /// - /// - /// - /// - /// - /// - /// - /// - /// - public delegate void EffectCallback(EffectType type, UUID sourceID, UUID targetID, - Vector3d targetPos, float duration, UUID id); - /// - /// Callback returning a dictionary of avatar's picks - /// - /// - /// - public delegate void AvatarPicksCallback(UUID avatarid, Dictionary picks); - /// - /// Callback returning a details of a specifick pick - /// - /// - /// - public delegate void PickInfoCallback(UUID pickid, ProfilePick pick); - /// - /// Callback returning a dictionary of avatar's Classified - /// - /// - /// - public delegate void AvatarClassifiedCallback(UUID avatarid, Dictionary classified); - /// - /// Callback returning a details of a specifick Classified - /// - /// - /// - public delegate void ClassifiedInfoCallback(UUID classifiedID, ClassifiedAd Classified); - /// - public event AvatarAnimationCallback OnAvatarAnimation; - /// - public event AvatarAppearanceCallback OnAvatarAppearance; - /// - public event AvatarNamesCallback OnAvatarNames; - /// - public event AvatarInterestsCallback OnAvatarInterests; - /// - public event AvatarPropertiesCallback OnAvatarProperties; - /// - public event AvatarGroupsCallback OnAvatarGroups; - /// - public event AvatarNameSearchCallback OnAvatarNameSearch; - /// - public event PointAtCallback OnPointAt; - /// - public event LookAtCallback OnLookAt; - /// - public event EffectCallback OnEffect; - /// - public event AvatarPicksCallback OnAvatarPicks; - /// - public event PickInfoCallback OnPickInfo; - /// - public event AvatarClassifiedCallback OnAvatarClassifieds; - /// - public event ClassifiedInfoCallback OnClassifiedInfo; + /// The event subscribers, null of no subscribers + private EventHandler m_AvatarAnimation; + + ///Raises the AvatarAnimation Event + /// An AvatarAnimationEventArgs object containing + /// the data sent from the simulator + protected virtual void OnAvatarAnimation(AvatarAnimationEventArgs e) + { + EventHandler handler = m_AvatarAnimation; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_AvatarAnimationLock = new object(); + + /// Raised when the simulator sends us data containing + /// an agents animation playlist + public event EventHandler AvatarAnimation + { + add { lock (m_AvatarAnimationLock) { m_AvatarAnimation += value; } } + remove { lock (m_AvatarAnimationLock) { m_AvatarAnimation -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_AvatarAppearance; + + ///Raises the AvatarAppearance Event + /// A AvatarAppearanceEventArgs object containing + /// the data sent from the simulator + protected virtual void OnAvatarAppearance(AvatarAppearanceEventArgs e) + { + EventHandler handler = m_AvatarAppearance; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_AvatarAppearanceLock = new object(); + + /// Raised when the simulator sends us data containing + /// the appearance information for an agent + public event EventHandler AvatarAppearance + { + add { lock (m_AvatarAppearanceLock) { m_AvatarAppearance += value; } } + remove { lock (m_AvatarAppearanceLock) { m_AvatarAppearance -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_UUIDNameReply; + + ///Raises the UUIDNameReply Event + /// A UUIDNameReplyEventArgs object containing + /// the data sent from the simulator + protected virtual void OnUUIDNameReply(UUIDNameReplyEventArgs e) + { + EventHandler handler = m_UUIDNameReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_UUIDNameReplyLock = new object(); + + /// Raised when the simulator sends us data containing + /// agent names/id values + public event EventHandler UUIDNameReply + { + add { lock (m_UUIDNameReplyLock) { m_UUIDNameReply += value; } } + remove { lock (m_UUIDNameReplyLock) { m_UUIDNameReply -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_AvatarInterestsReply; + + ///Raises the AvatarInterestsReply Event + /// A AvatarInterestsReplyEventArgs object containing + /// the data sent from the simulator + protected virtual void OnAvatarInterestsReply(AvatarInterestsReplyEventArgs e) + { + EventHandler handler = m_AvatarInterestsReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_AvatarInterestsReplyLock = new object(); + + /// Raised when the simulator sends us data containing + /// the interests listed in an agents profile + public event EventHandler AvatarInterestsReply + { + add { lock (m_AvatarInterestsReplyLock) { m_AvatarInterestsReply += value; } } + remove { lock (m_AvatarInterestsReplyLock) { m_AvatarInterestsReply -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_AvatarPropertiesReply; + + ///Raises the AvatarPropertiesReply Event + /// A AvatarPropertiesReplyEventArgs object containing + /// the data sent from the simulator + protected virtual void OnAvatarPropertiesReply(AvatarPropertiesReplyEventArgs e) + { + EventHandler handler = m_AvatarPropertiesReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_AvatarPropertiesReplyLock = new object(); + + /// Raised when the simulator sends us data containing + /// profile property information for an agent + public event EventHandler AvatarPropertiesReply + { + add { lock (m_AvatarPropertiesReplyLock) { m_AvatarPropertiesReply += value; } } + remove { lock (m_AvatarPropertiesReplyLock) { m_AvatarPropertiesReply -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_AvatarGroupsReply; + + ///Raises the AvatarGroupsReply Event + /// A AvatarGroupsReplyEventArgs object containing + /// the data sent from the simulator + protected virtual void OnAvatarGroupsReply(AvatarGroupsReplyEventArgs e) + { + EventHandler handler = m_AvatarGroupsReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_AvatarGroupsReplyLock = new object(); + + /// Raised when the simulator sends us data containing + /// the group membership an agent is a member of + public event EventHandler AvatarGroupsReply + { + add { lock (m_AvatarGroupsReplyLock) { m_AvatarGroupsReply += value; } } + remove { lock (m_AvatarGroupsReplyLock) { m_AvatarGroupsReply -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_AvatarPickerReply; + + ///Raises the AvatarPickerReply Event + /// A AvatarPickerReplyEventArgs object containing + /// the data sent from the simulator + protected virtual void OnAvatarPickerReply(AvatarPickerReplyEventArgs e) + { + EventHandler handler = m_AvatarPickerReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_AvatarPickerReplyLock = new object(); + + /// Raised when the simulator sends us data containing + /// name/id pair + public event EventHandler AvatarPickerReply + { + add { lock (m_AvatarPickerReplyLock) { m_AvatarPickerReply += value; } } + remove { lock (m_AvatarPickerReplyLock) { m_AvatarPickerReply -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_ViewerEffectPointAt; + + ///Raises the ViewerEffectPointAt Event + /// A ViewerEffectPointAtEventArgs object containing + /// the data sent from the simulator + protected virtual void OnViewerEffectPointAt(ViewerEffectPointAtEventArgs e) + { + EventHandler handler = m_ViewerEffectPointAt; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ViewerEffectPointAtLock = new object(); + + /// Raised when the simulator sends us data containing + /// the objects and effect when an agent is pointing at + public event EventHandler ViewerEffectPointAt + { + add { lock (m_ViewerEffectPointAtLock) { m_ViewerEffectPointAt += value; } } + remove { lock (m_ViewerEffectPointAtLock) { m_ViewerEffectPointAt -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_ViewerEffectLookAt; + + ///Raises the ViewerEffectLookAt Event + /// A ViewerEffectLookAtEventArgs object containing + /// the data sent from the simulator + protected virtual void OnViewerEffectLookAt(ViewerEffectLookAtEventArgs e) + { + EventHandler handler = m_ViewerEffectLookAt; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ViewerEffectLookAtLock = new object(); + + /// Raised when the simulator sends us data containing + /// the objects and effect when an agent is looking at + public event EventHandler ViewerEffectLookAt + { + add { lock (m_ViewerEffectLookAtLock) { m_ViewerEffectLookAt += value; } } + remove { lock (m_ViewerEffectLookAtLock) { m_ViewerEffectLookAt -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_ViewerEffect; + + ///Raises the ViewerEffect Event + /// A ViewerEffectEventArgs object containing + /// the data sent from the simulator + protected virtual void OnViewerEffect(ViewerEffectEventArgs e) + { + EventHandler handler = m_ViewerEffect; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ViewerEffectLock = new object(); + + /// Raised when the simulator sends us data containing + /// an agents viewer effect information + public event EventHandler ViewerEffect + { + add { lock (m_ViewerEffectLock) { m_ViewerEffect += value; } } + remove { lock (m_ViewerEffectLock) { m_ViewerEffect -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_AvatarPicksReply; + + ///Raises the AvatarPicksReply Event + /// A AvatarPicksReplyEventArgs object containing + /// the data sent from the simulator + protected virtual void OnAvatarPicksReply(AvatarPicksReplyEventArgs e) + { + EventHandler handler = m_AvatarPicksReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_AvatarPicksReplyLock = new object(); + + /// Raised when the simulator sends us data containing + /// the top picks from an agents profile + public event EventHandler AvatarPicksReply + { + add { lock (m_AvatarPicksReplyLock) { m_AvatarPicksReply += value; } } + remove { lock (m_AvatarPicksReplyLock) { m_AvatarPicksReply -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_PickInfoReply; + + ///Raises the PickInfoReply Event + /// A PickInfoReplyEventArgs object containing + /// the data sent from the simulator + protected virtual void OnPickInfoReply(PickInfoReplyEventArgs e) + { + EventHandler handler = m_PickInfoReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_PickInfoReplyLock = new object(); + + /// Raised when the simulator sends us data containing + /// the Pick details + public event EventHandler PickInfoReply + { + add { lock (m_PickInfoReplyLock) { m_PickInfoReply += value; } } + remove { lock (m_PickInfoReplyLock) { m_PickInfoReply -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_AvatarClassifiedReply; + + ///Raises the AvatarClassifiedReply Event + /// A AvatarClassifiedReplyEventArgs object containing + /// the data sent from the simulator + protected virtual void OnAvatarClassifiedReply(AvatarClassifiedReplyEventArgs e) + { + EventHandler handler = m_AvatarClassifiedReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_AvatarClassifiedReplyLock = new object(); + + /// Raised when the simulator sends us data containing + /// the classified ads an agent has placed + public event EventHandler AvatarClassifiedReply + { + add { lock (m_AvatarClassifiedReplyLock) { m_AvatarClassifiedReply += value; } } + remove { lock (m_AvatarClassifiedReplyLock) { m_AvatarClassifiedReply -= value; } } + } + + /// The event subscribers, null of no subscribers + private EventHandler m_ClassifiedInfoReply; + + ///Raises the ClassifiedInfoReply Event + /// A ClassifiedInfoReplyEventArgs object containing + /// the data sent from the simulator + protected virtual void OnClassifiedInfoReply(ClassifiedInfoReplyEventArgs e) + { + EventHandler handler = m_ClassifiedInfoReply; + if (handler != null) + handler(this, e); + } + + /// Thread sync lock object + private readonly object m_ClassifiedInfoReplyLock = new object(); + + /// Raised when the simulator sends us data containing + /// the details of a classified ad + public event EventHandler ClassifiedInfoReply + { + add { lock (m_ClassifiedInfoReplyLock) { m_ClassifiedInfoReply += value; } } + remove { lock (m_ClassifiedInfoReplyLock) { m_ClassifiedInfoReply -= value; } } + } private GridClient Client; @@ -247,28 +467,28 @@ namespace OpenMetaverse Client.Network.RegisterCallback(PacketType.AvatarInterestsReply, new NetworkManager.PacketCallback(AvatarInterestsHandler)); // Avatar group callback - Client.Network.RegisterCallback(PacketType.AvatarGroupsReply, new NetworkManager.PacketCallback(AvatarGroupsHandler)); + Client.Network.RegisterCallback(PacketType.AvatarGroupsReply, new NetworkManager.PacketCallback(AvatarGroupsReplyHandler)); // Viewer effect callback Client.Network.RegisterCallback(PacketType.ViewerEffect, new NetworkManager.PacketCallback(ViewerEffectHandler)); // Other callbacks - Client.Network.RegisterCallback(PacketType.UUIDNameReply, new NetworkManager.PacketCallback(AvatarNameHandler)); + Client.Network.RegisterCallback(PacketType.UUIDNameReply, new NetworkManager.PacketCallback(UUIDNameReplyHandler)); Client.Network.RegisterCallback(PacketType.AvatarPickerReply, new NetworkManager.PacketCallback(AvatarPickerReplyHandler)); - Client.Network.RegisterCallback(PacketType.AvatarAnimation, new NetworkManager.PacketCallback(AvatarAnimationHandler)); + Client.Network.RegisterCallback(PacketType.AvatarAnimation, new NetworkManager.PacketCallback(AvatarAnimationHandler)); // Picks callbacks - Client.Network.RegisterCallback(PacketType.AvatarPicksReply, new NetworkManager.PacketCallback(AvatarPicksHandler)); - Client.Network.RegisterCallback(PacketType.PickInfoReply, new NetworkManager.PacketCallback(PickInfoHandler)); + Client.Network.RegisterCallback(PacketType.AvatarPicksReply, new NetworkManager.PacketCallback(AvatarPicksReplyHandler)); + Client.Network.RegisterCallback(PacketType.PickInfoReply, new NetworkManager.PacketCallback(PickInfoReplyHandler)); // Classifieds callbacks - Client.Network.RegisterCallback(PacketType.AvatarClassifiedReply, new NetworkManager.PacketCallback(AvatarClassifiedsHandler)); - Client.Network.RegisterCallback(PacketType.ClassifiedInfoReply, new NetworkManager.PacketCallback(ClassifiedInfoHandler)); + Client.Network.RegisterCallback(PacketType.AvatarClassifiedReply, new NetworkManager.PacketCallback(AvatarClassifiedReplyHandler)); + Client.Network.RegisterCallback(PacketType.ClassifiedInfoReply, new NetworkManager.PacketCallback(ClassifiedInfoReplyHandler)); } /// Tracks the specified avatar on your map /// Avatar ID to track - public void TrackAvatar(UUID preyID) + public void RequestTrackAgent(UUID preyID) { TrackAgentPacket p = new TrackAgentPacket(); p.AgentData.AgentID = Client.Self.AgentID; @@ -340,7 +560,7 @@ namespace OpenMetaverse public void RequestAvatarProperties(UUID avatarid) { AvatarPropertiesRequestPacket aprp = new AvatarPropertiesRequestPacket(); - + aprp.AgentData.AgentID = Client.Self.AgentID; aprp.AgentData.SessionID = Client.Self.SessionID; aprp.AgentData.AvatarID = avatarid; @@ -349,7 +569,7 @@ namespace OpenMetaverse } /// - /// Search for an avatar (first name, last name, and uuid) + /// Search for an avatar (first name, last name) /// /// The name to search for /// An ID to associate with this query @@ -454,6 +674,7 @@ namespace OpenMetaverse Client.Network.SendPacket(gmp); } + #region Packet Handlers /// @@ -461,9 +682,9 @@ namespace OpenMetaverse /// /// Incoming Packet to process /// Unused - private void AvatarNameHandler(Packet packet, Simulator simulator) + protected void UUIDNameReplyHandler(Packet packet, Simulator simulator) { - if (OnAvatarNames != null) + if (m_UUIDNameReply != null) { Dictionary names = new Dictionary(); UUIDNameReplyPacket reply = (UUIDNameReplyPacket)packet; @@ -473,8 +694,8 @@ namespace OpenMetaverse names[block.ID] = Utils.BytesToString(block.FirstName) + " " + Utils.BytesToString(block.LastName); } - - OnAvatarNames(names); + + OnUUIDNameReply(new UUIDNameReplyEventArgs(names)); } } @@ -483,33 +704,37 @@ namespace OpenMetaverse /// /// /// - private void AvatarAnimationHandler(Packet packet, Simulator sim) + protected void AvatarAnimationHandler(Packet packet, Simulator sim) { - if (OnAvatarAnimation != null) + if (m_AvatarAnimation != null) { - AvatarAnimationPacket anims = (AvatarAnimationPacket)packet; + AvatarAnimationPacket data = (AvatarAnimationPacket)packet; - InternalDictionary signaledAnims = new InternalDictionary(); - - for(int i=0; i < anims.AnimationList.Length; i++) - signaledAnims.Add(anims.AnimationList[i].AnimID, anims.AnimationList[i].AnimSequenceID); + List signaledAnimations = new List(data.AnimationList.Length); - try { OnAvatarAnimation(anims.Sender.ID, signaledAnims); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + for (int i = 0; i < data.AnimationList.Length; i++) + { + Animation animation = new Animation(); + animation.AnimationID = data.AnimationList[i].AnimID; + animation.AnimationSequence = data.AnimationList[i].AnimSequenceID; + animation.AnimationSourceObjectID = data.AnimationSourceList[i].ObjectID; + + signaledAnimations.Add(animation); + } + + OnAvatarAnimation(new AvatarAnimationEventArgs(data.Sender.ID, signaledAnimations)); } } - /// - /// Process incoming avatar appearance - /// - /// - /// - private void AvatarAppearanceHandler(Packet packet, Simulator sim) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void AvatarAppearanceHandler(Packet packet, Simulator simulator) { - if (OnAvatarAppearance != null || Client.Settings.AVATAR_TRACKING) + if (m_AvatarAppearance != null || Client.Settings.AVATAR_TRACKING) { AvatarAppearancePacket appearance = (AvatarAppearancePacket)packet; - sim.ObjectsAvatars.ForEach(delegate(Avatar av) + simulator.ObjectsAvatars.ForEach(delegate(Avatar av) { if (av.ID == appearance.Sender.ID) { @@ -527,24 +752,22 @@ namespace OpenMetaverse av.Textures = textureEntry; - if (OnAvatarAppearance != null) + if (m_AvatarAppearance != null) { - try { OnAvatarAppearance(appearance.Sender.ID, appearance.Sender.IsTrial, defaultTexture, faceTextures, visualParams); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnAvatarAppearance(new AvatarAppearanceEventArgs(appearance.Sender.ID, appearance.Sender.IsTrial, + defaultTexture, faceTextures, visualParams)); } } }); } } - /// - /// Process incoming avatar properties (profile data) - /// - /// - /// - private void AvatarPropertiesHandler(Packet packet, Simulator sim) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void AvatarPropertiesHandler(Packet packet, Simulator simulator) { - if (OnAvatarProperties != null) + if (m_AvatarPropertiesReply != null) { AvatarPropertiesReplyPacket reply = (AvatarPropertiesReplyPacket)packet; Avatar.AvatarProperties properties = new Avatar.AvatarProperties(); @@ -557,28 +780,35 @@ namespace OpenMetaverse properties.BornOn = Utils.BytesToString(reply.PropertiesData.BornOn); //properties.CharterMember = Utils.BytesToString(reply.PropertiesData.CharterMember); uint charter = Utils.BytesToUInt(reply.PropertiesData.CharterMember); - if ( charter == 0 ) { + if (charter == 0) + { properties.CharterMember = "Resident"; - } else if ( charter == 2 ) { + } + else if (charter == 2) + { properties.CharterMember = "Charter"; - } else if ( charter == 3 ) { + } + else if (charter == 3) + { properties.CharterMember = "Linden"; - } else { + } + else + { properties.CharterMember = Utils.BytesToString(reply.PropertiesData.CharterMember); } properties.Flags = (ProfileFlags)reply.PropertiesData.Flags; properties.ProfileURL = Utils.BytesToString(reply.PropertiesData.ProfileURL); - OnAvatarProperties(reply.AgentData.AvatarID, properties); + OnAvatarPropertiesReply(new AvatarPropertiesReplyEventArgs(reply.AgentData.AvatarID, properties)); } } - /// - /// Process incoming Avatar Interests information - /// - private void AvatarInterestsHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void AvatarInterestsHandler(Packet packet, Simulator simulator) { - if (OnAvatarInterests != null) + if (m_AvatarInterestsReply != null) { AvatarInterestsReplyPacket airp = (AvatarInterestsReplyPacket)packet; Avatar.Interests interests = new Avatar.Interests(); @@ -589,18 +819,21 @@ namespace OpenMetaverse interests.SkillsText = Utils.BytesToString(airp.PropertiesData.SkillsText); interests.LanguagesText = Utils.BytesToString(airp.PropertiesData.LanguagesText); - OnAvatarInterests(airp.AgentData.AvatarID, interests); + OnAvatarInterestsReply(new AvatarInterestsReplyEventArgs(airp.AgentData.AvatarID, interests)); } } - private void AvatarGroupsHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void AvatarGroupsReplyHandler(Packet packet, Simulator simulator) { - if (OnAvatarGroups != null) + if (m_AvatarGroupsReply != null) { - + AvatarGroupsReplyPacket groups = (AvatarGroupsReplyPacket)packet; List avatarGroups = new List(groups.GroupData.Length); - + for (int i = 0; i < groups.GroupData.Length; i++) { AvatarGroup avatarGroup = new AvatarGroup(); @@ -616,14 +849,16 @@ namespace OpenMetaverse avatarGroups.Add(avatarGroup); } - try { OnAvatarGroups(groups.AgentData.AvatarID, avatarGroups); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnAvatarGroupsReply(new AvatarGroupsReplyEventArgs(groups.AgentData.AvatarID, avatarGroups)); } } - private void AvatarPickerReplyHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void AvatarPickerReplyHandler(Packet packet, Simulator simulator) { - if (OnAvatarNameSearch != null) + if (m_AvatarPickerReply != null) { AvatarPickerReplyPacket reply = (AvatarPickerReplyPacket)packet; Dictionary avatars = new Dictionary(); @@ -633,16 +868,14 @@ namespace OpenMetaverse avatars[block.AvatarID] = Utils.BytesToString(block.FirstName) + " " + Utils.BytesToString(block.LastName); } - - try { OnAvatarNameSearch(reply.AgentData.QueryID, avatars); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnAvatarPickerReply(new AvatarPickerReplyEventArgs(reply.AgentData.QueryID, avatars)); } } - /// - /// Process an incoming effect - /// - private void ViewerEffectHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void ViewerEffectHandler(Packet packet, Simulator simulator) { ViewerEffectPacket effect = (ViewerEffectPacket)packet; @@ -650,18 +883,6 @@ namespace OpenMetaverse { EffectType type = (EffectType)block.Type; - //Color4 color; - //if (block.Color.Length == 4) - //{ - // color = new Color4(block.Color, 0); - //} - //else - //{ - // Client.Log("Received a ViewerEffect.EffectBlock.Color array with " + block.Color.Length + - // " bytes", Helpers.LogLevel.Warning); - // color = Color4.Black; - //} - // Each ViewerEffect type uses it's own custom binary format for additional data. Fun eh? switch (type) { @@ -703,27 +924,25 @@ namespace OpenMetaverse case EffectType.Sphere: case EffectType.Spiral: case EffectType.Edit: - if (OnEffect != null) + if (m_ViewerEffect != null) { if (block.TypeData.Length == 56) { UUID sourceAvatar = new UUID(block.TypeData, 0); UUID targetObject = new UUID(block.TypeData, 16); Vector3d targetPos = new Vector3d(block.TypeData, 32); - - try { OnEffect(type, sourceAvatar, targetObject, targetPos, block.Duration, block.ID); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnViewerEffect(new ViewerEffectEventArgs(type, sourceAvatar, targetObject, targetPos, block.Duration, block.ID)); } else { - Logger.Log("Received a " + type.ToString() + + Logger.Log("Received a " + type.ToString() + " ViewerEffect with an incorrect TypeData size of " + block.TypeData.Length + " bytes", Helpers.LogLevel.Warning, Client); } } break; case EffectType.LookAt: - if (OnLookAt != null) + if (m_ViewerEffectLookAt != null) { if (block.TypeData.Length == 57) { @@ -732,9 +951,8 @@ namespace OpenMetaverse Vector3d targetPos = new Vector3d(block.TypeData, 32); LookAtType lookAt = (LookAtType)block.TypeData[56]; - try { OnLookAt(sourceAvatar, targetObject, targetPos, lookAt, block.Duration, - block.ID); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnViewerEffectLookAt(new ViewerEffectLookAtEventArgs(sourceAvatar, targetObject, targetPos, lookAt, + block.Duration, block.ID)); } else { @@ -744,7 +962,7 @@ namespace OpenMetaverse } break; case EffectType.PointAt: - if (OnPointAt != null) + if (m_ViewerEffectPointAt != null) { if (block.TypeData.Length == 57) { @@ -753,9 +971,8 @@ namespace OpenMetaverse Vector3d targetPos = new Vector3d(block.TypeData, 32); PointAtType pointAt = (PointAtType)block.TypeData[56]; - try { OnPointAt(sourceAvatar, targetObject, targetPos, pointAt, block.Duration, - block.ID); } - catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } + OnViewerEffectPointAt(new ViewerEffectPointAtEventArgs(sourceAvatar, targetObject, targetPos, + pointAt, block.Duration, block.ID)); } else { @@ -771,89 +988,82 @@ namespace OpenMetaverse } } - /// - /// Process an incoming list of profile picks - /// - private void AvatarPicksHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void AvatarPicksReplyHandler(Packet packet, Simulator simulator) { - if (OnAvatarPicks == null) { + if (m_AvatarPicksReply == null) + { return; } AvatarPicksReplyPacket p = (AvatarPicksReplyPacket)packet; - Dictionary picks = new Dictionary(); + Dictionary picks = new Dictionary(); - foreach (AvatarPicksReplyPacket.DataBlock b in p.Data) { + foreach (AvatarPicksReplyPacket.DataBlock b in p.Data) + { picks.Add(b.PickID, Utils.BytesToString(b.PickName)); } - try { - OnAvatarPicks(p.AgentData.TargetID, picks); - } catch (Exception ex) { - Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); - } + OnAvatarPicksReply(new AvatarPicksReplyEventArgs(p.AgentData.TargetID, picks)); } - /// - /// Process an incoming details of a profile pick - /// - private void PickInfoHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void PickInfoReplyHandler(Packet packet, Simulator simulator) { - if (OnPickInfo == null) { - return; - } - - PickInfoReplyPacket p = (PickInfoReplyPacket)packet; - ProfilePick ret = new ProfilePick(); - ret.CreatorID = p.Data.CreatorID; - ret.Desc = Utils.BytesToString(p.Data.Desc); - ret.Enabled = p.Data.Enabled; - ret.Name = Utils.BytesToString(p.Data.Name); - ret.OriginalName = Utils.BytesToString(p.Data.OriginalName); - ret.ParcelID = p.Data.ParcelID; - ret.PickID = p.Data.PickID; - ret.PosGlobal = p.Data.PosGlobal; - ret.SimName = Utils.BytesToString(p.Data.SimName); - ret.SnapshotID = p.Data.SnapshotID; - ret.SortOrder = p.Data.SortOrder; - ret.TopPick = p.Data.TopPick; - ret.User = Utils.BytesToString(p.Data.User); - - try { - OnPickInfo(ret.PickID, ret); - } catch (Exception ex) { - Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); - } - } - - /// - /// Process an incoming list of profile classifieds - /// - private void AvatarClassifiedsHandler(Packet packet, Simulator simulator) - { - if (OnAvatarClassifieds != null) + if (m_PickInfoReply != null) { - AvatarClassifiedReplyPacket p = (AvatarClassifiedReplyPacket) packet; + PickInfoReplyPacket p = (PickInfoReplyPacket)packet; + ProfilePick ret = new ProfilePick(); + ret.CreatorID = p.Data.CreatorID; + ret.Desc = Utils.BytesToString(p.Data.Desc); + ret.Enabled = p.Data.Enabled; + ret.Name = Utils.BytesToString(p.Data.Name); + ret.OriginalName = Utils.BytesToString(p.Data.OriginalName); + ret.ParcelID = p.Data.ParcelID; + ret.PickID = p.Data.PickID; + ret.PosGlobal = p.Data.PosGlobal; + ret.SimName = Utils.BytesToString(p.Data.SimName); + ret.SnapshotID = p.Data.SnapshotID; + ret.SortOrder = p.Data.SortOrder; + ret.TopPick = p.Data.TopPick; + ret.User = Utils.BytesToString(p.Data.User); + + OnPickInfoReply(new PickInfoReplyEventArgs(ret.PickID, ret)); + } + } + + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void AvatarClassifiedReplyHandler(Packet packet, Simulator simulator) + { + if (m_AvatarClassifiedReply != null) + { + + AvatarClassifiedReplyPacket p = (AvatarClassifiedReplyPacket)packet; Dictionary classifieds = new Dictionary(); - + foreach (AvatarClassifiedReplyPacket.DataBlock b in p.Data) { classifieds.Add(b.ClassifiedID, Utils.BytesToString(b.Name)); } - try { OnAvatarClassifieds(p.AgentData.TargetID, classifieds); } - catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } + OnAvatarClassifiedReply(new AvatarClassifiedReplyEventArgs(p.AgentData.TargetID, classifieds)); } } - /// - /// Process an incoming details of a profile Classified - /// - private void ClassifiedInfoHandler(Packet packet, Simulator simulator) + /// Process an incoming packet + /// The packet containing the data + /// The simulator the packet originated from + protected void ClassifiedInfoReplyHandler(Packet packet, Simulator simulator) { - if (OnClassifiedInfo != null) + if (m_AvatarClassifiedReply != null) { - ClassifiedInfoReplyPacket p = (ClassifiedInfoReplyPacket) packet; + ClassifiedInfoReplyPacket p = (ClassifiedInfoReplyPacket)packet; ClassifiedAd ret = new ClassifiedAd(); ret.Desc = Utils.BytesToString(p.Data.Desc); ret.Name = Utils.BytesToString(p.Data.Name); @@ -866,11 +1076,354 @@ namespace OpenMetaverse ret.ClassifiedFlags = p.Data.ClassifiedFlags; ret.Catagory = p.Data.Category; - try { OnClassifiedInfo(ret.ClassifiedID, ret); } - catch (Exception ex) { Logger.Log(ex.Message, Helpers.LogLevel.Error, Client, ex); } + OnClassifiedInfoReply(new ClassifiedInfoReplyEventArgs(ret.ClassifiedID, ret)); } } #endregion Packet Handlers } + + #region EventArgs + + /// Provides data for the event + /// The event occurs when the simulator sends + /// the animation playlist for an agent + /// + /// The following code example uses the and + /// properties to display the animation playlist of an avatar on the window. + /// + /// // subscribe to the event + /// Client.Avatars.AvatarAnimation += Avatars_AvatarAnimation; + /// + /// private void Avatars_AvatarAnimation(object sender, AvatarAnimationEventArgs e) + /// { + /// // create a dictionary of "known" animations from the Animations class using System.Reflection + /// Dictionary<UUID, string> systemAnimations = new Dictionary<UUID, string>(); + /// Type type = typeof(Animations); + /// System.Reflection.FieldInfo[] fields = type.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static); + /// foreach (System.Reflection.FieldInfo field in fields) + /// { + /// systemAnimations.Add((UUID)field.GetValue(type), field.Name); + /// } + /// + /// // find out which animations being played are known animations and which are assets + /// foreach (Animation animation in e.Animations) + /// { + /// if (systemAnimations.ContainsKey(animation.AnimationID)) + /// { + /// Console.WriteLine("{0} is playing {1} ({2}) sequence {3}", e.AvatarID, + /// systemAnimations[animation.AnimationID], animation.AnimationSequence); + /// } + /// else + /// { + /// Console.WriteLine("{0} is playing {1} (Asset) sequence {2}", e.AvatarID, + /// animation.AnimationID, animation.AnimationSequence); + /// } + /// } + /// } + /// + /// + public class AvatarAnimationEventArgs : EventArgs + { + private readonly UUID m_AvatarID; + private readonly List m_Animations; + + /// Get the ID of the agent + public UUID AvatarID { get { return m_AvatarID; } } + /// Get the list of animations to start + public List Animations { get { return m_Animations; } } + + /// + /// Construct a new instance of the AvatarAnimationEventArgs class + /// + /// The ID of the agent + /// The list of animations to start + public AvatarAnimationEventArgs(UUID avatarID, List anims) + { + this.m_AvatarID = avatarID; + this.m_Animations = anims; + } + } + + /// Provides data for the event + /// The event occurs when the simulator sends + /// the appearance data for an avatar + /// + /// The following code example uses the and + /// properties to display the selected shape of an avatar on the window. + /// + /// // subscribe to the event + /// Client.Avatars.AvatarAppearance += Avatars_AvatarAppearance; + /// + /// // handle the data when the event is raised + /// void Avatars_AvatarAppearance(object sender, AvatarAppearanceEventArgs e) + /// { + /// Console.WriteLine("The Agent {0} is using a {1} shape.", e.AvatarID, (e.VisualParams[31] > 0) : "male" ? "female") + /// } + /// + /// + public class AvatarAppearanceEventArgs : EventArgs + { + + private readonly UUID m_AvatarID; + private readonly bool m_IsTrial; + private readonly Primitive.TextureEntryFace m_DefaultTexture; + private readonly Primitive.TextureEntryFace[] m_FaceTextures; + private readonly List m_VisualParams; + + /// Get the ID of the agent + public UUID AvatarID { get { return m_AvatarID; } } + /// true if the agent is a trial account + public bool IsTrial { get { return m_IsTrial; } } + /// Get the default agent texture + public Primitive.TextureEntryFace DefaultTexture { get { return m_DefaultTexture; } } + /// Get the agents appearance layer textures + public Primitive.TextureEntryFace[] FaceTextures { get { return m_FaceTextures; } } + /// Get the for the agent + public List VisualParams { get { return m_VisualParams; } } + + /// + /// Construct a new instance of the AvatarAppearanceEventArgs class + /// + /// The ID of the agent + /// true of the agent is a trial account + /// The default agent texture + /// The agents appearance layer textures + /// The for the agent + public AvatarAppearanceEventArgs(UUID avatarID, bool isTrial, Primitive.TextureEntryFace defaultTexture, + Primitive.TextureEntryFace[] faceTextures, List visualParams) + { + this.m_AvatarID = avatarID; + this.m_IsTrial = isTrial; + this.m_DefaultTexture = defaultTexture; + this.m_FaceTextures = faceTextures; + this.m_VisualParams = visualParams; + } + } + + /// Represents the interests from the profile of an agent + public class AvatarInterestsReplyEventArgs : EventArgs + { + private readonly UUID m_AvatarID; + private readonly Avatar.Interests m_Interests; + + /// Get the ID of the agent + public UUID AvatarID { get { return m_AvatarID; } } + public Avatar.Interests Interests { get { return m_Interests; } } + + public AvatarInterestsReplyEventArgs(UUID avatarID, Avatar.Interests interests) + { + this.m_AvatarID = avatarID; + this.m_Interests = interests; + } + } + + /// The properties of an agent + public class AvatarPropertiesReplyEventArgs : EventArgs + { + private readonly UUID m_AvatarID; + private readonly Avatar.AvatarProperties m_Properties; + + /// Get the ID of the agent + public UUID AvatarID { get { return m_AvatarID; } } + public Avatar.AvatarProperties Properties { get { return m_Properties; } } + + public AvatarPropertiesReplyEventArgs(UUID avatarID, Avatar.AvatarProperties properties) + { + this.m_AvatarID = avatarID; + this.m_Properties = properties; + } + } + + + public class AvatarGroupsReplyEventArgs : EventArgs + { + private readonly UUID m_AvatarID; + private readonly List m_Groups; + + /// Get the ID of the agent + public UUID AvatarID { get { return m_AvatarID; } } + public List Groups { get { return m_Groups; } } + + public AvatarGroupsReplyEventArgs(UUID avatarID, List avatarGroups) + { + this.m_AvatarID = avatarID; + this.m_Groups = avatarGroups; + } + } + + public class AvatarPicksReplyEventArgs : EventArgs + { + private readonly UUID m_AvatarID; + private readonly Dictionary m_Picks; + + /// Get the ID of the agent + public UUID AvatarID { get { return m_AvatarID; } } + public Dictionary Picks { get { return m_Picks; } } + + public AvatarPicksReplyEventArgs(UUID avatarid, Dictionary picks) + { + this.m_AvatarID = avatarid; + this.m_Picks = picks; + } + } + + public class PickInfoReplyEventArgs : EventArgs + { + private readonly UUID m_PickID; + private readonly ProfilePick m_Pick; + + public UUID PickID { get { return m_PickID; } } + public ProfilePick Pick { get { return m_Pick; } } + + + public PickInfoReplyEventArgs(UUID pickid, ProfilePick pick) + { + this.m_PickID = pickid; + this.m_Pick = pick; + } + } + + public class AvatarClassifiedReplyEventArgs : EventArgs + { + private readonly UUID m_AvatarID; + private readonly Dictionary m_Classifieds; + + /// Get the ID of the avatar + public UUID AvatarID { get { return m_AvatarID; } } + public Dictionary Classifieds { get { return m_Classifieds; } } + + public AvatarClassifiedReplyEventArgs(UUID avatarid, Dictionary classifieds) + { + this.m_AvatarID = avatarid; + this.m_Classifieds = classifieds; + } + } + + public class ClassifiedInfoReplyEventArgs : EventArgs + { + private readonly UUID m_ClassifiedID; + private readonly ClassifiedAd m_Classified; + + public UUID ClassifiedID { get { return m_ClassifiedID; } } + public ClassifiedAd Classified { get { return m_Classified; } } + + + public ClassifiedInfoReplyEventArgs(UUID classifiedID, ClassifiedAd Classified) + { + this.m_ClassifiedID = classifiedID; + this.m_Classified = Classified; + } + } + + public class UUIDNameReplyEventArgs : EventArgs + { + private readonly Dictionary m_Names; + + public Dictionary Names { get { return m_Names; } } + + public UUIDNameReplyEventArgs(Dictionary names) + { + this.m_Names = names; + } + } + + public class AvatarPickerReplyEventArgs : EventArgs + { + private readonly UUID m_QueryID; + private readonly Dictionary m_Avatars; + + public UUID QueryID { get { return m_QueryID; } } + public Dictionary Avatars { get { return m_Avatars; } } + + public AvatarPickerReplyEventArgs(UUID queryID, Dictionary avatars) + { + this.m_QueryID = queryID; + this.m_Avatars = avatars; + } + } + + public class ViewerEffectEventArgs : EventArgs + { + private readonly EffectType m_Type; + private readonly UUID m_SourceID; + private readonly UUID m_TargetID; + private readonly Vector3d m_TargetPosition; + private readonly float m_Duration; + private readonly UUID m_EffectID; + + public EffectType Type { get { return m_Type; } } + public UUID SourceID { get { return m_SourceID; } } + public UUID TargetID { get { return m_TargetID; } } + public Vector3d TargetPosition { get { return m_TargetPosition; } } + public float Duration { get { return m_Duration; } } + public UUID EffectID { get { return m_EffectID; } } + + public ViewerEffectEventArgs(EffectType type, UUID sourceID, UUID targetID, Vector3d targetPos, float duration, UUID id) + { + this.m_Type = type; + this.m_SourceID = sourceID; + this.m_TargetID = targetID; + this.m_TargetPosition = targetPos; + this.m_Duration = duration; + this.m_EffectID = id; + } + } + + public class ViewerEffectPointAtEventArgs : EventArgs + { + private readonly UUID m_SourceID; + private readonly UUID m_TargetID; + private readonly Vector3d m_TargetPosition; + private readonly PointAtType m_PointType; + private readonly float m_Duration; + private readonly UUID m_EffectID; + + + public UUID SourceID { get { return m_SourceID; } } + public UUID TargetID { get { return m_TargetID; } } + public Vector3d TargetPosition { get { return m_TargetPosition; } } + public PointAtType PointType { get { return m_PointType; } } + public float Duration { get { return m_Duration; } } + public UUID EffectID { get { return m_EffectID; } } + + public ViewerEffectPointAtEventArgs(UUID sourceID, UUID targetID, Vector3d targetPos, PointAtType pointType, float duration, UUID id) + { + this.m_SourceID = sourceID; + this.m_TargetID = targetID; + this.m_TargetPosition = targetPos; + this.m_PointType = pointType; + this.m_Duration = duration; + this.m_EffectID = id; + } + } + + public class ViewerEffectLookAtEventArgs : EventArgs + { + private readonly UUID m_SourceID; + private readonly UUID m_TargetID; + private readonly Vector3d m_TargetPosition; + private readonly LookAtType m_LookType; + private readonly float m_Duration; + private readonly UUID m_EffectID; + + + public UUID SourceID { get { return m_SourceID; } } + public UUID TargetID { get { return m_TargetID; } } + public Vector3d TargetPosition { get { return m_TargetPosition; } } + public LookAtType LookType { get { return m_LookType; } } + public float Duration { get { return m_Duration; } } + public UUID EffectID { get { return m_EffectID; } } + + public ViewerEffectLookAtEventArgs(UUID sourceID, UUID targetID, Vector3d targetPos, LookAtType lookType, float duration, UUID id) + { + this.m_SourceID = sourceID; + this.m_TargetID = targetID; + this.m_TargetPosition = targetPos; + this.m_LookType = lookType; + this.m_Duration = duration; + this.m_EffectID = id; + } + } + #endregion } diff --git a/OpenMetaverse/FriendsManager.cs b/OpenMetaverse/FriendsManager.cs index ac4d0496..d32d1bb4 100644 --- a/OpenMetaverse/FriendsManager.cs +++ b/OpenMetaverse/FriendsManager.cs @@ -454,7 +454,7 @@ namespace OpenMetaverse Client = client; Client.Network.OnConnected += new NetworkManager.ConnectedCallback(Network_OnConnect); - Client.Avatars.OnAvatarNames += new AvatarManager.AvatarNamesCallback(Avatars_OnAvatarNames); + Client.Avatars.UUIDNameReply += new EventHandler(Avatars_OnAvatarNames); Client.Self.IM += Self_IM; Client.Network.RegisterCallback(PacketType.OnlineNotification, OnlineNotificationHandler); @@ -467,7 +467,6 @@ namespace OpenMetaverse new string[] { "buddy-list" }); } - #region Public Methods /// @@ -692,12 +691,13 @@ namespace OpenMetaverse /// /// This handles the asynchronous response of a RequestAvatarNames call. /// - /// names cooresponding to the the list of IDs sent the the RequestAvatarNames call. - private void Avatars_OnAvatarNames(Dictionary names) + /// + /// names cooresponding to the the list of IDs sent the the RequestAvatarNames call. + private void Avatars_OnAvatarNames(object sender, UUIDNameReplyEventArgs e) { Dictionary newNames = new Dictionary(); - foreach (KeyValuePair kvp in names) + foreach (KeyValuePair kvp in e.Names) { FriendInfo friend; lock (FriendList.Dictionary) @@ -705,9 +705,9 @@ namespace OpenMetaverse if (FriendList.TryGetValue(kvp.Key, out friend)) { if (friend.Name == null) - newNames.Add(kvp.Key, names[kvp.Key]); + newNames.Add(kvp.Key, e.Names[kvp.Key]); - friend.Name = names[kvp.Key]; + friend.Name = e.Names[kvp.Key]; FriendList[kvp.Key] = friend; } } diff --git a/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs b/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs new file mode 100644 index 00000000..c3022112 --- /dev/null +++ b/Programs/examples/TestClient/Commands/Agent/BotsCommand.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; +using OpenMetaverse.Packets; + +namespace OpenMetaverse.TestClient +{ + public class BotsCommand : Command + { + private Dictionary m_AgentList = new Dictionary(); + + public BotsCommand(TestClient testClient) + { + Name = "bots"; + Description = "detects avatars that appear to be bots."; + Category = CommandCategory.Other; + + testClient.Avatars.ViewerEffect += new EventHandler(Avatars_ViewerEffect); + testClient.Avatars.ViewerEffectLookAt += new EventHandler(Avatars_ViewerEffectLookAt); + testClient.Avatars.ViewerEffectPointAt += new EventHandler(Avatars_ViewerEffectPointAt); + } + + void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e) + { + lock (m_AgentList) + { + if (m_AgentList.ContainsKey(e.SourceID)) + m_AgentList[e.SourceID] = true; + else + m_AgentList.Add(e.SourceID, true); + } + } + + void Avatars_ViewerEffectLookAt(object sender, ViewerEffectLookAtEventArgs e) + { + lock (m_AgentList) + { + if (m_AgentList.ContainsKey(e.SourceID)) + m_AgentList[e.SourceID] = true; + else + m_AgentList.Add(e.SourceID, true); + } + } + + void Avatars_ViewerEffect(object sender, ViewerEffectEventArgs e) + { + lock (m_AgentList) + { + if (m_AgentList.ContainsKey(e.SourceID)) + m_AgentList[e.SourceID] = true; + else + m_AgentList.Add(e.SourceID, true); + } + } + + public override string Execute(string[] args, UUID fromAgentID) + { + StringBuilder result = new StringBuilder(); + + lock (Client.Network.Simulators) + { + for (int i = 0; i < Client.Network.Simulators.Count; i++) + { + Client.Network.Simulators[i].ObjectsAvatars.ForEach( + delegate(Avatar av) + { + lock (m_AgentList) + { + if (!m_AgentList.ContainsKey(av.ID)) + { + result.AppendLine(); + result.AppendFormat("{0} (Group: {1}, Location: {2}, UUID: {3} LocalID: {4}) Is Probably a bot", + av.Name, av.GroupName, av.Position, av.ID, av.LocalID); + } + } + } + ); + } + } + + return result.ToString(); + } + } +} diff --git a/Programs/examples/TestClient/Commands/Agent/CloneProfileCommand.cs b/Programs/examples/TestClient/Commands/Agent/CloneProfileCommand.cs index c4b00d77..9a2e00ce 100644 --- a/Programs/examples/TestClient/Commands/Agent/CloneProfileCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/CloneProfileCommand.cs @@ -18,20 +18,19 @@ namespace OpenMetaverse.TestClient public CloneProfileCommand(TestClient testClient) { - testClient.Avatars.OnAvatarInterests += new AvatarManager.AvatarInterestsCallback(Avatars_OnAvatarInterests); - testClient.Avatars.OnAvatarProperties += new AvatarManager.AvatarPropertiesCallback(Avatars_OnAvatarProperties); - testClient.Avatars.OnAvatarGroups += new AvatarManager.AvatarGroupsCallback(Avatars_OnAvatarGroups); + testClient.Avatars.AvatarInterestsReply += new EventHandler(Avatars_AvatarInterestsReply); + testClient.Avatars.AvatarPropertiesReply += new EventHandler(Avatars_AvatarPropertiesReply); + testClient.Avatars.AvatarGroupsReply += new EventHandler(Avatars_AvatarGroupsReply); testClient.Groups.GroupJoinedReply += new EventHandler(Groups_OnGroupJoined); - - testClient.Avatars.OnAvatarPicks += new AvatarManager.AvatarPicksCallback(Avatars_OnAvatarPicks); - testClient.Avatars.OnPickInfo += new AvatarManager.PickInfoCallback(Avatars_OnPickInfo); + testClient.Avatars.AvatarPicksReply += new EventHandler(Avatars_AvatarPicksReply); + testClient.Avatars.PickInfoReply += new EventHandler(Avatars_PickInfoReply); Name = "cloneprofile"; Description = "Clones another avatars profile as closely as possible. WARNING: This command will " + "destroy your existing profile! Usage: cloneprofile [targetuuid]"; Category = CommandCategory.Other; - } - + } + public override string Execute(string[] args, UUID fromAgentID) { if (args.Length != 1) @@ -80,67 +79,7 @@ namespace OpenMetaverse.TestClient } return "Synchronized our profile to the profile of " + targetID.ToString(); - } - - void Avatars_OnAvatarPicks(UUID avatarid, Dictionary picks) - { - foreach (KeyValuePair kvp in picks) - { - if (avatarid == Client.Self.AgentID) - { - Client.Self.PickDelete(kvp.Key); - } - else - { - Client.Avatars.RequestPickInfo(avatarid, kvp.Key); - } - } - } - - void Avatars_OnPickInfo(UUID pickid, ProfilePick pick) - { - Client.Self.PickInfoUpdate(pickid, pick.TopPick, pick.ParcelID, pick.Name, pick.PosGlobal, pick.SnapshotID, pick.Desc); - } - - void Avatars_OnAvatarProperties(UUID avatarID, Avatar.AvatarProperties properties) - { - lock (ReceivedProfileEvent) - { - Properties = properties; - ReceivedProperties = true; - - if (ReceivedInterests && ReceivedProperties && ReceivedGroups) - ReceivedProfileEvent.Set(); - } - } - - void Avatars_OnAvatarInterests(UUID avatarID, Avatar.Interests interests) - { - lock (ReceivedProfileEvent) - { - Interests = interests; - ReceivedInterests = true; - - if (ReceivedInterests && ReceivedProperties && ReceivedGroups) - ReceivedProfileEvent.Set(); - } - } - - void Avatars_OnAvatarGroups(UUID avatarID, List groups) - { - lock (ReceivedProfileEvent) - { - foreach (AvatarGroup group in groups) - { - Groups.Add(group.GroupID); - } - - ReceivedGroups = true; - - if (ReceivedInterests && ReceivedProperties && ReceivedGroups) - ReceivedProfileEvent.Set(); - } - } + } void Groups_OnGroupJoined(object sender, GroupOperationEventArgs e) { @@ -154,5 +93,67 @@ namespace OpenMetaverse.TestClient Client.Groups.ActivateGroup(e.GroupID); } } + + void Avatars_PickInfoReply(object sender, PickInfoReplyEventArgs e) + { + Client.Self.PickInfoUpdate(e.PickID, e.Pick.TopPick, e.Pick.ParcelID, e.Pick.Name, e.Pick.PosGlobal, e.Pick.SnapshotID, e.Pick.Desc); + } + + void Avatars_AvatarPicksReply(object sender, AvatarPicksReplyEventArgs e) + { + foreach (KeyValuePair kvp in e.Picks) + { + if (e.AvatarID == Client.Self.AgentID) + { + Client.Self.PickDelete(kvp.Key); + } + else + { + Client.Avatars.RequestPickInfo(e.AvatarID, kvp.Key); + } + } + } + + void Avatars_AvatarGroupsReply(object sender, AvatarGroupsReplyEventArgs e) + { + lock (ReceivedProfileEvent) + { + foreach (AvatarGroup group in e.Groups) + { + Groups.Add(group.GroupID); + } + + ReceivedGroups = true; + + if (ReceivedInterests && ReceivedProperties && ReceivedGroups) + ReceivedProfileEvent.Set(); + } + } + + void Avatars_AvatarPropertiesReply(object sender, AvatarPropertiesReplyEventArgs e) + { + lock (ReceivedProfileEvent) + { + Properties = e.Properties; + ReceivedProperties = true; + + if (ReceivedInterests && ReceivedProperties && ReceivedGroups) + ReceivedProfileEvent.Set(); + } + } + + void Avatars_AvatarInterestsReply(object sender, AvatarInterestsReplyEventArgs e) + { + lock (ReceivedProfileEvent) + { + Interests = e.Interests; + ReceivedInterests = true; + + if (ReceivedInterests && ReceivedProperties && ReceivedGroups) + ReceivedProfileEvent.Set(); + } + } + + } } diff --git a/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs b/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs new file mode 100644 index 00000000..327ccc56 --- /dev/null +++ b/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs @@ -0,0 +1,90 @@ +using System; +using System.Text; +using System.Reflection; +using System.Collections.Generic; +using OpenMetaverse; +using OpenMetaverse.Packets; + +namespace OpenMetaverse.TestClient +{ + public class PlayAnimationCommand : Command + { + private Dictionary m_BuiltInAnimations = new Dictionary(); + public PlayAnimationCommand(TestClient testClient) + { + Name = "play"; + Description = "Attempts to play an animation"; + Category = CommandCategory.Appearance; + + Type t = typeof(Animations); + FieldInfo[] f = t.GetFields(BindingFlags.Public | BindingFlags.Static); + foreach (FieldInfo field in f) + { + m_BuiltInAnimations.Add((UUID)field.GetValue(t), field.Name); + } + Console.WriteLine(f); + } + + private string Usage() + { + String usage = "Usage:\n" + + "\tplay list - list the built in animations\n" + + "\tplay show - show any currently playing animations\n" + + "\tplay UUID - play an animation asset\n" + + "\tplay ANIMATION - where ANIMATION is one of the values returned from \"play list\"\n"; + return usage; + } + + public override string Execute(string[] args, UUID fromAgentID) + { + StringBuilder result = new StringBuilder(); + if (args.Length != 1) + return Usage(); + + UUID animationID; + string arg = args[0].Trim(); + + if (UUID.TryParse(args[0], out animationID)) + { + Client.Self.AnimationStart(animationID, true); + } + else if (arg.ToLower().Equals("list")) + { + foreach (string key in m_BuiltInAnimations.Values) + { + result.AppendLine(key); + } + } + else if (arg.ToLower().Equals("show")) + { + Client.Self.SignaledAnimations.ForEach(delegate(KeyValuePair kvp) { + if (m_BuiltInAnimations.ContainsKey(kvp.Key)) + { + result.AppendFormat("The {0} System Animation is being played, sequence is {1}", m_BuiltInAnimations[kvp.Key], kvp.Value); + } + else + { + result.AppendFormat("The {0} Asset Animation is being played, sequence is {0}", kvp.Key, kvp.Value); + } + }); + } + else if (m_BuiltInAnimations.ContainsValue(args[0].Trim().ToUpper())) + { + foreach (var kvp in m_BuiltInAnimations) + { + if (kvp.Value.Equals(arg.ToUpper())) + { + Client.Self.AnimationStart(kvp.Key, true); + break; + } + } + } + else + { + return Usage(); + } + + return result.ToString(); + } + } +} diff --git a/Programs/examples/TestClient/Commands/Communication/IMCommand.cs b/Programs/examples/TestClient/Commands/Communication/IMCommand.cs index b0478aa4..ab9d3e0d 100644 --- a/Programs/examples/TestClient/Commands/Communication/IMCommand.cs +++ b/Programs/examples/TestClient/Commands/Communication/IMCommand.cs @@ -14,13 +14,13 @@ namespace OpenMetaverse.TestClient public ImCommand(TestClient testClient) { - testClient.Avatars.OnAvatarNameSearch += new AvatarManager.AvatarNameSearchCallback(Avatars_OnAvatarNameSearch); + testClient.Avatars.AvatarPickerReply += Avatars_AvatarPickerReply; Name = "im"; Description = "Instant message someone. Usage: im [firstname] [lastname] [message]"; Category = CommandCategory.Communication; } - + public override string Execute(string[] args, UUID fromAgentID) { if (args.Length < 3) @@ -56,9 +56,9 @@ namespace OpenMetaverse.TestClient } } - void Avatars_OnAvatarNameSearch(UUID queryID, Dictionary avatars) + void Avatars_AvatarPickerReply(object sender, AvatarPickerReplyEventArgs e) { - foreach (KeyValuePair kvp in avatars) + foreach (KeyValuePair kvp in e.Avatars) { if (kvp.Value.ToLower() == ToAvatarName.ToLower()) { diff --git a/Programs/examples/TestClient/Commands/Directory/Key2NameCommand.cs b/Programs/examples/TestClient/Commands/Directory/Key2NameCommand.cs index 3df133b9..a2839dab 100644 --- a/Programs/examples/TestClient/Commands/Directory/Key2NameCommand.cs +++ b/Programs/examples/TestClient/Commands/Directory/Key2NameCommand.cs @@ -28,7 +28,7 @@ namespace OpenMetaverse.TestClient.Commands result.Remove(0, result.Length); waitQuery.Reset(); - Client.Avatars.OnAvatarNames += Avatars_OnAvatarNames; + Client.Avatars.UUIDNameReply += Avatars_OnAvatarNames; Client.Groups.GroupProfile += Groups_OnGroupProfile; Client.Avatars.RequestAvatarName(key); @@ -38,7 +38,7 @@ namespace OpenMetaverse.TestClient.Commands result.AppendLine("Timeout waiting for reply, this could mean the Key is not an avatar or a group"); } - Client.Avatars.OnAvatarNames -= Avatars_OnAvatarNames; + Client.Avatars.UUIDNameReply -= Avatars_OnAvatarNames; Client.Groups.GroupProfile -= Groups_OnGroupProfile; return result.ToString(); } @@ -49,9 +49,9 @@ namespace OpenMetaverse.TestClient.Commands waitQuery.Set(); } - void Avatars_OnAvatarNames(Dictionary names) + void Avatars_OnAvatarNames(object sender, UUIDNameReplyEventArgs e) { - foreach (KeyValuePair kvp in names) + foreach (KeyValuePair kvp in e.Names) result.AppendLine("Avatar: " + kvp.Value + " " + kvp.Key); waitQuery.Set(); } diff --git a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs index dd3cc310..d51dc74e 100644 --- a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs @@ -23,13 +23,22 @@ namespace OpenMetaverse.TestClient { testClient.Objects.OnObjectPropertiesFamily += new ObjectManager.ObjectPropertiesFamilyCallback(Objects_OnObjectPropertiesFamily); testClient.Objects.OnObjectProperties += new ObjectManager.ObjectPropertiesCallback(Objects_OnObjectProperties); - testClient.Avatars.OnPointAt += new AvatarManager.PointAtCallback(Avatars_OnPointAt); + testClient.Avatars.ViewerEffectPointAt += new EventHandler(Avatars_ViewerEffectPointAt); Name = "export"; Description = "Exports an object to an xml file. Usage: export uuid outputfile.xml"; Category = CommandCategory.Objects; } + void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e) + { + if (e.SourceID == Client.MasterKey) + { + //Client.DebugLog("Master is now selecting " + targetID.ToString()); + SelectedObject = e.TargetID; + } + } + public override string Execute(string[] args, UUID fromAgentID) { if (args.Length != 2 && !(args.Length == 1 && SelectedObject != UUID.Zero)) @@ -211,16 +220,6 @@ namespace OpenMetaverse.TestClient } } - void Avatars_OnPointAt(UUID sourceID, UUID targetID, Vector3d targetPos, - PointAtType pointType, float duration, UUID id) - { - if (sourceID == Client.MasterKey) - { - //Client.DebugLog("Master is now selecting " + targetID.ToString()); - SelectedObject = targetID; - } - } - void Objects_OnObjectPropertiesFamily(Simulator simulator, Primitive.ObjectProperties properties, ReportType type) { diff --git a/Programs/examples/TestClient/Commands/System/ShowEffectsCommand.cs b/Programs/examples/TestClient/Commands/System/ShowEffectsCommand.cs index da46ff37..0c68a3a5 100644 --- a/Programs/examples/TestClient/Commands/System/ShowEffectsCommand.cs +++ b/Programs/examples/TestClient/Commands/System/ShowEffectsCommand.cs @@ -13,9 +13,36 @@ namespace OpenMetaverse.TestClient Description = "Prints out information for every viewer effect that is received. Usage: showeffects [on/off]"; Category = CommandCategory.Other; - testClient.Avatars.OnEffect += new AvatarManager.EffectCallback(Avatars_OnEffect); - testClient.Avatars.OnLookAt += new AvatarManager.LookAtCallback(Avatars_OnLookAt); - testClient.Avatars.OnPointAt += new AvatarManager.PointAtCallback(Avatars_OnPointAt); + testClient.Avatars.ViewerEffect += new EventHandler(Avatars_ViewerEffect); + testClient.Avatars.ViewerEffectPointAt += new EventHandler(Avatars_ViewerEffectPointAt); + testClient.Avatars.ViewerEffectLookAt += new EventHandler(Avatars_ViewerEffectLookAt); + } + + void Avatars_ViewerEffectLookAt(object sender, ViewerEffectLookAtEventArgs e) + { + if (ShowEffects) + Console.WriteLine( + "ViewerEffect [LookAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}", + e.SourceID.ToString(), e.TargetID.ToString(), e.TargetPosition, e.LookType, e.Duration, + e.EffectID.ToString()); + } + + void Avatars_ViewerEffectPointAt(object sender, ViewerEffectPointAtEventArgs e) + { + if (ShowEffects) + Console.WriteLine( + "ViewerEffect [PointAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}", + e.SourceID.ToString(), e.TargetID.ToString(), e.TargetPosition, e.PointType, e.Duration, + e.EffectID.ToString()); + } + + void Avatars_ViewerEffect(object sender, ViewerEffectEventArgs e) + { + if (ShowEffects) + Console.WriteLine( + "ViewerEffect [{0}]: SourceID: {1} TargetID: {2} TargetPos: {3} Duration: {4} ID: {5}", + e.Type, e.SourceID.ToString(), e.TargetID.ToString(), e.TargetPosition, e.Duration, + e.EffectID.ToString()); } public override string Execute(string[] args, UUID fromAgentID) @@ -42,36 +69,7 @@ namespace OpenMetaverse.TestClient { return "Usage: showeffects [on/off]"; } - } + } - private void Avatars_OnPointAt(UUID sourceID, UUID targetID, Vector3d targetPos, - PointAtType pointType, float duration, UUID id) - { - if (ShowEffects) - Console.WriteLine( - "ViewerEffect [PointAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}", - sourceID.ToString(), targetID.ToString(), targetPos, pointType, duration, - id.ToString()); - } - - private void Avatars_OnLookAt(UUID sourceID, UUID targetID, Vector3d targetPos, - LookAtType lookType, float duration, UUID id) - { - if (ShowEffects) - Console.WriteLine( - "ViewerEffect [LookAt]: SourceID: {0} TargetID: {1} TargetPos: {2} Type: {3} Duration: {4} ID: {5}", - sourceID.ToString(), targetID.ToString(), targetPos, lookType, duration, - id.ToString()); - } - - private void Avatars_OnEffect(EffectType type, UUID sourceID, UUID targetID, - Vector3d targetPos, float duration, UUID id) - { - if (ShowEffects) - Console.WriteLine( - "ViewerEffect [{0}]: SourceID: {1} TargetID: {2} TargetPos: {3} Duration: {4} ID: {5}", - type, sourceID.ToString(), targetID.ToString(), targetPos, duration, - id.ToString()); - } } } diff --git a/Programs/examples/groupmanager/frmGroupInfo.Designer.cs b/Programs/examples/groupmanager/frmGroupInfo.Designer.cs index 6cf70884..9bb6c9d8 100644 --- a/Programs/examples/groupmanager/frmGroupInfo.Designer.cs +++ b/Programs/examples/groupmanager/frmGroupInfo.Designer.cs @@ -30,6 +30,7 @@ namespace groupmanager { this.tabs = new System.Windows.Forms.TabControl(); this.tabGeneral = new System.Windows.Forms.TabPage(); + this.labelInsigniaProgress = new System.Windows.Forms.Label(); this.grpPreferences = new System.Windows.Forms.GroupBox(); this.chkMature = new System.Windows.Forms.CheckBox(); this.numFee = new System.Windows.Forms.NumericUpDown(); @@ -93,7 +94,6 @@ namespace groupmanager this.cmdCancel = new System.Windows.Forms.Button(); this.cmdOK = new System.Windows.Forms.Button(); this.cmdRefresh = new System.Windows.Forms.Button(); - this.labelInsigniaProgress = new System.Windows.Forms.Label(); this.tabs.SuspendLayout(); this.tabGeneral.SuspendLayout(); this.grpPreferences.SuspendLayout(); @@ -140,6 +140,15 @@ namespace groupmanager this.tabGeneral.Text = "General"; this.tabGeneral.UseVisualStyleBackColor = true; // + // labelInsigniaProgress + // + this.labelInsigniaProgress.AutoSize = true; + this.labelInsigniaProgress.Location = new System.Drawing.Point(23, 149); + this.labelInsigniaProgress.Name = "labelInsigniaProgress"; + this.labelInsigniaProgress.Size = new System.Drawing.Size(54, 13); + this.labelInsigniaProgress.TabIndex = 7; + this.labelInsigniaProgress.Text = "Loading..."; + // // grpPreferences // this.grpPreferences.Controls.Add(this.chkMature); @@ -716,16 +725,7 @@ namespace groupmanager this.cmdRefresh.Size = new System.Drawing.Size(121, 23); this.cmdRefresh.TabIndex = 13; this.cmdRefresh.Text = "Refresh from server"; - this.cmdRefresh.UseVisualStyleBackColor = true; - // - // labelInsigniaProgress - // - this.labelInsigniaProgress.AutoSize = true; - this.labelInsigniaProgress.Location = new System.Drawing.Point(23, 149); - this.labelInsigniaProgress.Name = "labelInsigniaProgress"; - this.labelInsigniaProgress.Size = new System.Drawing.Size(54, 13); - this.labelInsigniaProgress.TabIndex = 7; - this.labelInsigniaProgress.Text = "Loading..."; + this.cmdRefresh.UseVisualStyleBackColor = true; // // frmGroupInfo // diff --git a/Programs/examples/groupmanager/frmGroupInfo.cs b/Programs/examples/groupmanager/frmGroupInfo.cs index 4d92147e..124b8fb8 100644 --- a/Programs/examples/groupmanager/frmGroupInfo.cs +++ b/Programs/examples/groupmanager/frmGroupInfo.cs @@ -24,7 +24,7 @@ namespace groupmanager EventHandler GroupProfileCallback; EventHandler GroupMembersCallback; EventHandler GroupTitlesCallback; - AvatarManager.AvatarNamesCallback AvatarNamesCallback; + EventHandler AvatarNamesCallback; public frmGroupInfo(Group group, GridClient client) { @@ -40,7 +40,7 @@ namespace groupmanager GroupMembersCallback = new EventHandler(GroupMembersHandler); GroupProfileCallback = new EventHandler(GroupProfileHandler); GroupTitlesCallback = new EventHandler(GroupTitlesHandler); - AvatarNamesCallback = new AvatarManager.AvatarNamesCallback(AvatarNamesHandler); + AvatarNamesCallback = new EventHandler(AvatarNamesHandler); Group = group; Client = client; @@ -49,7 +49,7 @@ namespace groupmanager Client.Groups.GroupProfile += GroupProfileCallback; Client.Groups.GroupMembersReply += GroupMembersCallback; Client.Groups.GroupTitlesReply += GroupTitlesCallback; - Client.Avatars.OnAvatarNames += AvatarNamesCallback; + Client.Avatars.UUIDNameReply += AvatarNamesCallback; // Request the group information Client.Groups.RequestGroupProfile(Group.ID); @@ -63,7 +63,7 @@ namespace groupmanager Client.Groups.GroupProfile -= GroupProfileCallback; Client.Groups.GroupMembersReply -= GroupMembersCallback; Client.Groups.GroupTitlesReply -= GroupTitlesCallback; - Client.Avatars.OnAvatarNames -= AvatarNamesCallback; + Client.Avatars.UUIDNameReply -= AvatarNamesCallback; } private void GroupProfileHandler(object sender, GroupProfileEventArgs e) @@ -120,11 +120,11 @@ namespace groupmanager Client.Avatars.RequestAvatarName(Profile.FounderID); } - private void AvatarNamesHandler(Dictionary names) + private void AvatarNamesHandler(object sender, UUIDNameReplyEventArgs e) { lock (Names) { - foreach (KeyValuePair agent in names) + foreach (KeyValuePair agent in e.Names) { Names[agent.Key] = agent.Value; }