Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
fuss:libopenmetaverse [2015/01/05 23:46] – [Extract Full Avatar Name] officefuss:libopenmetaverse [2022/04/19 08:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
-======== Role UUID to Name ======== +====== Extract Full Avatar Name ======
- +
-<code csharp> +
-/////////////////////////////////////////////////////////////////////////// +
-//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    // +
-/////////////////////////////////////////////////////////////////////////// +
-/// <summary> +
-/// Resolves a role name to a role UUID. +
-/// </summary> +
-/// <param name="RoleUUID">the UUID of the role to be resolved to a name</param> +
-/// <param name="GroupUUID">the UUID of the group to query for the role name</param> +
-/// <param name="millisecondsTimeout">timeout for the search in milliseconds</param> +
-/// <param name="roleName">a string object to store the role name in</param> +
-/// <returns>true if the role could be resolved</returns> +
-private static bool RoleUUIDToName(UUID RoleUUID, UUID GroupUUID, int millisecondsTimeout, ref string roleName) +
-+
-    string localRoleName = roleName; +
-    var GroupRoleDataEvent = new ManualResetEvent(false); +
-    EventHandler<GroupRolesDataReplyEventArgs> GroupRoleDataReplyDelegate = (o, s) => +
-    { +
-        foreach (var kvp in s.Roles.Where(kvp => kvp.Key.Equals(RoleUUID))) { localRoleName = kvp.Value.Name;+
-        GroupRoleDataEvent.Set(); +
-    }; +
-    Client.Groups.GroupRoleDataReply += GroupRoleDataReplyDelegate; +
-    Client.Groups.RequestGroupRoles(GroupUUID); +
-    if (GroupRoleDataEvent.WaitOne(millisecondsTimeout, false)) +
-    { +
-        Client.Groups.GroupRoleDataReply -= GroupRoleDataReplyDelegate; +
-        return false; +
-    } +
-    Client.Groups.GroupRoleDataReply -= GroupRoleDataReplyDelegate; +
-    roleName = localRoleName; +
-    return true; +
-+
-</code> +
- +
-======== Role Name to Role UUID ======== +
-<code csharp> +
-/////////////////////////////////////////////////////////////////////////// +
-//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    // +
-/////////////////////////////////////////////////////////////////////////// +
-/// <summary> +
-/// Resolves a role name to a role UUID. +
-/// </summary> +
-/// <param name="roleName">the name of the role to be resolved to an UUID</param> +
-/// <param name="groupUUID">the UUID of the group to query for the role UUID</param> +
-/// <param name="millisecondsTimeout">timeout for the search in milliseconds</param> +
-/// <param name="roleUUID">an UUID object to store the role UUID in</param> +
-/// <returns>true if the role could be found</returns> +
-private static bool RoleNameToRoleUUID(string roleName, UUID groupUUID, int millisecondsTimeout, ref UUID roleUUID) { +
-    var localRoleUUID = roleUUID; +
-    var GroupRoleDataEvent = new ManualResetEvent(false); +
-    EventHandler<GroupRolesDataReplyEventArgs> GroupRoleDataReplyDelegate = (o, s) => { +
-        foreach(var kvp in s.Roles.Where(kvp => kvp.Value.Name.Equals(roleName))) { +
-            localRoleUUID = kvp.Key; +
-        } +
-        GroupRoleDataEvent.Set(); +
-    }; +
-    roleUUID = localRoleUUID; +
-    Client.Groups.GroupRoleDataReply += GroupRoleDataReplyDelegate; +
-    Client.Groups.RequestGroupRoles(groupUUID); +
-    if(!GroupRoleDataEvent.WaitOne(millisecondsTimeout, false)) { +
-        Client.Groups.GroupRoleDataReply -= GroupRoleDataReplyDelegate; +
-        return false; +
-    } +
-    Client.Groups.GroupRoleDataReply -= GroupRoleDataReplyDelegate; +
-    return true; +
-+
-</code> +
- +
-======== Determine if an Agent is in a Group ======== +
- +
-<code csharp> +
-/////////////////////////////////////////////////////////////////////////// +
-//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    // +
-/////////////////////////////////////////////////////////////////////////// +
-/// <summary> +
-/// Determines whether an agent referenced by an UUID is in a group  +
-/// referenced by an UUID. +
-/// </summary> +
-/// <param name="AgentUUID">the UUID of the agent</param> +
-/// <param name="GroupUUID">the UUID of the groupt</param> +
-/// <param name="millisecondsTimeout">timeout for the search in milliseconds</param> +
-/// <returns>true if the agent is in the group and false otherwise</returns> +
-private static bool AgentInGroup(UUID AgentUUID, UUID GroupUUID, int millisecondsTimeout) { +
-    var agentInGroup = false; +
-    var GroupsEvent = new ManualResetEvent(false); +
-    EventHandler<GroupMembersReplyEventArgs> HandleGroupMembersReplyDelegate = (o, s) => { +
-        if (s.Members.Any(kvp => kvp.Key.Equals(AgentUUID))) { agentInGroup = true; } +
-        GroupsEvent.Set(); +
-    }; +
-    Client.Groups.GroupMembersReply += HandleGroupMembersReplyDelegate; +
-    Client.Groups.RequestGroupMembers(GroupUUID); +
-    GroupsEvent.WaitOne(millisecondsTimeout, false); +
-    Client.Groups.GroupMembersReply -= HandleGroupMembersReplyDelegate; +
-    return agentInGroup; +
-+
-</code> +
- +
-======== Agent UUID to Name ======== +
- +
-<code csharp> +
-/////////////////////////////////////////////////////////////////////////// +
-//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    // +
-/////////////////////////////////////////////////////////////////////////// +
-/// <summary> +
-/// Resolves an agent UUID to an agent name. +
-/// </summary> +
-/// <param name="agentUUID">the UUID of the agent</param> +
-/// <param name="millisecondsTimeout">timeout for the search in milliseconds</param> +
-/// <param name="agentName">an object to store the name of the agent in</param> +
-/// <returns>true if the UUID could be resolved to a name</returns> +
-private static bool AgentUUIDToName(UUID agentUUID, int millisecondsTimeout, ref string agentName) { +
-    var localAgentName = agentName; +
-    var agentNameEvent = new ManualResetEvent(false); +
-    EventHandler<UUIDNameReplyEventArgs> UUIDNameReplyDelegate = (o, s) => { +
-        foreach(var agent in s.Names.Where(kvp => !kvp.Value.Equals(string.Empty))) { +
-            localAgentName = agent.Value; +
-        } +
-        agentNameEvent.Set(); +
-    }; +
-    Client.Avatars.UUIDNameReply += UUIDNameReplyDelegate; +
-    Client.Avatars.RequestAvatarName(agentUUID); +
-    if(!agentNameEvent.WaitOne(millisecondsTimeout, false)) { +
-        Client.Avatars.UUIDNameReply -= UUIDNameReplyDelegate; +
-        return false; +
-    } +
-    Client.Avatars.UUIDNameReply -= UUIDNameReplyDelegate; +
-    agentName = localAgentName; +
-    return true; +
-+
-</code> +
- +
-======== Agent Name to UUID ======== +
- +
-<code csharp> +
-/////////////////////////////////////////////////////////////////////////// +
-//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    // +
-/////////////////////////////////////////////////////////////////////////// +
-/// <summary> +
-/// Resolves an agent name to an agent UUID by searching the directory  +
-/// services. +
-/// </summary> +
-/// <param name="agentFirstName">the first name of the agent</param> +
-/// <param name="agentLastName">the last name of the agent</param> +
-/// <param name="millisecondsTimeout">timeout for the search in milliseconds</param> +
-/// <param name="agentUUID">an object to store the agent UUID</param> +
-/// <returns>true if the agent name could be resolved to an UUID</returns> +
-private static bool AgentNameToUUID(string agentFirstName, string agentLastName, int millisecondsTimeout, ref UUID agentUUID) { +
-    var localAgentUUID = agentUUID; +
-    var agentUUIDEvent = new ManualResetEvent(false); +
-    EventHandler<DirPeopleReplyEventArgs> DirPeopleReplyDelegate = (o, s) => { +
-        Parallel.ForEach(s.MatchedPeople.Where(match => match.FirstName.Equals(agentFirstName) && match.LastName.Equals(agentLastName)), match => { localAgentUUID = match.AgentID; }); +
-        agentUUIDEvent.Set(); +
-    }; +
-    Client.Directory.DirPeopleReply += DirPeopleReplyDelegate; +
-    Client.Directory.StartPeopleSearch(String.Format(CultureInfo.InvariantCulture, "{0} {1}", agentFirstName, agentLastName), 0); +
-    if(!agentUUIDEvent.WaitOne(millisecondsTimeout, false)) { +
-        Client.Directory.DirPeopleReply -= DirPeopleReplyDelegate; +
-        return false; +
-    } +
-    Client.Directory.DirPeopleReply -= DirPeopleReplyDelegate; +
-    agentUUID = localAgentUUID; +
-    return true; +
-+
-</code> +
- +
- +
-======== Group UUID to Name ======== +
- +
-Performed by concurrently searching current groups and the directory and accepting whichever answer comes first. +
- +
-<code csharp> +
-/////////////////////////////////////////////////////////////////////////// +
-//    Copyright (C) 2013 Wizardry and Steamworks - License: GNU GPLv3    // +
-/////////////////////////////////////////////////////////////////////////// +
-/// <summary> +
-/// Resolves a group UUID. +
-/// </summary> +
-/// <param name="groupUUID">the UUID of the group</param> +
-/// <param name="millisecondsTimeout">timeout for the search in milliseconds</param> +
-/// <param name="groupName">an object to store the group name in</param> +
-/// <returns>true if the group UUID could be resolved to a name</returns> +
-private static bool GroupUUIDToName(UUID groupUUID, int millisecondsTimeout, ref string groupName) { +
-    var localGroupName = groupName; +
-    var GroupNameEvent = new ManualResetEvent(false); +
-    EventHandler<GroupProfileEventArgs> GroupProfileDelegate = (o, s) => { +
-        localGroupName = s.Group.Name; +
-        GroupNameEvent.Set(); +
-    }; +
-    Client.Groups.GroupProfile += GroupProfileDelegate; +
-    Client.Groups.RequestGroupProfile(groupUUID); +
-    if(!GroupNameEvent.WaitOne(millisecondsTimeout, false)) { +
-        Client.Groups.GroupProfile -= GroupProfileDelegate; +
-        return false; +
-    } +
-    Client.Groups.GroupProfile -= GroupProfileDelegate; +
-    groupName = localGroupName; +
-    return true; +
-+
-</code> +
- +
-======== Find UUID of Inventory Item ======== +
- +
-<code csharp> +
-/////////////////////////////////////////////////////////////////////////// +
-//    Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3    // +
-/////////////////////////////////////////////////////////////////////////// +
-/// /// +
-/// <summary> +
-///     Finds an inventory item starting from a given root folder and  +
-///     return false if the item cannot be found, true if it can as well  +
-///     as setting itemUUID to the UUID of the found item. +
-/// </summary> +
-/// <param name="rootFolder">a folder from which to search</param> +
-/// <param name="itemName">the name of the item to be found</param> +
-/// <param name="itemUUID">an UUID to store the the found item</param> +
-/// <param name="millisecondsTimeout">timeout for the search</param> +
-/// <returns>true if the item has been found and false otherwise</returns> +
-static bool SearchInventoryItem(InventoryFolder rootFolder, string itemName, ref UUID itemUUID, int millisecondsTimeout) +
-+
-    List<InventoryBase> contents = Client.Inventory.FolderContents(rootFolder.UUID, Client.Self.AgentID, +
-        true, true, InventorySortOrder.ByName, millisecondsTimeout); +
- +
-    if (contents == null) return false; +
- +
-    foreach (InventoryBase i in contents) +
-    { +
-        if (i.Name.Equals(itemName)) +
-        { +
-            itemUUID = i.UUID; +
-            return true; +
-        } +
- +
-        var inventoryFolder = i as InventoryFolder; +
-        if (inventoryFolder == null) continue; +
-        SearchInventoryItem(inventoryFolder, itemName, ref itemUUID, millisecondsTimeout); +
-    } +
- +
-    return false; +
-+
-</code> +
- +
-======== Get Parcel of a Simulator at a Given Position ======== +
- +
-The following function will store a parcel given a simulator and a position: +
- +
-<code csharp> +
-/////////////////////////////////////////////////////////////////////////// +
-//    Copyright (C) 2014 Wizardry and Steamworks - License: GNU GPLv3    // +
-/////////////////////////////////////////////////////////////////////////// +
-/// <summary> +
-/// Get the parcel of a simulator given a position. +
-/// </summary> +
-/// <param name="simulator">the simulator containing the parcel</param> +
-/// <param name="position">a position within the parcel</param> +
-/// <param name="millisecondsTimeout">timeout for the search in milliseconds</param> +
-/// <param name="parcel">a parcel object where to store the found parcel</param> +
-/// <returns>true if the parcel could be found</returns> +
-private static bool GetParcelAtPosition(Simulator simulator, Vector3 position, int millisecondsTimeout, ref Parcel parcel) +
-+
-    Parcel localParcel = null; +
-    var RequestAllSimParcelsEvent = new ManualResetEvent(false); +
-    EventHandler<SimParcelsDownloadedEventArgs> SimParcelsDownloadedDelegate = (o, s) => RequestAllSimParcelsEvent.Set(); +
-    Client.Parcels.SimParcelsDownloaded += SimParcelsDownloadedDelegate; +
-    Client.Parcels.RequestAllSimParcels(simulator, true, simulator.Stats.LastLag); +
-    if (!RequestAllSimParcelsEvent.WaitOne(millisecondsTimeout * simulator.Stats.LastLag, false)) +
-    { +
-        Client.Parcels.SimParcelsDownloaded -= SimParcelsDownloadedDelegate; +
-        return false; +
-    } +
-    Client.Parcels.SimParcelsDownloaded -= SimParcelsDownloadedDelegate; +
-    Client.Network.CurrentSim.Parcels.ForEach(delegate(Parcel currentParcel) +
-    { +
-        if (!(position.X >= currentParcel.AABBMin.X) || !(position.X <= currentParcel.AABBMax.X) || +
-            !(position.Y >= currentParcel.AABBMin.Y) || !(position.Y <= currentParcel.AABBMax.Y)) return; +
-        localParcel = currentParcel; +
-    }); +
-    if (localParcel == null) return false; +
-    parcel = localParcel; +
-    return true; +
-+
-</code> +
- +
-For example, a call such as: +
-<code csharp> +
-Parcel parcel = null; +
-if (!GetParcelAtPosition(Client.Network.CurrentSim, Client.Self.SimPosition, 60000, ref parcel)) +
-+
-    throw new Exception(); +
-+
- +
-</code> +
- +
-will get the parcel that the scripted agent is currently on by supplying the scripted agent's ''CurrentSim'' and ''SimPosition''. The result will be stored in ''parcel''+
- +
-======== Extract Full Avatar Name ========+
  
 libopenmetaverse uses different possible avatar name formats when passing avatar names. For example, an avatar name can be in one of the following formats: libopenmetaverse uses different possible avatar name formats when passing avatar names. For example, an avatar name can be in one of the following formats:

fuss/libopenmetaverse.1420501591.txt.bz2 · Last modified: 2015/01/05 23:46 by office

Wizardry and Steamworks

© 2025 Wizardry and Steamworks

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.