/// <summary> /// Invokes the xGetAssetMetadata operation on the simian server to retrieve metadata for an asset /// This operation is generally used to determine if an asset exists in the database /// </summary> /// <param name="id"></param> /// <returns></returns> private AssetMetadata SimianGetMetadataOperation(string id) { try { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "xGetAssetMetadata" }, { "ID", id } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (!response["Success"].AsBoolean()) { // this is not really an error, this call is used to test existence // m_log.DebugFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset metadata; {0}",response["Message"].AsString()); return(null); } AssetMetadata metadata = new AssetMetadata(); metadata.ID = id; metadata.ContentType = response["ContentType"].AsString(); metadata.CreatorID = response["CreatorID"].AsString(); metadata.Local = false; metadata.Temporary = response["Temporary"]; string lastModifiedStr = response["Last-Modified"].AsString(); if (!String.IsNullOrEmpty(lastModifiedStr)) { DateTime lastModified; if (DateTime.TryParse(lastModifiedStr, out lastModified)) { metadata.CreationDate = lastModified; } } return(metadata); } catch (Exception ex) { m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: Failed to get asset metadata; {0}", ex.Message); } return(null); }
private string Authorize(UUID userID) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "AddSession" }, { "UserID", userID.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean()) { return(response["SessionID"].AsUUID().ToString()); } else { return(String.Empty); } }
/// <summary> /// Get an item, given by its UUID /// </summary> /// <param name="item"></param> /// <returns></returns> public InventoryItemBase GetItem(InventoryItemBase item) { InventoryItemBase retrieved = null; if (m_ItemCache.TryGetValue(item.ID, out retrieved)) { return(retrieved); } NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetInventoryNode" }, { "ItemID", item.ID.ToString() }, { "OwnerID", item.Owner.ToString() }, { "IncludeFolders", "1" }, { "IncludeItems", "1" }, { "ChildrenOnly", "1" } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean() && response["Items"] is OSDArray) { List <InventoryItemBase> items = GetItemsFromResponse((OSDArray)response["Items"]); if (items.Count > 0) { // The requested item should be the first in this list, but loop through // and sanity check just in case for (int i = 0; i < items.Count; i++) { if (items[i].ID == item.ID) { retrieved = items[i]; m_ItemCache.AddOrUpdate(item.ID, retrieved, CACHE_EXPIRATION_SECONDS); return(retrieved); } } } } m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Item " + item.ID + " owned by " + item.Owner + " not found"); return(null); }
public bool DeregisterRegion(UUID regionID) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "AddScene" }, { "SceneID", regionID.ToString() }, { "Enabled", "0" } }; OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); bool success = response["Success"].AsBoolean(); if (!success) { m_log.Warn("[SIMIAN GRID CONNECTOR]: Region deregistration for " + regionID + " failed: " + response["Message"].AsString()); } return(success); }
private bool AddUserData(UUID userID, string key, OSDMap value) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "AddUserData" }, { "UserID", userID.ToString() }, { key, OSDParser.SerializeJsonString(value) } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); bool success = response["Success"].AsBoolean(); if (!success) { m_log.WarnFormat("[SIMIAN PROFILES]: Failed to add user data with key {0} for {1}: {2}", key, userID, response["Message"].AsString()); } return(success); }
public string RegisterRegion(UUID scopeID, GridRegion regionInfo) { Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); OSDMap extraData = new OSDMap { { "ServerURI", OSD.FromString(regionInfo.ServerURI) }, { "InternalAddress", OSD.FromString(regionInfo.InternalEndPoint.Address.ToString()) }, { "InternalPort", OSD.FromInteger(regionInfo.InternalEndPoint.Port) }, { "ExternalAddress", OSD.FromString(regionInfo.ExternalEndPoint.Address.ToString()) }, { "ExternalPort", OSD.FromInteger(regionInfo.ExternalEndPoint.Port) }, { "MapTexture", OSD.FromUUID(regionInfo.TerrainImage) }, { "Access", OSD.FromInteger(regionInfo.Access) }, { "RegionSecret", OSD.FromString(regionInfo.RegionSecret) }, { "EstateOwner", OSD.FromUUID(regionInfo.EstateOwner) }, { "Token", OSD.FromString(regionInfo.Token) } }; NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "AddScene" }, { "SceneID", regionInfo.RegionID.ToString() }, { "Name", regionInfo.RegionName }, { "MinPosition", minPosition.ToString() }, { "MaxPosition", maxPosition.ToString() }, { "Address", regionInfo.ServerURI }, { "Enabled", "1" }, { "ExtraData", OSDParser.SerializeJsonString(extraData) } }; OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); if (response["Success"].AsBoolean()) { return(String.Empty); } else { return("Region registration for " + regionInfo.RegionName + " failed: " + response["Message"].AsString()); } }
/// <summary> /// Purge an inventory folder of all its items and subfolders. /// </summary> /// <param name="folder"></param> /// <returns>true if the folder was successfully purged</returns> public bool PurgeFolder(InventoryFolderBase folder) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "PurgeInventoryFolder" }, { "OwnerID", folder.Owner.ToString() }, { "FolderID", folder.ID.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); bool success = response["Success"].AsBoolean(); if (!success) { m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error purging folder " + folder.ID + " for " + folder.Owner + ": " + response["Message"].AsString()); } return(success); }
private OSDMap GetUserData(UUID userID) { // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID); NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetUser" }, { "UserID", userID.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean() && response["User"] is OSDMap) { return(response); } m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}; {1}", userID.ToString(), response["Message"].AsString()); return(null); }
public bool LogoutRegionAgents(UUID regionID) { // m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for all agents in region " + regionID); NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "RemoveSessions" }, { "SceneID", regionID.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); bool success = response["Success"].AsBoolean(); if (!success) { m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to logout agents from region " + regionID + ": " + response["Message"].AsString()); } return(success); }
public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt) { // m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "AddUserData" }, { "UserID", userID.ToString() }, { "HomeLocation", SerializeLocation(regionID, position, lookAt) } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); bool success = response["Success"].AsBoolean(); if (!success) { m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to set home location for " + userID + ": " + response["Message"].AsString()); } return(success); }
private OSDArray GetFriendedBy(string ownerID) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetGenerics" }, { "Key", ownerID.ToString() }, { "Type", "Friend" } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean() && response["Entries"] is OSDArray) { return((OSDArray)response["Entries"]); } else { m_log.Warn("[SIMIAN FRIENDS CONNECTOR]: Failed to retrieve reverse friends for user " + ownerID + ": " + response["Message"].AsString()); return(new OSDArray(0)); } }
private void UserInfoRequestHandler(IClientAPI client) { m_log.Error("[SIMIAN PROFILES]: UserInfoRequestHandler"); // Fetch this user's e-mail address NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetUser" }, { "UserID", client.AgentId.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); string email = response["Email"].AsString(); if (!response["Success"].AsBoolean()) { m_log.Warn("[SIMIAN PROFILES]: GetUser failed during a user info request for " + client.Name); } client.SendUserInfoReply(false, true, email); }
public List <GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) { List <GridRegion> foundRegions = new List <GridRegion>(); NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetScenes" }, { "NameQuery", name }, { "Enabled", "1" } }; if (maxNumber > 0) { requestArgs["MaxNumber"] = maxNumber.ToString(); } // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions with name {0}",name); OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); if (response["Success"].AsBoolean()) { // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] found regions with name {0}",name); OSDArray array = response["Scenes"] as OSDArray; if (array != null) { for (int i = 0; i < array.Count; i++) { GridRegion region = ResponseToGridRegion(array[i] as OSDMap); if (region != null) { foundRegions.Add(region); } } } } return(foundRegions); }
public List <UserAccount> GetUserAccounts(UUID scopeID, string query) { List <UserAccount> accounts = new List <UserAccount>(); // m_log.DebugFormat("[SIMIAN ACCOUNT CONNECTOR]: Searching for user accounts with name query " + query); NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetUsers" }, { "NameQuery", query } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean()) { OSDArray array = response["Users"] as OSDArray; if (array != null && array.Count > 0) { for (int i = 0; i < array.Count; i++) { UserAccount account = ResponseToUserAccount(array[i] as OSDMap); if (account != null) { accounts.Add(account); } } } else { m_log.Warn("[SIMIAN ACCOUNT CONNECTOR]: Account search failed, response data was in an invalid format"); } } else { m_log.Warn("[SIMIAN ACCOUNT CONNECTOR]: Failed to search for account data by name " + query); } return(accounts); }
public bool Verify(UUID principalID, string token, int lifetime) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetSession" }, { "SessionID", token } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean()) { return(true); } else { m_log.Warn("[SIMIAN AUTH CONNECTOR]: Could not verify session for " + principalID + ": " + response["Message"].AsString()); } return(false); }
public bool Release(UUID principalID, string token) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "RemoveSession" }, { "UserID", principalID.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean()) { return(true); } else { m_log.Warn("[SIMIAN AUTH CONNECTOR]: Failed to remove session for " + principalID + ": " + response["Message"].AsString()); } return(false); }
private bool UpdateSession(UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { // Save our current location as session data NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "UpdateSession" }, { "SessionID", sessionID.ToString() }, { "SceneID", regionID.ToString() }, { "ScenePosition", lastPosition.ToString() }, { "SceneLookAt", lastLookAt.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); bool success = response["Success"].AsBoolean(); if (!success) { m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to update agent session " + sessionID + ": " + response["Message"].AsString()); } return(success); }
public List <GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { List <GridRegion> foundRegions = new List <GridRegion>(); Vector3d minPosition = new Vector3d(xmin, ymin, 0.0); Vector3d maxPosition = new Vector3d(xmax, ymax, Constants.RegionHeight); NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetScenes" }, { "MinPosition", minPosition.ToString() }, { "MaxPosition", maxPosition.ToString() }, { "Enabled", "1" } }; //m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request regions by range {0} to {1}",minPosition.ToString(),maxPosition.ToString()); OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); if (response["Success"].AsBoolean()) { OSDArray array = response["Scenes"] as OSDArray; if (array != null) { for (int i = 0; i < array.Count; i++) { GridRegion region = ResponseToGridRegion(array[i] as OSDMap); if (region != null) { foundRegions.Add(region); } } } } return(foundRegions); }
/// <summary> /// Add a new folder to the user's inventory /// </summary> /// <param name="folder"></param> /// <returns>true if the folder was successfully added</returns> public bool AddFolder(InventoryFolderBase folder) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "AddInventoryFolder" }, { "FolderID", folder.ID.ToString() }, { "ParentID", folder.ParentID.ToString() }, { "OwnerID", folder.Owner.ToString() }, { "Name", folder.Name }, { "ContentType", SLUtil.SLAssetTypeToContentType(folder.Type) } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); bool success = response["Success"].AsBoolean(); if (!success) { m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error creating folder " + folder.Name + " for " + folder.Owner + ": " + response["Message"].AsString()); } return(success); }
private OSDMap FetchUserData(UUID userID) { m_log.DebugFormat("[SIMIAN PROFILES]: Fetch information about {0}", userID); NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetUser" }, { "UserID", userID.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean() && response["User"] is OSDMap) { return((OSDMap)response["User"]); } else { m_log.Error("[SIMIAN PROFILES]: Failed to fetch user data for " + userID + ": " + response["Message"].AsString()); } return(null); }
public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetScene" }, { "SceneID", regionID.ToString() } }; // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] request region with uuid {0}",regionID.ToString()); OSDMap response = SimianGrid.PostToService(m_ServerURI, requestArgs); if (response["Success"].AsBoolean()) { // m_log.DebugFormat("[SIMIAN GRID CONNECTOR] uuid request successful {0}",response["Name"].AsString()); return(ResponseToGridRegion(response)); } else { m_log.Warn("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region " + regionID); return(null); } }
/// <summary> /// Invokes the xGetAsset operation on the simian server to get data associated with an asset /// </summary> /// <param name="id"></param> /// <returns></returns> private AssetBase SimianGetOperation(string id) { try { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "xGetAsset" }, { "ID", id } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (!response["Success"].AsBoolean()) { m_log.WarnFormat("[SIMIAN ASSET CONNECTOR] Failed to get asset; {0}", response["Message"].AsString()); return(null); } AssetBase asset = new AssetBase(); asset.ID = id; asset.Name = String.Empty; asset.Metadata.ContentType = response["ContentType"].AsString(); // this will also set the asset Type property asset.CreatorID = response["CreatorID"].AsString(); asset.Data = System.Convert.FromBase64String(response["EncodedData"].AsString()); asset.Local = false; asset.Temporary = response["Temporary"]; return(asset); } catch (Exception ex) { m_log.WarnFormat("[SIMIAN ASSET CONNECTOR]: failed to retrieve asset {0}; {1}", id, ex.Message); } return(null); }
///<summary> /// ///</summary> private void UploadMapTile(IScene scene) { m_log.DebugFormat("[SIMIAN MAPTILE]: upload maptile for {0}", scene.RegionInfo.RegionName); // Create a PNG map tile and upload it to the AddMapTile API byte[] pngData = Utils.EmptyBytes; IMapImageGenerator tileGenerator = scene.RequestModuleInterface <IMapImageGenerator>(); if (tileGenerator == null) { m_log.Warn("[SIMIAN MAPTILE]: Cannot upload PNG map tile without an ImageGenerator"); return; } using (Image mapTile = tileGenerator.CreateMapTile()) { using (MemoryStream stream = new MemoryStream()) { mapTile.Save(stream, ImageFormat.Png); pngData = stream.ToArray(); } } NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "xAddMapTile" }, { "X", scene.RegionInfo.RegionLocX.ToString() }, { "Y", scene.RegionInfo.RegionLocY.ToString() }, { "ContentType", "image/png" }, { "EncodedData", System.Convert.ToBase64String(pngData) } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (!response["Success"].AsBoolean()) { m_log.WarnFormat("[SIMIAN MAPTILE] failed to store map tile; {0}", response["Message"].AsString()); return; } // List<MultipartForm.Element> postParameters = new List<MultipartForm.Element>() // { // new MultipartForm.Parameter("X", scene.RegionInfo.RegionLocX.ToString()), // new MultipartForm.Parameter("Y", scene.RegionInfo.RegionLocY.ToString()), // new MultipartForm.File("Tile", "tile.png", "image/png", pngData) // }; // string errorMessage = null; // int tickstart = Util.EnvironmentTickCount(); // // Make the remote storage request // try // { // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(m_serverUrl); // request.Timeout = 20000; // request.ReadWriteTimeout = 5000; // using (HttpWebResponse response = MultipartForm.Post(request, postParameters)) // { // using (Stream responseStream = response.GetResponseStream()) // { // string responseStr = responseStream.GetStreamString(); // OSD responseOSD = OSDParser.Deserialize(responseStr); // if (responseOSD.Type == OSDType.Map) // { // OSDMap responseMap = (OSDMap)responseOSD; // if (responseMap["Success"].AsBoolean()) // return; // errorMessage = "Upload failed: " + responseMap["Message"].AsString(); // } // else // { // errorMessage = "Response format was invalid:\n" + responseStr; // } // } // } // } // catch (WebException we) // { // errorMessage = we.Message; // if (we.Status == WebExceptionStatus.ProtocolError) // { // HttpWebResponse webResponse = (HttpWebResponse)we.Response; // errorMessage = String.Format("[{0}] {1}", // webResponse.StatusCode,webResponse.StatusDescription); // } // } // catch (Exception ex) // { // errorMessage = ex.Message; // } // finally // { // // This just dumps a warning for any operation that takes more than 100 ms // int tickdiff = Util.EnvironmentTickCountSubtract(tickstart); // m_log.DebugFormat("[SIMIAN MAPTILE]: map tile uploaded in {0}ms",tickdiff); // } // m_log.WarnFormat("[SIMIAN MAPTILE]: Failed to store {0} byte tile for {1}: {2}", // pngData.Length, scene.RegionInfo.RegionName, errorMessage); }
/// <summary> /// Add a new item to the user's inventory /// </summary> /// <param name="item"></param> /// <returns>true if the item was successfully added</returns> public bool AddItem(InventoryItemBase item) { // A folder of UUID.Zero means we need to find the most appropriate home for this item if (item.Folder == UUID.Zero) { InventoryFolderBase folder = GetFolderForType(item.Owner, (AssetType)item.AssetType); if (folder != null && folder.ID != UUID.Zero) { item.Folder = folder.ID; } else { item.Folder = item.Owner; // Root folder } } if ((AssetType)item.AssetType == AssetType.Gesture) { UpdateGesture(item.Owner, item.ID, item.Flags == 1); } if (item.BasePermissions == 0) { m_log.WarnFormat("[SIMIAN INVENTORY CONNECTOR]: Adding inventory item {0} ({1}) with no base permissions", item.Name, item.ID); } OSDMap permissions = new OSDMap { { "BaseMask", OSD.FromInteger(item.BasePermissions) }, { "EveryoneMask", OSD.FromInteger(item.EveryOnePermissions) }, { "GroupMask", OSD.FromInteger(item.GroupPermissions) }, { "NextOwnerMask", OSD.FromInteger(item.NextPermissions) }, { "OwnerMask", OSD.FromInteger(item.CurrentPermissions) } }; OSDMap extraData = new OSDMap() { { "Flags", OSD.FromInteger(item.Flags) }, { "GroupID", OSD.FromUUID(item.GroupID) }, { "GroupOwned", OSD.FromBoolean(item.GroupOwned) }, { "SalePrice", OSD.FromInteger(item.SalePrice) }, { "SaleType", OSD.FromInteger(item.SaleType) }, { "Permissions", permissions } }; // Add different asset type only if it differs from inventory type // (needed for links) string invContentType = SLUtil.SLInvTypeToContentType(item.InvType); string assetContentType = SLUtil.SLAssetTypeToContentType(item.AssetType); if (invContentType != assetContentType) { extraData["LinkedItemType"] = OSD.FromString(assetContentType); } NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "AddInventoryItem" }, { "ItemID", item.ID.ToString() }, { "AssetID", item.AssetID.ToString() }, { "ParentID", item.Folder.ToString() }, { "OwnerID", item.Owner.ToString() }, { "Name", item.Name }, { "Description", item.Description }, { "CreatorID", item.CreatorId }, { "CreatorData", item.CreatorData }, { "ContentType", invContentType }, { "ExtraData", OSDParser.SerializeJsonString(extraData) } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); bool success = response["Success"].AsBoolean(); if (!success) { m_log.Warn("[SIMIAN INVENTORY CONNECTOR]: Error creating item " + item.Name + " for " + item.Owner + ": " + response["Message"].AsString()); } return(success); }
// <summary> // </summary> // <param name=""></param> public bool SetAvatar(UUID userID, AvatarData avatar) { m_log.Debug("[SIMIAN AVATAR CONNECTOR]: SetAvatar called for " + userID); if (avatar.AvatarType == 1) // LLAvatar { AvatarAppearance appearance = avatar.ToAvatarAppearance(); OSDMap map = new OSDMap(); map["Height"] = OSD.FromReal(appearance.AvatarHeight); map["BodyItem"] = appearance.Wearables[AvatarWearable.BODY][0].ItemID.ToString(); map["EyesItem"] = appearance.Wearables[AvatarWearable.EYES][0].ItemID.ToString(); map["GlovesItem"] = appearance.Wearables[AvatarWearable.GLOVES][0].ItemID.ToString(); map["HairItem"] = appearance.Wearables[AvatarWearable.HAIR][0].ItemID.ToString(); map["JacketItem"] = appearance.Wearables[AvatarWearable.JACKET][0].ItemID.ToString(); map["PantsItem"] = appearance.Wearables[AvatarWearable.PANTS][0].ItemID.ToString(); map["ShirtItem"] = appearance.Wearables[AvatarWearable.SHIRT][0].ItemID.ToString(); map["ShoesItem"] = appearance.Wearables[AvatarWearable.SHOES][0].ItemID.ToString(); map["SkinItem"] = appearance.Wearables[AvatarWearable.SKIN][0].ItemID.ToString(); map["SkirtItem"] = appearance.Wearables[AvatarWearable.SKIRT][0].ItemID.ToString(); map["SocksItem"] = appearance.Wearables[AvatarWearable.SOCKS][0].ItemID.ToString(); map["UnderPantsItem"] = appearance.Wearables[AvatarWearable.UNDERPANTS][0].ItemID.ToString(); map["UnderShirtItem"] = appearance.Wearables[AvatarWearable.UNDERSHIRT][0].ItemID.ToString(); map["BodyAsset"] = appearance.Wearables[AvatarWearable.BODY][0].AssetID.ToString(); map["EyesAsset"] = appearance.Wearables[AvatarWearable.EYES][0].AssetID.ToString(); map["GlovesAsset"] = appearance.Wearables[AvatarWearable.GLOVES][0].AssetID.ToString(); map["HairAsset"] = appearance.Wearables[AvatarWearable.HAIR][0].AssetID.ToString(); map["JacketAsset"] = appearance.Wearables[AvatarWearable.JACKET][0].AssetID.ToString(); map["PantsAsset"] = appearance.Wearables[AvatarWearable.PANTS][0].AssetID.ToString(); map["ShirtAsset"] = appearance.Wearables[AvatarWearable.SHIRT][0].AssetID.ToString(); map["ShoesAsset"] = appearance.Wearables[AvatarWearable.SHOES][0].AssetID.ToString(); map["SkinAsset"] = appearance.Wearables[AvatarWearable.SKIN][0].AssetID.ToString(); map["SkirtAsset"] = appearance.Wearables[AvatarWearable.SKIRT][0].AssetID.ToString(); map["SocksAsset"] = appearance.Wearables[AvatarWearable.SOCKS][0].AssetID.ToString(); map["UnderPantsAsset"] = appearance.Wearables[AvatarWearable.UNDERPANTS][0].AssetID.ToString(); map["UnderShirtAsset"] = appearance.Wearables[AvatarWearable.UNDERSHIRT][0].AssetID.ToString(); OSDMap items = new OSDMap(); foreach (KeyValuePair <string, string> kvp in avatar.Data) { if (kvp.Key.StartsWith("_ap_")) { items.Add(kvp.Key, OSD.FromString(kvp.Value)); } } NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "AddUserData" }, { "UserID", userID.ToString() }, { "LLAppearance", OSDParser.SerializeJsonString(map) }, { "LLAttachments", OSDParser.SerializeJsonString(items) } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); bool success = response["Success"].AsBoolean(); if (!success) { m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed saving appearance for " + userID + ": " + response["Message"].AsString()); } return(success); } else { m_log.Error("[SIMIAN AVATAR CONNECTOR]: Can't save appearance for " + userID + ". Unhandled avatar type " + avatar.AvatarType); return(false); } }
// <summary> // </summary> // <param name=""></param> public AvatarData GetAvatar(UUID userID) { NameValueCollection requestArgs = new NameValueCollection { { "RequestMethod", "GetUser" }, { "UserID", userID.ToString() } }; OSDMap response = SimianGrid.PostToService(m_serverUrl, requestArgs); if (response["Success"].AsBoolean()) { OSDMap map = null; try { map = OSDParser.DeserializeJson(response["LLAppearance"].AsString()) as OSDMap; } catch { } if (map != null) { AvatarWearable[] wearables = new AvatarWearable[13]; wearables[0] = new AvatarWearable(map["ShapeItem"].AsUUID(), map["ShapeAsset"].AsUUID()); wearables[1] = new AvatarWearable(map["SkinItem"].AsUUID(), map["SkinAsset"].AsUUID()); wearables[2] = new AvatarWearable(map["HairItem"].AsUUID(), map["HairAsset"].AsUUID()); wearables[3] = new AvatarWearable(map["EyesItem"].AsUUID(), map["EyesAsset"].AsUUID()); wearables[4] = new AvatarWearable(map["ShirtItem"].AsUUID(), map["ShirtAsset"].AsUUID()); wearables[5] = new AvatarWearable(map["PantsItem"].AsUUID(), map["PantsAsset"].AsUUID()); wearables[6] = new AvatarWearable(map["ShoesItem"].AsUUID(), map["ShoesAsset"].AsUUID()); wearables[7] = new AvatarWearable(map["SocksItem"].AsUUID(), map["SocksAsset"].AsUUID()); wearables[8] = new AvatarWearable(map["JacketItem"].AsUUID(), map["JacketAsset"].AsUUID()); wearables[9] = new AvatarWearable(map["GlovesItem"].AsUUID(), map["GlovesAsset"].AsUUID()); wearables[10] = new AvatarWearable(map["UndershirtItem"].AsUUID(), map["UndershirtAsset"].AsUUID()); wearables[11] = new AvatarWearable(map["UnderpantsItem"].AsUUID(), map["UnderpantsAsset"].AsUUID()); wearables[12] = new AvatarWearable(map["SkirtItem"].AsUUID(), map["SkirtAsset"].AsUUID()); AvatarAppearance appearance = new AvatarAppearance(); appearance.Wearables = wearables; appearance.AvatarHeight = (float)map["Height"].AsReal(); AvatarData avatar = new AvatarData(appearance); // Get attachments map = null; try { map = OSDParser.DeserializeJson(response["LLAttachments"].AsString()) as OSDMap; } catch { } if (map != null) { foreach (KeyValuePair <string, OSD> kvp in map) { avatar.Data[kvp.Key] = kvp.Value.AsString(); } } return(avatar); } else { m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed to get user appearance for " + userID + ", LLAppearance is missing or invalid"); return(null); } } else { m_log.Warn("[SIMIAN AVATAR CONNECTOR]: Failed to get user appearance for " + userID + ": " + response["Message"].AsString()); } return(null); }