public void Parse(Hashtable reply) { try { AgentID = ParseUUID("agent_id", reply); SessionID = ParseUUID("session_id", reply); SecureSessionID = ParseUUID("secure_session_id", reply); FirstName = ParseString("first_name", reply).Trim('"'); LastName = ParseString("last_name", reply).Trim('"'); // "first_login" for brand new accounts StartLocation = ParseString("start_location", reply); AgentAccess = ParseString("agent_access", reply); LookAt = ParseVector3("look_at", reply); Reason = ParseString("reason", reply); Message = ParseString("message", reply); if (reply.ContainsKey("login")) { Login = (string)reply["login"]; Success = Login == "true"; // Parse redirect options if (Login == "indeterminate") { NextUrl = ParseString("next_url", reply); NextDuration = (int)ParseUInt("next_duration", reply); NextMethod = ParseString("next_method", reply); NextOptions = (string[])((ArrayList)reply["next_options"]).ToArray(typeof(string)); } } } catch (Exception e) { Logger.Log("Login server returned (some) invalid data: " + e.Message, Helpers.LogLevel.Warning); } if (!Success) return; // Home OSDMap home = null; if (reply.ContainsKey("home")) { OSD osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].ToString()); if (osdHome.Type == OSDType.Map) { home = (OSDMap)osdHome; OSD homeRegion; if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array) { OSDArray homeArray = (OSDArray)homeRegion; if (homeArray.Count == 2) HomeRegion = Utils.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger()); else HomeRegion = 0; } HomePosition = ParseVector3("position", home); HomeLookAt = ParseVector3("look_at", home); } } else { HomeRegion = 0; HomePosition = Vector3.Zero; HomeLookAt = Vector3.Zero; } CircuitCode = (int)ParseUInt("circuit_code", reply); RegionX = (int)ParseUInt("region_x", reply); RegionY = (int)ParseUInt("region_y", reply); SimPort = (short)ParseUInt("sim_port", reply); string simIP = ParseString("sim_ip", reply); IPAddress.TryParse(simIP, out SimIP); SeedCapability = ParseString("seed_capability", reply); // Buddy list if (reply.ContainsKey("buddy-list") && reply["buddy-list"] is ArrayList) { List<BuddyListEntry> buddys = new List<BuddyListEntry>(); ArrayList buddyArray = (ArrayList)reply["buddy-list"]; for (int i = 0; i < buddyArray.Count; i++) { if (buddyArray[i] is Hashtable) { BuddyListEntry bud = new BuddyListEntry(); Hashtable buddy = (Hashtable)buddyArray[i]; bud.buddy_id = ParseString("buddy_id", buddy); bud.buddy_rights_given = (int)ParseUInt("buddy_rights_given", buddy); bud.buddy_rights_has = (int)ParseUInt("buddy_rights_has", buddy); buddys.Add(bud); } } BuddyList = buddys.ToArray(); } SecondsSinceEpoch = (int)ParseUInt("seconds_since_epoch", reply); InventoryRoot = ParseMappedUUID("inventory-root", "folder_id", reply); InventorySkeleton = ParseInventorySkeleton("inventory-skeleton", reply); LibraryOwner = ParseMappedUUID("inventory-lib-owner", "agent_id", reply); LibraryRoot = ParseMappedUUID("inventory-lib-root", "folder_id", reply); LibrarySkeleton = ParseInventorySkeleton("inventory-skel-lib", reply); // UDP Blacklist if (reply.ContainsKey("udp_blacklist")) { UDPBlacklist = ParseString("udp_blacklist", reply); } }
/// <summary> /// Parse LLSD Login Reply Data /// </summary> /// <param name="reply">An <seealso cref="OSDMap"/> /// contaning the login response data</param> /// <remarks>XML-RPC logins do not require this as XML-RPC.NET /// automatically populates the struct properly using attributes</remarks> public void Parse(OSDMap reply) { try { AgentID = ParseUUID("agent_id", reply); SessionID = ParseUUID("session_id", reply); SecureSessionID = ParseUUID("secure_session_id", reply); FirstName = ParseString("first_name", reply).Trim('"'); LastName = ParseString("last_name", reply).Trim('"'); StartLocation = ParseString("start_location", reply); AgentAccess = ParseString("agent_access", reply); LookAt = ParseVector3("look_at", reply); Reason = ParseString("reason", reply); Message = ParseString("message", reply); Login = reply["login"].AsString(); Success = reply["login"].AsBoolean(); } catch (OSDException e) { Logger.Log("Login server returned (some) invalid data: " + e.Message, Helpers.LogLevel.Warning); } // Home OSDMap home = null; OSD osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].AsString()); if (osdHome.Type == OSDType.Map) { home = (OSDMap)osdHome; OSD homeRegion; if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array) { OSDArray homeArray = (OSDArray)homeRegion; if (homeArray.Count == 2) HomeRegion = Utils.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger()); else HomeRegion = 0; } HomePosition = ParseVector3("position", home); HomeLookAt = ParseVector3("look_at", home); } else { HomeRegion = 0; HomePosition = Vector3.Zero; HomeLookAt = Vector3.Zero; } CircuitCode = (int)ParseUInt("circuit_code", reply); RegionX = (int)ParseUInt("region_x", reply); RegionY = (int)ParseUInt("region_y", reply); SimPort = (short)ParseUInt("sim_port", reply); string simIP = ParseString("sim_ip", reply); IPAddress.TryParse(simIP, out SimIP); SeedCapability = ParseString("seed_capability", reply); // Buddy list OSD buddyLLSD; if (reply.TryGetValue("buddy-list", out buddyLLSD) && buddyLLSD.Type == OSDType.Array) { List<BuddyListEntry> buddys = new List<BuddyListEntry>(); OSDArray buddyArray = (OSDArray)buddyLLSD; for (int i = 0; i < buddyArray.Count; i++) { if (buddyArray[i].Type == OSDType.Map) { BuddyListEntry bud = new BuddyListEntry(); OSDMap buddy = (OSDMap)buddyArray[i]; bud.buddy_id = buddy["buddy_id"].AsString(); bud.buddy_rights_given = (int)ParseUInt("buddy_rights_given", buddy); bud.buddy_rights_has = (int)ParseUInt("buddy_rights_has", buddy); buddys.Add(bud); } BuddyList = buddys.ToArray(); } } SecondsSinceEpoch = (int)ParseUInt("seconds_since_epoch", reply); InventoryRoot = ParseMappedUUID("inventory-root", "folder_id", reply); InventorySkeleton = ParseInventorySkeleton("inventory-skeleton", reply); LibraryOwner = ParseMappedUUID("inventory-lib-owner", "agent_id", reply); LibraryRoot = ParseMappedUUID("inventory-lib-root", "folder_id", reply); LibrarySkeleton = ParseInventorySkeleton("inventory-skel-lib", reply); }