Skip to content

Commit

Permalink
Handle AvatarNotesReply packet
Browse files Browse the repository at this point in the history
  • Loading branch information
cinderblocks committed Sep 17, 2021
1 parent 423ecae commit de61c63
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions LibreMetaverse/AvatarManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,29 @@ public event EventHandler<AvatarInterestsReplyEventArgs> AvatarInterestsReply
remove { lock (m_AvatarInterestsReplyLock) { m_AvatarInterestsReply -= value; } }
}

/// <summary>The event subscribers, null of no subscribers</summary>
private EventHandler<AvatarNotesReplyEventArgs> m_AvatarNotesReply;

///<summary>Raises the AvatarNotesReply Event</summary>
/// <param name="e">A AvatarNotesReplyEventArgs object containing
/// the data sent from the simulator</param>
protected virtual void OnAvatarNotesReply(AvatarNotesReplyEventArgs e)
{
EventHandler<AvatarNotesReplyEventArgs> handler = m_AvatarNotesReply;
handler?.Invoke(this, e);
}

/// <summary>Thread sync lock object</summary>
private readonly object m_AvatarNotesReplyLock = new object();

/// <summary>Raised when the simulator sends us data containing
/// the private notes listed in an agents profile</summary>
public event EventHandler<AvatarNotesReplyEventArgs> AvatarNotesReply
{
add { lock (m_AvatarNotesReplyLock) { m_AvatarNotesReply += value; } }
remove { lock (m_AvatarNotesReplyLock) { m_AvatarNotesReply -= value; } }
}

/// <summary>The event subscribers, null of no subscribers</summary>
private EventHandler<AvatarPropertiesReplyEventArgs> m_AvatarPropertiesReply;

Expand Down Expand Up @@ -561,6 +584,7 @@ public AvatarManager(GridClient client)
Client.Network.RegisterCallback(PacketType.AvatarPropertiesReply, AvatarPropertiesHandler);
// Client.Network.RegisterCallback(PacketType.AvatarStatisticsReply, AvatarStatisticsHandler);
Client.Network.RegisterCallback(PacketType.AvatarInterestsReply, AvatarInterestsHandler);
Client.Network.RegisterCallback(PacketType.AvatarNotesReply, AvatarNotesHandler);

// Avatar group callback
Client.Network.RegisterCallback(PacketType.AvatarGroupsReply, AvatarGroupsReplyHandler);
Expand Down Expand Up @@ -1038,6 +1062,19 @@ protected void AvatarInterestsHandler(object sender, PacketReceivedEventArgs e)
}
}

protected void AvatarNotesHandler(object sender, PacketReceivedEventArgs e)
{
if (m_AvatarNotesReply != null)
{
Packet packet = e.Packet;
AvatarNotesReplyPacket anrp = (AvatarNotesReplyPacket)packet;
UUID target = anrp.Data.TargetID;
string notes = Utils.BytesToString(anrp.Data.Notes);

OnAvatarNotesReply(new AvatarNotesReplyEventArgs(anrp.Data.TargetID, notes));
}
}

/// <summary>
/// EQ Message fired when someone nearby changes their display name
/// </summary>
Expand Down Expand Up @@ -1492,6 +1529,22 @@ public AvatarInterestsReplyEventArgs(UUID avatarID, Avatar.Interests interests)
}
}

/// <summary>Represents the private notes from the profile of an agent</summary>
public class AvatarNotesReplyEventArgs : EventArgs
{
/// <summary>Get the ID of the agent</summary>
public UUID AvatarID { get; }

/// <summary>Get the interests of the agent</summary>
public string Notes { get; }

public AvatarNotesReplyEventArgs(UUID avatarID, string notes)
{
this.AvatarID = avatarID;
this.Notes = notes;
}
}

/// <summary>The properties of an agent</summary>
public class AvatarPropertiesReplyEventArgs : EventArgs
{
Expand Down

0 comments on commit de61c63

Please sign in to comment.