From 266eabcad493863de2ddb8430b7d4509e584dfb9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 25 Jan 2018 06:50:49 +0000 Subject: add a low level LLSDxml encoder for cases where it makes no sense to use more heavy things like OSD, and use it on displaynames --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 67 +++++++++++----------- 1 file changed, 33 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index daa40c4..85e5ec3 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -1824,52 +1824,51 @@ namespace OpenSim.Region.ClientStack.Linden Dictionary names = m_UserManager.GetUsersNames(ids); - OSDMap osdReply = new OSDMap(); - OSDArray agents = new OSDArray(); - - osdReply["agents"] = agents; - foreach (KeyValuePair kvp in names) + StringBuilder lsl = new StringBuilder(names.Count * 256 + 256); + LLSDxmlEncode.AddStartHeader(lsl); + LLSDxmlEncode.AddStartMap(lsl); + if(names.Count == 0) + LLSDxmlEncode.AddEmpyArray("agents", lsl); + else { - if (string.IsNullOrEmpty(kvp.Value)) - continue; - if(kvp.Key == UUID.Zero) - continue; + LLSDxmlEncode.AddStartArray("agents", lsl); + + foreach (KeyValuePair kvp in names) + { + if (string.IsNullOrEmpty(kvp.Value)) + continue; + if(kvp.Key == UUID.Zero) + continue; - string[] parts = kvp.Value.Split(new char[] {' '}); - OSDMap osdname = new OSDMap(); + string[] parts = kvp.Value.Split(new char[] {' '}); // dont tell about unknown users, we can't send them back on Bad either - if(parts[0] == "Unknown") - continue; -/* - if(parts[0] == "Unknown") - { - osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddHours(1)); - osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddHours(2)); - } - else -*/ - { - osdname["display_name_next_update"] = OSD.FromDate(DateTime.UtcNow.AddDays(8)); - osdname["display_name_expires"] = OSD.FromDate(DateTime.UtcNow.AddMonths(1)); + if(parts[0] == "Unknown") + continue; + + LLSDxmlEncode.AddStartMap(lsl); + LLSDxmlEncode.AddElem("display_name_next_update", DateTime.UtcNow.AddDays(8), lsl); + LLSDxmlEncode.AddElem("display_name_expires", DateTime.UtcNow.AddMonths(1), lsl); + LLSDxmlEncode.AddElem("display_name", kvp.Value, lsl); + LLSDxmlEncode.AddElem("legacy_first_name", parts[0], lsl); + LLSDxmlEncode.AddElem("legacy_last_name", parts[1], lsl); + LLSDxmlEncode.AddElem("username", kvp.Value, lsl); + LLSDxmlEncode.AddElem("id", kvp.Key, lsl); + LLSDxmlEncode.AddElem("is_display_name_default", true, lsl); + LLSDxmlEncode.AddEndMap(lsl); } - osdname["display_name"] = OSD.FromString(kvp.Value); - osdname["legacy_first_name"] = parts[0]; - osdname["legacy_last_name"] = parts[1]; - osdname["username"] = OSD.FromString(kvp.Value); - osdname["id"] = OSD.FromUUID(kvp.Key); - osdname["is_display_name_default"] = OSD.FromBoolean(true); - - agents.Add(osdname); + LLSDxmlEncode.AddEndArray(lsl); } + + LLSDxmlEncode.AddEndMap(lsl); + LLSDxmlEncode.AddEndHeader(lsl); // Full content request httpResponse.StatusCode = (int)System.Net.HttpStatusCode.OK; //httpResponse.ContentLength = ??; httpResponse.ContentType = "application/llsd+xml"; - string reply = OSDParser.SerializeLLSDXmlString(osdReply); - return reply; + return lsl.ToString(); } } -- cgit v1.1