private void MakeSeedRequest() { if (Simulator == null || !Simulator.Client.Network.Connected) { return; } // Create a request list LLSDArray req = new LLSDArray(); req.Add("MapLayer"); req.Add("MapLayerGod"); req.Add("NewFileAgentInventory"); req.Add("EventQueueGet"); req.Add("UpdateGestureAgentInventory"); req.Add("UpdateNotecardAgentInventory"); req.Add("UpdateScriptAgentInventory"); req.Add("UpdateGestureTaskInventory"); req.Add("UpdateNotecardTaskInventory"); req.Add("UpdateScriptTaskInventory"); req.Add("SendPostcard"); req.Add("ViewerStartAuction"); req.Add("ParcelGodReserveForNewbie"); req.Add("SendUserReport"); req.Add("SendUserReportWithScreenshot"); req.Add("RequestTextureDownload"); req.Add("UntrustedSimulatorMessage"); req.Add("ParcelVoiceInfoRequest"); req.Add("ChatSessionRequest"); req.Add("ProvisionVoiceAccountRequest"); _SeedRequest = new CapsClient(new Uri(_SeedCapsURI)); _SeedRequest.OnComplete += new CapsClient.CompleteCallback(SeedRequestCompleteHandler); _SeedRequest.StartRequest(req); }
private void CreateUserResponse(CapsClient client, LLSD response, Exception error) { if (response is LLSDMap) { // everything is okay // FIXME: //return new UUID(((Dictionary<string, object>)response)["agent_id"].ToString()); } else { // an error happened LLSDArray al = (LLSDArray)response; StringBuilder sb = new StringBuilder(); foreach (LLSD ec in al) { if (sb.Length > 0) { sb.Append("; "); } sb.Append(_errors[ec.AsInteger()]); } // FIXME: //throw new Exception("failed to create user: " + sb.ToString()); } }
public static TextureEntry FromLLSD(LLSD llsd) { LLSDArray array = (LLSDArray)llsd; LLSDMap faceLLSD; if (array.Count > 0) { int faceNumber; faceLLSD = (LLSDMap)array[0]; TextureEntryFace defaultFace = TextureEntryFace.FromLLSD(faceLLSD, null, out faceNumber); TextureEntry te = new TextureEntry(defaultFace); for (int i = 1; i < array.Count; i++) { TextureEntryFace tex = TextureEntryFace.FromLLSD(array[i], defaultFace, out faceNumber); if (faceNumber >= 0 && faceNumber < te.FaceTextures.Length) { te.FaceTextures[faceNumber] = tex; } } return(te); } else { throw new ArgumentException("LLSD contains no elements"); } }
private void MapLayerResponseHandler(CapsClient client, LLSD result, Exception error) { LLSDMap body = (LLSDMap)result; LLSDArray layerData = (LLSDArray)body["LayerData"]; if (OnGridLayer != null) { for (int i = 0; i < layerData.Count; i++) { LLSDMap thisLayerData = (LLSDMap)layerData[i]; GridLayer layer; layer.Bottom = thisLayerData["Bottom"].AsInteger(); layer.Left = thisLayerData["Left"].AsInteger(); layer.Top = thisLayerData["Top"].AsInteger(); layer.Right = thisLayerData["Right"].AsInteger(); layer.ImageID = thisLayerData["ImageID"].AsUUID(); try { OnGridLayer(layer); } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, Client, e); } } } if (body.ContainsKey("MapBlocks")) { // TODO: At one point this will become activated Logger.Log("Got MapBlocks through CAPS, please finish this function!", Helpers.LogLevel.Error, Client); } }
public void DeserializeArray() { LLSD llsdEmptyArray = LLSDParser.DeserializeBinary(binaryEmptyArray); Assert.AreEqual(LLSDType.Array, llsdEmptyArray.Type); LLSDArray llsdEmptyArrayArray = (LLSDArray)llsdEmptyArray; Assert.AreEqual(0, llsdEmptyArrayArray.Count); LLSD llsdSimpleArray = LLSDParser.DeserializeBinary(binarySimpleArray); Assert.AreEqual(LLSDType.Array, llsdSimpleArray.Type); LLSDArray llsdArray = (LLSDArray)llsdSimpleArray; Assert.AreEqual(LLSDType.Integer, llsdArray[0].Type); Assert.AreEqual(0, llsdArray[0].AsInteger()); LLSD llsdSimpleArrayTwo = LLSDParser.DeserializeBinary(binarySimpleArrayTwo); Assert.AreEqual(LLSDType.Array, llsdSimpleArrayTwo.Type); LLSDArray llsdArrayTwo = (LLSDArray)llsdSimpleArrayTwo; Assert.AreEqual(2, llsdArrayTwo.Count); Assert.AreEqual(LLSDType.Integer, llsdArrayTwo[0].Type); Assert.AreEqual(0, llsdArrayTwo[0].AsInteger()); Assert.AreEqual(LLSDType.Integer, llsdArrayTwo[1].Type); Assert.AreEqual(0, llsdArrayTwo[1].AsInteger()); }
public void DeserializeUUID() { LLSD theLLSD = null; LLSDArray array = null; LLSDUUID tempUUID = null; String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <array> <uuid>d7f4aeca-88f1-42a1-b385-b9db18abb255</uuid> <uuid/> </array> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testLLSD); theLLSD = LLSDParser.DeserializeXml(bytes); Assert.IsTrue(theLLSD is LLSDArray); array = (LLSDArray)theLLSD; Assert.AreEqual(LLSDType.UUID, array[0].Type); tempUUID = (LLSDUUID)array[0]; Assert.AreEqual(new LLUUID("d7f4aeca-88f1-42a1-b385-b9db18abb255"), tempUUID.AsUUID()); Assert.AreEqual(LLSDType.UUID, array[1].Type); tempUUID = (LLSDUUID)array[1]; Assert.AreEqual(LLUUID.Zero, tempUUID.AsUUID()); }
public static InventoryFolder[] ParseInventoryFolders(string key, LLUUID owner, LLSDMap reply) { List <InventoryFolder> folders = new List <InventoryFolder>(); LLSD skeleton; if (reply.TryGetValue(key, out skeleton) && skeleton.Type == LLSDType.Array) { LLSDArray array = (LLSDArray)skeleton; for (int i = 0; i < array.Count; i++) { if (array[i].Type == LLSDType.Map) { LLSDMap map = (LLSDMap)array[i]; InventoryFolder folder = new InventoryFolder(map["folder_id"].AsUUID()); folder.PreferredType = (AssetType)map["type_default"].AsInteger(); folder.Version = map["version"].AsInteger(); folder.OwnerID = owner; folder.ParentUUID = map["parent_id"].AsUUID(); folder.Name = map["name"].AsString(); folders.Add(folder); } } return(folders.ToArray()); } return(new InventoryFolder[0]); }
public void DeserializeURI() { LLSD theLLSD = null; LLSDArray array = null; LLSDURI tempURI = null; String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <array> <uri>http://sim956.agni.lindenlab.com:12035/runtime/agents</uri> <uri/> </array> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testLLSD); theLLSD = LLSDParser.DeserializeXml(bytes); Assert.IsTrue(theLLSD is LLSDArray); array = (LLSDArray)theLLSD; Assert.AreEqual(LLSDType.URI, array[0].Type); tempURI = (LLSDURI)array[0]; Uri testURI = new Uri(@"http://sim956.agni.lindenlab.com:12035/runtime/agents"); Assert.AreEqual(testURI, tempURI.AsUri()); Assert.AreEqual(LLSDType.URI, array[1].Type); tempURI = (LLSDURI)array[1]; Assert.AreEqual("", tempURI.AsUri().ToString()); }
/// <summary> /// Attempts to convert an LLSD structure to a known Packet type /// </summary> /// <param name="capsEventName">Event name, this must match an actual /// packet name for a Packet to be successfully built</param> /// <param name="body">LLSD to convert to a Packet</param> /// <returns>A Packet on success, otherwise null</returns> public static Packet BuildPacket(string capsEventName, LLSDMap body) { Assembly assembly = Assembly.GetExecutingAssembly(); // Check if we have a subclass of packet with the same name as this event Type type = assembly.GetType("libsecondlife.Packets." + capsEventName + "Packet", false); if (type == null) { return(null); } Packet packet = null; try { // Create an instance of the object packet = (Packet)Activator.CreateInstance(type); // Iterate over all of the fields in the packet class, looking for matches in the LLSD foreach (FieldInfo field in type.GetFields()) { if (body.ContainsKey(field.Name)) { Type blockType = field.FieldType; if (blockType.IsArray) { LLSDArray array = (LLSDArray)body[field.Name]; Type elementType = blockType.GetElementType(); object[] blockArray = (object[])Array.CreateInstance(elementType, array.Count); for (int i = 0; i < array.Count; i++) { LLSDMap map = (LLSDMap)array[i]; blockArray[i] = ParseLLSDBlock(map, elementType); } field.SetValue(packet, blockArray); } else { LLSDMap map = (LLSDMap)((LLSDArray)body[field.Name])[0]; field.SetValue(packet, ParseLLSDBlock(map, blockType)); } } } } catch (Exception e) { Logger.Log(e.Message, Helpers.LogLevel.Error, e); } return(packet); }
public void DeserializeRealWorldExamples() { string realWorldExample = @" [ {'destination':'http://secondlife.com'}, {'version':i1}, { 'agent_id':u3c115e51-04f4-523c-9fa6-98aff1034730, 'session_id':u2c585cec-038c-40b0-b42e-a25ebab4d132, 'circuit_code':i1075, 'first_name':'Phoenix', 'last_name':'Linden', 'position':[r70.9247,r254.378,r38.7304], 'look_at':[r-0.043753,r-0.999042,r0], 'granters':[ua2e76fcd-9360-4f6d-a924-000000000003], 'attachment_data': [ { 'attachment_point':i2, 'item_id':ud6852c11-a74e-309a-0462-50533f1ef9b3, 'asset_id':uc69b29b1-8944-58ae-a7c5-2ca7b23e22fb }, { 'attachment_point':i10, 'item_id':uff852c22-a74e-309a-0462-50533f1ef900, 'asset_id':u5868dd20-c25a-47bd-8b4c-dedc99ef9479 } ] } ]"; // We dont do full testing here. We are fine if a few values are right // and the parser doesnt throw an exception LLSDArray llsdArray = (LLSDArray)LLSDParser.DeserializeNotation(realWorldExample); Assert.AreEqual(LLSDType.Array, llsdArray.Type); Assert.AreEqual(3, llsdArray.Count); LLSDMap llsdMapOne = (LLSDMap)llsdArray[0]; Assert.AreEqual(LLSDType.Map, llsdMapOne.Type); Assert.AreEqual("http://secondlife.com", llsdMapOne["destination"].AsString()); LLSDMap llsdMapTwo = (LLSDMap)llsdArray[1]; Assert.AreEqual(LLSDType.Map, llsdMapTwo.Type); Assert.AreEqual(LLSDType.Integer, llsdMapTwo["version"].Type); Assert.AreEqual(1, llsdMapTwo["version"].AsInteger()); LLSDMap llsdMapThree = (LLSDMap)llsdArray[2]; Assert.AreEqual(LLSDType.UUID, llsdMapThree["session_id"].Type); Assert.AreEqual("2c585cec-038c-40b0-b42e-a25ebab4d132", llsdMapThree["session_id"].AsString()); Assert.AreEqual(LLSDType.UUID, llsdMapThree["agent_id"].Type); Assert.AreEqual("3c115e51-04f4-523c-9fa6-98aff1034730", llsdMapThree["agent_id"].AsString()); }
public void SerializeFormattedTest() { // This is not a real test. Instead look at the console.out tab for how formatted notation looks like. LLSDArray llsdArray = new LLSDArray(); LLSD llsdOne = LLSD.FromInteger(1); LLSD llsdTwo = LLSD.FromInteger(1); llsdArray.Add(llsdOne); llsdArray.Add(llsdTwo); string sOne = LLSDParser.SerializeNotationFormatted(llsdArray); Console.Write(sOne); LLSDMap llsdMap = new LLSDMap(); LLSD llsdThree = LLSD.FromInteger(2); llsdMap["test1"] = llsdThree; LLSD llsdFour = LLSD.FromInteger(2); llsdMap["test2"] = llsdFour; llsdArray.Add(llsdMap); string sTwo = LLSDParser.SerializeNotationFormatted(llsdArray); Console.Write(sTwo); LLSDArray llsdArrayTwo = new LLSDArray(); LLSD llsdFive = LLSD.FromString("asdflkhjasdhj"); LLSD llsdSix = LLSD.FromString("asdkfhasjkldfghsd"); llsdArrayTwo.Add(llsdFive); llsdArrayTwo.Add(llsdSix); llsdMap["test3"] = llsdArrayTwo; string sThree = LLSDParser.SerializeNotationFormatted(llsdArray); Console.Write(sThree); // we also try to parse this... and look a little at the results LLSDArray llsdSeven = (LLSDArray)LLSDParser.DeserializeNotation(sThree); Assert.AreEqual(LLSDType.Array, llsdSeven.Type); Assert.AreEqual(3, llsdSeven.Count); Assert.AreEqual(LLSDType.Integer, llsdSeven[0].Type); Assert.AreEqual(1, llsdSeven[0].AsInteger()); Assert.AreEqual(LLSDType.Integer, llsdSeven[1].Type); Assert.AreEqual(1, llsdSeven[1].AsInteger()); Assert.AreEqual(LLSDType.Map, llsdSeven[2].Type); // thats enough for now. }
public LLSD Serialize() { LLSDArray array = new LLSDArray(accounts.Count); accounts.ForEach(delegate(Agent agent) { array.Add(LLSD.SerializeMembers(agent)); }); Logger.Log(String.Format("Serializing the agent store with {0} entries", accounts.Count), Helpers.LogLevel.Info); return(array); }
public void DeserializeArray() { string sArrayOne = "[]"; LLSDArray llsdArrayOne = (LLSDArray)LLSDParser.DeserializeNotation(sArrayOne); Assert.AreEqual(LLSDType.Array, llsdArrayOne.Type); Assert.AreEqual(0, llsdArrayOne.Count); string sArrayTwo = "[ i0 ]"; LLSDArray llsdArrayTwo = (LLSDArray)LLSDParser.DeserializeNotation(sArrayTwo); Assert.AreEqual(LLSDType.Array, llsdArrayTwo.Type); Assert.AreEqual(1, llsdArrayTwo.Count); LLSDInteger llsdIntOne = (LLSDInteger)llsdArrayTwo[0]; Assert.AreEqual(LLSDType.Integer, llsdIntOne.Type); Assert.AreEqual(0, llsdIntOne.AsInteger()); string sArrayThree = "[ i0, i1 ]"; LLSDArray llsdArrayThree = (LLSDArray)LLSDParser.DeserializeNotation(sArrayThree); Assert.AreEqual(LLSDType.Array, llsdArrayThree.Type); Assert.AreEqual(2, llsdArrayThree.Count); LLSDInteger llsdIntTwo = (LLSDInteger)llsdArrayThree[0]; Assert.AreEqual(LLSDType.Integer, llsdIntTwo.Type); Assert.AreEqual(0, llsdIntTwo.AsInteger()); LLSDInteger llsdIntThree = (LLSDInteger)llsdArrayThree[1]; Assert.AreEqual(LLSDType.Integer, llsdIntThree.Type); Assert.AreEqual(1, llsdIntThree.AsInteger()); string sArrayFour = " [ \"testtest\", \"aha\",t,f,i1, r1.2, [ i1] ] "; LLSDArray llsdArrayFour = (LLSDArray)LLSDParser.DeserializeNotation(sArrayFour); Assert.AreEqual(LLSDType.Array, llsdArrayFour.Type); Assert.AreEqual(7, llsdArrayFour.Count); Assert.AreEqual("testtest", llsdArrayFour[0].AsString()); Assert.AreEqual("aha", llsdArrayFour[1].AsString()); Assert.AreEqual(true, llsdArrayFour[2].AsBoolean()); Assert.AreEqual(false, llsdArrayFour[3].AsBoolean()); Assert.AreEqual(1, llsdArrayFour[4].AsInteger()); Assert.AreEqual(1.2d, llsdArrayFour[5].AsReal()); Assert.AreEqual(LLSDType.Array, llsdArrayFour[6].Type); LLSDArray llsdArrayFive = (LLSDArray)llsdArrayFour[6]; Assert.AreEqual(1, llsdArrayFive[0].AsInteger()); }
private void MakeSeedRequest() { if (Simulator == null || !Simulator.Client.Network.Connected) { return; } // Create a request list LLSDArray req = new LLSDArray(); req.Add("ChatSessionRequest"); req.Add("CopyInventoryFromNotecard"); req.Add("DispatchRegionInfo"); req.Add("EstateChangeInfo"); req.Add("EventQueueGet"); req.Add("FetchInventoryDescendents"); req.Add("GroupProposalBallot"); req.Add("MapLayer"); req.Add("MapLayerGod"); req.Add("NewFileAgentInventory"); req.Add("ParcelPropertiesUpdate"); req.Add("ParcelVoiceInfoRequest"); req.Add("ProvisionVoiceAccountRequest"); req.Add("RemoteParcelRequest"); req.Add("RequestTextureDownload"); req.Add("SearchStatRequest"); req.Add("SearchStatTracking"); req.Add("SendPostcard"); req.Add("SendUserReport"); req.Add("SendUserReportWithScreenshot"); req.Add("ServerReleaseNotes"); req.Add("StartGroupProposal"); req.Add("UpdateGestureAgentInventory"); req.Add("UpdateNotecardAgentInventory"); req.Add("UpdateScriptAgentInventory"); req.Add("UpdateGestureTaskInventory"); req.Add("UpdateNotecardTaskInventory"); req.Add("UpdateScriptTaskInventory"); req.Add("ViewerStartAuction"); req.Add("UntrustedSimulatorMessage"); req.Add("ViewerStats"); _SeedRequest = new CapsClient(new Uri(_SeedCapsURI)); _SeedRequest.OnComplete += new CapsClient.CompleteCallback(SeedRequestCompleteHandler); _SeedRequest.StartRequest(req); }
/// <summary> /// /// </summary> /// <returns></returns> public LLSD ToLLSD() { LLSDArray array = new LLSDArray(); // Always add default texture array.Add(DefaultTexture.ToLLSD(-1)); for (int i = 0; i < MAX_FACES; i++) { if (FaceTextures[i] != null) { array.Add(FaceTextures[i].ToLLSD(i)); } } return(array); }
public void SerializeNestedComposite() { LLSDArray llsdNested = new LLSDArray(); LLSDMap llsdMap = new LLSDMap(); LLSDArray llsdArray = new LLSDArray(); llsdArray.Add(LLSD.FromInteger(1)); llsdArray.Add(LLSD.FromInteger(2)); llsdMap["t0st"] = llsdArray; llsdMap["test"] = LLSD.FromString("what"); llsdNested.Add(llsdMap); llsdNested.Add(LLSD.FromInteger(124)); llsdNested.Add(LLSD.FromInteger(987)); byte[] binaryNestedSerialized = LLSDParser.SerializeBinary(llsdNested); // Because maps don't preserve order, we compare here to a deserialized value. LLSDArray llsdNestedDeserialized = (LLSDArray)LLSDParser.DeserializeBinary(binaryNestedSerialized); Assert.AreEqual(LLSDType.Array, llsdNestedDeserialized.Type); Assert.AreEqual(3, llsdNestedDeserialized.Count); LLSDMap llsdMapDeserialized = (LLSDMap)llsdNestedDeserialized[0]; Assert.AreEqual(LLSDType.Map, llsdMapDeserialized.Type); Assert.AreEqual(2, llsdMapDeserialized.Count); Assert.AreEqual(LLSDType.Array, llsdMapDeserialized["t0st"].Type); LLSDArray llsdNestedArray = (LLSDArray)llsdMapDeserialized["t0st"]; Assert.AreEqual(LLSDType.Array, llsdNestedArray.Type); Assert.AreEqual(2, llsdNestedArray.Count); Assert.AreEqual(LLSDType.Integer, llsdNestedArray[0].Type); Assert.AreEqual(1, llsdNestedArray[0].AsInteger()); Assert.AreEqual(LLSDType.Integer, llsdNestedArray[1].Type); Assert.AreEqual(2, llsdNestedArray[1].AsInteger()); Assert.AreEqual(LLSDType.String, llsdMapDeserialized["test"].Type); Assert.AreEqual("what", llsdMapDeserialized["test"].AsString()); Assert.AreEqual(LLSDType.Integer, llsdNestedDeserialized[1].Type); Assert.AreEqual(124, llsdNestedDeserialized[1].AsInteger()); Assert.AreEqual(LLSDType.Integer, llsdNestedDeserialized[2].Type); Assert.AreEqual(987, llsdNestedDeserialized[2].AsInteger()); }
public void DeserializeReals() { LLSD theLLSD = null; LLSDArray array = null; LLSDReal tempReal = null; String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <array> <real>44.38898</real> <real>nan</real> <real>4</real> <real>-13.333</real> <real/> </array> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testLLSD); theLLSD = LLSDParser.DeserializeXml(bytes); Assert.IsTrue(theLLSD is LLSDArray); array = (LLSDArray)theLLSD; Assert.AreEqual(LLSDType.Real, array[0].Type); tempReal = (LLSDReal)array[0]; Assert.AreEqual(44.38898d, tempReal.AsReal()); Assert.AreEqual(LLSDType.Real, array[1].Type); tempReal = (LLSDReal)array[1]; Assert.AreEqual(Double.NaN, tempReal.AsReal()); Assert.AreEqual(LLSDType.Real, array[2].Type); tempReal = (LLSDReal)array[2]; Assert.AreEqual(4.0d, tempReal.AsReal()); Assert.AreEqual(LLSDType.Real, array[3].Type); tempReal = (LLSDReal)array[3]; Assert.AreEqual(-13.333d, tempReal.AsReal()); Assert.AreEqual(LLSDType.Real, array[4].Type); tempReal = (LLSDReal)array[4]; Assert.AreEqual(0d, tempReal.AsReal()); }
public void DeserializeIntegers() { LLSD theLLSD = null; LLSDArray array = null; LLSDInteger tempInt = null; String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <array> <integer>2147483647</integer> <integer>-2147483648</integer> <integer>0</integer> <integer>013</integer> <integer/> </array> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testLLSD); theLLSD = LLSDParser.DeserializeXml(bytes); Assert.IsTrue(theLLSD is LLSDArray); array = (LLSDArray)theLLSD; Assert.AreEqual(LLSDType.Integer, array[0].Type); tempInt = (LLSDInteger)array[0]; Assert.AreEqual(2147483647, tempInt.AsInteger()); Assert.AreEqual(LLSDType.Integer, array[1].Type); tempInt = (LLSDInteger)array[1]; Assert.AreEqual(-2147483648, tempInt.AsInteger()); Assert.AreEqual(LLSDType.Integer, array[2].Type); tempInt = (LLSDInteger)array[2]; Assert.AreEqual(0, tempInt.AsInteger()); Assert.AreEqual(LLSDType.Integer, array[3].Type); tempInt = (LLSDInteger)array[3]; Assert.AreEqual(13, tempInt.AsInteger()); Assert.AreEqual(LLSDType.Integer, array[4].Type); tempInt = (LLSDInteger)array[4]; Assert.AreEqual(0, tempInt.AsInteger()); }
public void DeserializeBoolean() { LLSD theLLSD = null; LLSDArray array = null; LLSDBoolean tempBool = null; String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <array> <boolean>1</boolean> <boolean>true</boolean> <boolean>0</boolean> <boolean>false</boolean> <boolean/> </array> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testLLSD); theLLSD = LLSDParser.DeserializeXml(bytes); Assert.IsTrue(theLLSD is LLSDArray); array = (LLSDArray)theLLSD; Assert.AreEqual(LLSDType.Boolean, array[0].Type); tempBool = (LLSDBoolean)array[0]; Assert.AreEqual(true, tempBool.AsBoolean()); Assert.AreEqual(LLSDType.Boolean, array[1].Type); tempBool = (LLSDBoolean)array[1]; Assert.AreEqual(true, tempBool.AsBoolean()); Assert.AreEqual(LLSDType.Boolean, array[2].Type); tempBool = (LLSDBoolean)array[2]; Assert.AreEqual(false, tempBool.AsBoolean()); Assert.AreEqual(LLSDType.Boolean, array[3].Type); tempBool = (LLSDBoolean)array[3]; Assert.AreEqual(false, tempBool.AsBoolean()); Assert.AreEqual(LLSDType.Boolean, array[4].Type); tempBool = (LLSDBoolean)array[4]; Assert.AreEqual(false, tempBool.AsBoolean()); }
public static Vector3 ParseVector3(string key, LLSDMap reply) { LLSD llsd; if (reply.TryGetValue(key, out llsd)) { if (llsd.Type == LLSDType.Array) { return(((LLSDArray)llsd).AsVector3()); } else if (llsd.Type == LLSDType.String) { LLSDArray array = (LLSDArray)LLSDParser.DeserializeNotation(llsd.AsString()); return(array.AsVector3()); } } return(Vector3.Zero); }
public void Deserialize(LLSD serialized) { accounts.Clear(); LLSDArray array = (LLSDArray)serialized; for (int i = 0; i < array.Count; i++) { Agent agent = new Agent(); object agentRef = (object)agent; LLSD.DeserializeMembers(ref agentRef, (LLSDMap)array[i]); agent = (Agent)agentRef; accounts.Add(agent.FullName, agent.AgentID, agent); } Logger.Log(String.Format("Deserialized the agent store with {0} entries", accounts.Count), Helpers.LogLevel.Info); }
public static LLUUID ParseMappedUUID(string key, string key2, LLSDMap reply) { LLSD folderLLSD; if (reply.TryGetValue(key, out folderLLSD) && folderLLSD.Type == LLSDType.Array) { LLSDArray array = (LLSDArray)folderLLSD; if (array.Count == 1 && array[0].Type == LLSDType.Map) { LLSDMap map = (LLSDMap)array[0]; LLSD folder; if (map.TryGetValue(key2, out folder)) { return(folder.AsUUID()); } } } return(LLUUID.Zero); }
public void SerializeArray() { LLSDArray llsdEmptyArray = new LLSDArray(); byte[] binaryEmptyArraySerialized = LLSDParser.SerializeBinary(llsdEmptyArray); Assert.AreEqual(binaryEmptyArray, binaryEmptyArraySerialized); LLSDArray llsdSimpleArray = new LLSDArray(); llsdSimpleArray.Add(LLSD.FromInteger(0)); byte[] binarySimpleArraySerialized = LLSDParser.SerializeBinary(llsdSimpleArray); Assert.AreEqual(binarySimpleArray, binarySimpleArraySerialized); LLSDArray llsdSimpleArrayTwo = new LLSDArray(); llsdSimpleArrayTwo.Add(LLSD.FromInteger(0)); llsdSimpleArrayTwo.Add(LLSD.FromInteger(0)); byte[] binarySimpleArrayTwoSerialized = LLSDParser.SerializeBinary(llsdSimpleArrayTwo); Assert.AreEqual(binarySimpleArrayTwo, binarySimpleArrayTwoSerialized); }
public void DeserializeNestedComposite() { LLSD llsdNested = LLSDParser.DeserializeBinary(binaryNested); Assert.AreEqual(LLSDType.Array, llsdNested.Type); LLSDArray llsdArray = (LLSDArray)llsdNested; Assert.AreEqual(3, llsdArray.Count); LLSDMap llsdMap = (LLSDMap)llsdArray[0]; Assert.AreEqual(LLSDType.Map, llsdMap.Type); Assert.AreEqual(2, llsdMap.Count); LLSDArray llsdNestedArray = (LLSDArray)llsdMap["t0st"]; Assert.AreEqual(LLSDType.Array, llsdNestedArray.Type); LLSDInteger llsdNestedIntOne = (LLSDInteger)llsdNestedArray[0]; Assert.AreEqual(LLSDType.Integer, llsdNestedIntOne.Type); Assert.AreEqual(1, llsdNestedIntOne.AsInteger()); LLSDInteger llsdNestedIntTwo = (LLSDInteger)llsdNestedArray[1]; Assert.AreEqual(LLSDType.Integer, llsdNestedIntTwo.Type); Assert.AreEqual(2, llsdNestedIntTwo.AsInteger()); LLSDString llsdString = (LLSDString)llsdMap["test"]; Assert.AreEqual(LLSDType.String, llsdString.Type); Assert.AreEqual("what", llsdString.AsString()); LLSDInteger llsdIntOne = (LLSDInteger)llsdArray[1]; Assert.AreEqual(LLSDType.Integer, llsdIntOne.Type); Assert.AreEqual(124, llsdIntOne.AsInteger()); LLSDInteger llsdIntTwo = (LLSDInteger)llsdArray[2]; Assert.AreEqual(LLSDType.Integer, llsdIntTwo.Type); Assert.AreEqual(987, llsdIntTwo.AsInteger()); }
public void LLSDTerseParsing() { string testOne = "[r0.99967899999999998428,r-0.025334599999999998787,r0]"; string testTwo = "[[r1,r1,r1],r0]"; string testThree = "{'region_handle':[r255232, r256512], 'position':[r33.6, r33.71, r43.13], 'look_at':[r34.6, r33.71, r43.13]}"; LLSD obj = LLSDParser.DeserializeNotation(testOne); Assert.IsInstanceOfType(typeof(LLSDArray), obj, "Expected LLSDArray, got " + obj.GetType().ToString()); LLSDArray array = (LLSDArray)obj; Assert.IsTrue(array.Count == 3, "Expected three contained objects, got " + array.Count); Assert.IsTrue(array[0].AsReal() > 0.9d && array[0].AsReal() < 1.0d, "Unexpected value for first real " + array[0].AsReal()); Assert.IsTrue(array[1].AsReal() < 0.0d && array[1].AsReal() > -0.03d, "Unexpected value for second real " + array[1].AsReal()); Assert.IsTrue(array[2].AsReal() == 0.0d, "Unexpected value for third real " + array[2].AsReal()); obj = LLSDParser.DeserializeNotation(testTwo); Assert.IsInstanceOfType(typeof(LLSDArray), obj, "Expected LLSDArray, got " + obj.GetType().ToString()); array = (LLSDArray)obj; Assert.IsTrue(array.Count == 2, "Expected two contained objects, got " + array.Count); Assert.IsTrue(array[1].AsReal() == 0.0d, "Unexpected value for real " + array[1].AsReal()); obj = array[0]; Assert.IsInstanceOfType(typeof(LLSDArray), obj, "Expected ArrayList, got " + obj.GetType().ToString()); array = (LLSDArray)obj; Assert.IsTrue(array[0].AsReal() == 1.0d && array[1].AsReal() == 1.0d && array[2].AsReal() == 1.0d, "Unexpected value(s) for nested array: " + array[0].AsReal() + ", " + array[1].AsReal() + ", " + array[2].AsReal()); obj = LLSDParser.DeserializeNotation(testThree); Assert.IsInstanceOfType(typeof(LLSDMap), obj, "Expected LLSDMap, got " + obj.GetType().ToString()); LLSDMap hashtable = (LLSDMap)obj; Assert.IsTrue(hashtable.Count == 3, "Expected three contained objects, got " + hashtable.Count); Assert.IsInstanceOfType(typeof(LLSDArray), hashtable["region_handle"]); Assert.IsTrue(((LLSDArray)hashtable["region_handle"]).Count == 2); Assert.IsInstanceOfType(typeof(LLSDArray), hashtable["position"]); Assert.IsTrue(((LLSDArray)hashtable["position"]).Count == 3); Assert.IsInstanceOfType(typeof(LLSDArray), hashtable["look_at"]); Assert.IsTrue(((LLSDArray)hashtable["look_at"]).Count == 3); }
public void DeserializeStrings() { LLSD theLLSD = null; LLSDArray array = null; LLSDString tempStr = null; String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <array> <string>Kissling</string> <string>Attack ships on fire off the shoulder of Orion</string> <string>< > & ' "</string> <string/> </array> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testLLSD); theLLSD = LLSDParser.DeserializeXml(bytes); Assert.IsTrue(theLLSD is LLSDArray); array = (LLSDArray)theLLSD; Assert.AreEqual(LLSDType.String, array[0].Type); tempStr = (LLSDString)array[0]; Assert.AreEqual("Kissling", tempStr.AsString()); Assert.AreEqual(LLSDType.String, array[1].Type); tempStr = (LLSDString)array[1]; Assert.AreEqual("Attack ships on fire off the shoulder of Orion", tempStr.AsString()); Assert.AreEqual(LLSDType.String, array[2].Type); tempStr = (LLSDString)array[2]; Assert.AreEqual("< > & \' \"", tempStr.AsString()); Assert.AreEqual(LLSDType.String, array[3].Type); tempStr = (LLSDString)array[3]; Assert.AreEqual("", tempStr.AsString()); }
public void SerializeArray() { LLSDArray llsdOne = new LLSDArray(); string sOne = LLSDParser.SerializeNotation(llsdOne); LLSDArray llsdOneDS = (LLSDArray)LLSDParser.DeserializeNotation(sOne); Assert.AreEqual(LLSDType.Array, llsdOneDS.Type); Assert.AreEqual(0, llsdOneDS.Count); LLSD llsdTwo = LLSD.FromInteger(123234); LLSD llsdThree = LLSD.FromString("asedkfjhaqweiurohzasdf"); LLSDArray llsdFour = new LLSDArray(); llsdFour.Add(llsdTwo); llsdFour.Add(llsdThree); llsdOne.Add(llsdTwo); llsdOne.Add(llsdThree); llsdOne.Add(llsdFour); string sFive = LLSDParser.SerializeNotation(llsdOne); LLSDArray llsdFive = (LLSDArray)LLSDParser.DeserializeNotation(sFive); Assert.AreEqual(LLSDType.Array, llsdFive.Type); Assert.AreEqual(3, llsdFive.Count); Assert.AreEqual(LLSDType.Integer, llsdFive[0].Type); Assert.AreEqual(123234, llsdFive[0].AsInteger()); Assert.AreEqual(LLSDType.String, llsdFive[1].Type); Assert.AreEqual("asedkfjhaqweiurohzasdf", llsdFive[1].AsString()); LLSDArray llsdSix = (LLSDArray)llsdFive[2]; Assert.AreEqual(LLSDType.Array, llsdSix.Type); Assert.AreEqual(2, llsdSix.Count); Assert.AreEqual(LLSDType.Integer, llsdSix[0].Type); Assert.AreEqual(123234, llsdSix[0].AsInteger()); Assert.AreEqual(LLSDType.String, llsdSix[1].Type); Assert.AreEqual("asedkfjhaqweiurohzasdf", llsdSix[1].AsString()); }
public static LLVector3 ParseLLVector3(string key, LLSDMap reply) { LLSD llsd; if (reply.TryGetValue(key, out llsd)) { if (llsd.Type == LLSDType.Array) { LLVector3 vec = new LLVector3(); vec.FromLLSD(llsd); return(vec); } else if (llsd.Type == LLSDType.String) { LLSDArray array = (LLSDArray)LLSDParser.DeserializeNotation(llsd.AsString()); LLVector3 vec = new LLVector3(); vec.FromLLSD(array); return(vec); } } return(LLVector3.Zero); }
public void DeserializeDates() { LLSD theLLSD = null; LLSDArray array = null; LLSDDate tempDate = null; DateTime testDate; String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <array> <date>2006-02-01T14:29:53Z</date> <date>1999-01-01T00:00:00Z</date> <date/> </array> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testLLSD); theLLSD = LLSDParser.DeserializeXml(bytes); Assert.IsTrue(theLLSD is LLSDArray); array = (LLSDArray)theLLSD; Assert.AreEqual(LLSDType.Date, array[0].Type); tempDate = (LLSDDate)array[0]; DateTime.TryParse("2006-02-01T14:29:53Z", out testDate); Assert.AreEqual(testDate, tempDate.AsDate()); Assert.AreEqual(LLSDType.Date, array[1].Type); tempDate = (LLSDDate)array[1]; DateTime.TryParse("1999-01-01T00:00:00Z", out testDate); Assert.AreEqual(testDate, tempDate.AsDate()); Assert.AreEqual(LLSDType.Date, array[2].Type); tempDate = (LLSDDate)array[2]; Assert.AreEqual(Helpers.Epoch, tempDate.AsDate()); }
public void DeserializeBinary() { LLSD theLLSD = null; LLSDArray array = null; LLSDBinary tempBinary = null; String testLLSD = @"<?xml version='1.0' encoding='UTF-8'?> <llsd> <array> <binary encoding='base64'>cmFuZG9t</binary> <binary>dGhlIHF1aWNrIGJyb3duIGZveA==</binary> <binary/> </array> </llsd>"; //Deserialize the string byte[] bytes = Encoding.UTF8.GetBytes(testLLSD); theLLSD = LLSDParser.DeserializeXml(bytes); Assert.IsTrue(theLLSD is LLSDArray); array = (LLSDArray)theLLSD; Assert.AreEqual(LLSDType.Binary, array[0].Type); tempBinary = (LLSDBinary)array[0]; byte[] testData1 = { 114, 97, 110, 100, 111, 109 }; TestBinary(tempBinary, testData1); Assert.AreEqual(LLSDType.Binary, array[1].Type); tempBinary = (LLSDBinary)array[1]; byte[] testData2 = { 116, 104, 101, 32, 113, 117, 105, 99, 107, 32, 98, 114, 111, 119, 110, 32, 102, 111, 120 }; TestBinary(tempBinary, testData2); Assert.AreEqual(LLSDType.Binary, array[1].Type); tempBinary = (LLSDBinary)array[2]; Assert.AreEqual(0, tempBinary.AsBinary().Length); }
public static LLSD GetLLSD(Packet packet) { LLSDMap body = new LLSDMap(); Type type = packet.GetType(); foreach (FieldInfo field in type.GetFields()) { if (field.IsPublic) { Type blockType = field.FieldType; if (blockType.IsArray) { object blockArray = field.GetValue(packet); Array array = (Array)blockArray; LLSDArray blockList = new LLSDArray(array.Length); IEnumerator ie = array.GetEnumerator(); while (ie.MoveNext()) { object block = ie.Current; blockList.Add(BuildLLSDBlock(block)); } body[field.Name] = blockList; } else { object block = field.GetValue(packet); body[field.Name] = BuildLLSDBlock(block); } } } return body; }
private static void SerializeBinaryArray( MemoryStream stream, LLSDArray llsdArray ) { stream.WriteByte( arrayBeginBinaryMarker ); byte[] binaryNumElementsHostEnd = HostToNetworkIntBytes( llsdArray.Count ); stream.Write( binaryNumElementsHostEnd, 0, int32Length ); foreach( LLSD llsd in llsdArray ) { SerializeBinaryElement( stream, llsd ); } stream.WriteByte( arrayEndBinaryMarker ); }
private void MakeSeedRequest() { if (Simulator == null || !Simulator.Client.Network.Connected) return; // Create a request list LLSDArray req = new LLSDArray(); req.Add("MapLayer"); req.Add("MapLayerGod"); req.Add("NewFileAgentInventory"); req.Add("EventQueueGet"); req.Add("UpdateGestureAgentInventory"); req.Add("UpdateNotecardAgentInventory"); req.Add("UpdateScriptAgentInventory"); req.Add("UpdateGestureTaskInventory"); req.Add("UpdateNotecardTaskInventory"); req.Add("UpdateScriptTaskInventory"); req.Add("SendPostcard"); req.Add("ViewerStartAuction"); req.Add("ParcelGodReserveForNewbie"); req.Add("SendUserReport"); req.Add("SendUserReportWithScreenshot"); req.Add("RequestTextureDownload"); req.Add("UntrustedSimulatorMessage"); req.Add("ParcelVoiceInfoRequest"); req.Add("ChatSessionRequest"); req.Add("ProvisionVoiceAccountRequest"); _SeedRequest = new CapsClient(new Uri(_SeedCapsURI)); _SeedRequest.OnComplete += new CapsClient.CompleteCallback(SeedRequestCompleteHandler); _SeedRequest.StartRequest(req); }
private static void SerializeNotationArray(StringWriter writer, LLSDArray llsdArray) { writer.Write(arrayBeginNotationMarker); int lastIndex = llsdArray.Count - 1; for (int idx = 0; idx <= lastIndex; idx++) { SerializeNotationElement(writer, llsdArray[idx]); if (idx < lastIndex) writer.Write(kommaNotationDelimiter); } writer.Write(arrayEndNotationMarker); }
public void SerializeArray() { LLSDArray llsdEmptyArray = new LLSDArray(); byte[] binaryEmptyArraySerialized = LLSDParser.SerializeBinary(llsdEmptyArray); Assert.AreEqual(binaryEmptyArray, binaryEmptyArraySerialized); LLSDArray llsdSimpleArray = new LLSDArray(); llsdSimpleArray.Add(LLSD.FromInteger(0)); byte[] binarySimpleArraySerialized = LLSDParser.SerializeBinary(llsdSimpleArray); Assert.AreEqual(binarySimpleArray, binarySimpleArraySerialized); LLSDArray llsdSimpleArrayTwo = new LLSDArray(); llsdSimpleArrayTwo.Add(LLSD.FromInteger(0)); llsdSimpleArrayTwo.Add(LLSD.FromInteger(0)); byte[] binarySimpleArrayTwoSerialized = LLSDParser.SerializeBinary(llsdSimpleArrayTwo); Assert.AreEqual(binarySimpleArrayTwo, binarySimpleArrayTwoSerialized); }
private static void SerializeNotationArrayFormatted(StringWriter writer, string intend, LLSDArray llsdArray) { writer.Write(Helpers.NewLine); writer.Write(intend); writer.Write(arrayBeginNotationMarker); int lastIndex = llsdArray.Count - 1; for (int idx = 0; idx <= lastIndex; idx++) { if (llsdArray[idx].Type != LLSDType.Array && llsdArray[idx].Type != LLSDType.Map) writer.Write(Helpers.NewLine); writer.Write(intend + baseIntend); SerializeNotationElementFormatted(writer, intend, llsdArray[idx]); if (idx < lastIndex) { writer.Write(kommaNotationDelimiter); } } writer.Write(Helpers.NewLine); writer.Write(intend); writer.Write(arrayEndNotationMarker); }
public void SerializeArray() { LLSDArray llsdOne = new LLSDArray(); string sOne = LLSDParser.SerializeNotation(llsdOne); LLSDArray llsdOneDS = (LLSDArray)LLSDParser.DeserializeNotation(sOne); Assert.AreEqual(LLSDType.Array, llsdOneDS.Type); Assert.AreEqual(0, llsdOneDS.Count); LLSD llsdTwo = LLSD.FromInteger(123234); LLSD llsdThree = LLSD.FromString("asedkfjhaqweiurohzasdf"); LLSDArray llsdFour = new LLSDArray(); llsdFour.Add(llsdTwo); llsdFour.Add(llsdThree); llsdOne.Add(llsdTwo); llsdOne.Add(llsdThree); llsdOne.Add(llsdFour); string sFive = LLSDParser.SerializeNotation(llsdOne); LLSDArray llsdFive = (LLSDArray)LLSDParser.DeserializeNotation(sFive); Assert.AreEqual(LLSDType.Array, llsdFive.Type); Assert.AreEqual(3, llsdFive.Count); Assert.AreEqual(LLSDType.Integer, llsdFive[0].Type); Assert.AreEqual(123234, llsdFive[0].AsInteger()); Assert.AreEqual(LLSDType.String, llsdFive[1].Type); Assert.AreEqual("asedkfjhaqweiurohzasdf", llsdFive[1].AsString()); LLSDArray llsdSix = (LLSDArray)llsdFive[2]; Assert.AreEqual(LLSDType.Array, llsdSix.Type); Assert.AreEqual(2, llsdSix.Count); Assert.AreEqual(LLSDType.Integer, llsdSix[0].Type); Assert.AreEqual(123234, llsdSix[0].AsInteger()); Assert.AreEqual(LLSDType.String, llsdSix[1].Type); Assert.AreEqual("asedkfjhaqweiurohzasdf", llsdSix[1].AsString()); }
private static LLSDArray ParseXmlArray(XmlTextReader reader) { if (reader.NodeType != XmlNodeType.Element || reader.LocalName != "array") throw new LLSDException("Expected <array>"); LLSDArray array = new LLSDArray(); if (reader.IsEmptyElement) { reader.Read(); return array; } if (reader.Read()) { while (true) { SkipWhitespace(reader); if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == "array") { reader.Read(); break; } array.Add(ParseXmlElement(reader)); } } return array; }
/// <summary> /// /// </summary> /// <returns></returns> public LLSD ToLLSD() { LLSDArray array = new LLSDArray(); array.Add(LLSD.FromReal(R)); array.Add(LLSD.FromReal(G)); array.Add(LLSD.FromReal(B)); array.Add(LLSD.FromReal(A)); return array; }
private void BeginLogin() { LoginParams loginParams = CurrentContext.Value; // Sanity check if (loginParams.Options == null) loginParams.Options = new List<string>(); // Convert the password to MD5 if it isn't already if (loginParams.Password.Length != 35 && !loginParams.Password.StartsWith("$1$")) loginParams.Password = Helpers.MD5(loginParams.Password); // Override SSL authentication mechanisms. DO NOT convert this to the // .NET 2.0 preferred method, the equivalent function in Mono has a // different name and it will break compatibility! #pragma warning disable 0618 ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); // TODO: At some point, maybe we should check the cert? // Create the CAPS login structure LLSDMap loginLLSD = new LLSDMap(); loginLLSD["first"] = LLSD.FromString(loginParams.FirstName); loginLLSD["last"] = LLSD.FromString(loginParams.LastName); loginLLSD["passwd"] = LLSD.FromString(loginParams.Password); loginLLSD["start"] = LLSD.FromString(loginParams.Start); loginLLSD["channel"] = LLSD.FromString(loginParams.Channel); loginLLSD["version"] = LLSD.FromString(loginParams.Version); loginLLSD["platform"] = LLSD.FromString(loginParams.Platform); loginLLSD["mac"] = LLSD.FromString(loginParams.MAC); loginLLSD["agree_to_tos"] = LLSD.FromBoolean(true); loginLLSD["read_critical"] = LLSD.FromBoolean(true); loginLLSD["viewer_digest"] = LLSD.FromString(loginParams.ViewerDigest); loginLLSD["id0"] = LLSD.FromString(loginParams.id0); // Create the options LLSD array LLSDArray optionsLLSD = new LLSDArray(); for (int i = 0; i < loginParams.Options.Count; i++) optionsLLSD.Add(LLSD.FromString(loginParams.Options[i])); foreach (string[] callbackOpts in CallbackOptions.Values) { if (callbackOpts != null) { for (int i = 0; i < callbackOpts.Length; i++) { if (!optionsLLSD.Contains(callbackOpts[i])) optionsLLSD.Add(callbackOpts[i]); } } } loginLLSD["options"] = optionsLLSD; // Make the CAPS POST for login Uri loginUri; try { loginUri = new Uri(loginParams.URI); } catch (Exception ex) { Logger.Log(String.Format("Failed to parse login URI {0}, {1}", loginParams.URI, ex.Message), Helpers.LogLevel.Error, Client); return; } CapsClient loginRequest = new CapsClient(new Uri(loginParams.URI)); loginRequest.OnComplete += new CapsClient.CompleteCallback(LoginReplyHandler); loginRequest.UserData = CurrentContext; loginRequest.StartRequest(LLSDParser.SerializeXmlBytes(loginLLSD), "application/xml+llsd"); }
private void MakeSeedRequest() { if (Simulator == null || !Simulator.Client.Network.Connected) return; // Create a request list LLSDArray req = new LLSDArray(); req.Add("ChatSessionRequest"); req.Add("CopyInventoryFromNotecard"); req.Add("DispatchRegionInfo"); req.Add("EstateChangeInfo"); req.Add("EventQueueGet"); req.Add("FetchInventoryDescendents"); req.Add("GroupProposalBallot"); req.Add("MapLayer"); req.Add("MapLayerGod"); req.Add("NewFileAgentInventory"); req.Add("ParcelPropertiesUpdate"); req.Add("ParcelVoiceInfoRequest"); req.Add("ProvisionVoiceAccountRequest"); req.Add("RemoteParcelRequest"); req.Add("RequestTextureDownload"); req.Add("SearchStatRequest"); req.Add("SearchStatTracking"); req.Add("SendPostcard"); req.Add("SendUserReport"); req.Add("SendUserReportWithScreenshot"); req.Add("ServerReleaseNotes"); req.Add("StartGroupProposal"); req.Add("UpdateGestureAgentInventory"); req.Add("UpdateNotecardAgentInventory"); req.Add("UpdateScriptAgentInventory"); req.Add("UpdateGestureTaskInventory"); req.Add("UpdateNotecardTaskInventory"); req.Add("UpdateScriptTaskInventory"); req.Add("ViewerStartAuction"); req.Add("UntrustedSimulatorMessage"); req.Add("ViewerStats"); _SeedRequest = new CapsClient(new Uri(_SeedCapsURI)); _SeedRequest.OnComplete += new CapsClient.CompleteCallback(SeedRequestCompleteHandler); _SeedRequest.StartRequest(req); }
public LLSD ToLLSD() { LLSDArray array = new LLSDArray(); array.Add(LLSD.FromReal(X)); array.Add(LLSD.FromReal(Y)); array.Add(LLSD.FromReal(Z)); return array; }
private static LLSD DeserializeNotationArray(StringReader reader) { int character; LLSDArray llsdArray = new LLSDArray(); while (((character = PeekAndSkipWhitespace(reader)) > 0) && ((char)character != arrayEndNotationMarker)) { llsdArray.Add(DeserializeNotationElement(reader)); character = ReadAndSkipWhitespace(reader); if (character < 0) throw new LLSDException("Notation LLSD parsing: Unexpected end of array discovered."); else if ((char)character == kommaNotationDelimiter) continue; else if ((char)character == arrayEndNotationMarker) break; } if (character < 0) throw new LLSDException("Notation LLSD parsing: Unexpected end of array discovered."); return (LLSD)llsdArray; }
private static LLSD ParseBinaryArray(MemoryStream stream) { int numElements = NetworkToHostInt( ConsumeBytes( stream, int32Length )); int crrElement = 0; LLSDArray llsdArray = new LLSDArray(); while ( crrElement < numElements ) { llsdArray.Add( ParseBinaryElement( stream )); crrElement++; } if ( !FindByte( stream, arrayEndBinaryMarker )) throw new LLSDException( "Binary LLSD parsing: Missing end marker in array." ); return (LLSD)llsdArray; }
public void SerializeFormattedTest() { // This is not a real test. Instead look at the console.out tab for how formatted notation looks like. LLSDArray llsdArray = new LLSDArray(); LLSD llsdOne = LLSD.FromInteger(1); LLSD llsdTwo = LLSD.FromInteger(1); llsdArray.Add(llsdOne); llsdArray.Add(llsdTwo); string sOne = LLSDParser.SerializeNotationFormatted(llsdArray); Console.Write(sOne); LLSDMap llsdMap = new LLSDMap(); LLSD llsdThree = LLSD.FromInteger(2); llsdMap["test1"] = llsdThree; LLSD llsdFour = LLSD.FromInteger(2); llsdMap["test2"] = llsdFour; llsdArray.Add(llsdMap); string sTwo = LLSDParser.SerializeNotationFormatted(llsdArray); Console.Write(sTwo); LLSDArray llsdArrayTwo = new LLSDArray(); LLSD llsdFive = LLSD.FromString("asdflkhjasdhj"); LLSD llsdSix = LLSD.FromString("asdkfhasjkldfghsd"); llsdArrayTwo.Add(llsdFive); llsdArrayTwo.Add(llsdSix); llsdMap["test3"] = llsdArrayTwo; string sThree = LLSDParser.SerializeNotationFormatted(llsdArray); Console.Write(sThree); // we also try to parse this... and look a little at the results LLSDArray llsdSeven = (LLSDArray)LLSDParser.DeserializeNotation(sThree); Assert.AreEqual(LLSDType.Array, llsdSeven.Type); Assert.AreEqual(3, llsdSeven.Count); Assert.AreEqual(LLSDType.Integer, llsdSeven[0].Type); Assert.AreEqual(1, llsdSeven[0].AsInteger()); Assert.AreEqual(LLSDType.Integer, llsdSeven[1].Type); Assert.AreEqual(1, llsdSeven[1].AsInteger()); Assert.AreEqual(LLSDType.Map, llsdSeven[2].Type); // thats enough for now. }
private static LLSD ParseNotationElement(string notationData, out int endPos) { if (notationData.Length == 0) { endPos = 0; return null; } // Identify what type of object this is switch (notationData[0]) { case '!': endPos = 1; return new LLSD(); case '1': endPos = 1; return LLSD.FromBoolean(true); case '0': endPos = 1; return LLSD.FromBoolean(false); case 'i': { if (notationData.Length < 2) { endPos = notationData.Length; return LLSD.FromInteger(0); } int value; endPos = FindEnd(notationData, 1); if (Helpers.TryParse(notationData.Substring(1, endPos - 1), out value)) return LLSD.FromInteger(value); else return LLSD.FromInteger(0); } case 'r': { if (notationData.Length < 2) { endPos = notationData.Length; return LLSD.FromReal(0d); } double value; endPos = FindEnd(notationData, 1); if (Helpers.TryParse(notationData.Substring(1, endPos - 1), out value)) return LLSD.FromReal(value); else return LLSD.FromReal(0d); } case 'u': { if (notationData.Length < 17) { endPos = notationData.Length; return LLSD.FromUUID(LLUUID.Zero); } LLUUID value; endPos = FindEnd(notationData, 1); if (Helpers.TryParse(notationData.Substring(1, endPos - 1), out value)) return LLSD.FromUUID(value); else return LLSD.FromUUID(LLUUID.Zero); } case 'b': throw new NotImplementedException("Notation binary type is unimplemented"); case 's': case '"': case '\'': if (notationData.Length < 2) { endPos = notationData.Length; return LLSD.FromString(String.Empty); } endPos = FindEnd(notationData, 1); return LLSD.FromString(notationData.Substring(1, endPos - 1).Trim(new char[] { '"', '\'' })); case 'l': throw new NotImplementedException("Notation URI type is unimplemented"); case 'd': throw new NotImplementedException("Notation date type is unimplemented"); case '[': { if (notationData.IndexOf(']') == -1) throw new LLSDException("Invalid notation array"); int pos = 0; LLSDArray array = new LLSDArray(); while (notationData[pos] != ']') { ++pos; // Advance past comma if need be if (notationData[pos] == ',') ++pos; // Allow a single whitespace character if (pos < notationData.Length && notationData[pos] == ' ') ++pos; int end; array.Add(ParseNotationElement(notationData.Substring(pos), out end)); pos += end; } endPos = pos + 1; return array; } case '{': { if (notationData.IndexOf('}') == -1) throw new LLSDException("Invalid notation map"); int pos = 0; LLSDMap hashtable = new LLSDMap(); while (notationData[pos] != '}') { ++pos; // Advance past comma if need be if (notationData[pos] == ',') ++pos; // Allow a single whitespace character if (pos < notationData.Length && notationData[pos] == ' ') ++pos; if (notationData[pos] != '\'') throw new LLSDException("Expected a map key"); int endquote = notationData.IndexOf('\'', pos + 1); if (endquote == -1 || (endquote + 1) >= notationData.Length || notationData[endquote + 1] != ':') throw new LLSDException("Invalid map format"); string key = notationData.Substring(pos, endquote - pos); key = key.Trim(new char[] { '"', '\'' }); //key.Replace("'", String.Empty); pos += (endquote - pos) + 2; int end; hashtable[key] = ParseNotationElement(notationData.Substring(pos), out end); pos += end; } endPos = pos + 1; return hashtable; } default: throw new LLSDException("Unknown notation value type"); } }
public void SerializeNestedComposite() { LLSDArray llsdNested = new LLSDArray(); LLSDMap llsdMap = new LLSDMap(); LLSDArray llsdArray = new LLSDArray(); llsdArray.Add(LLSD.FromInteger(1)); llsdArray.Add(LLSD.FromInteger(2)); llsdMap["t0st"] = llsdArray; llsdMap["test"] = LLSD.FromString("what"); llsdNested.Add(llsdMap); llsdNested.Add(LLSD.FromInteger(124)); llsdNested.Add(LLSD.FromInteger(987)); byte[] binaryNestedSerialized = LLSDParser.SerializeBinary(llsdNested); // Because maps don't preserve order, we compare here to a deserialized value. LLSDArray llsdNestedDeserialized = (LLSDArray)LLSDParser.DeserializeBinary(binaryNestedSerialized); Assert.AreEqual(LLSDType.Array, llsdNestedDeserialized.Type); Assert.AreEqual(3, llsdNestedDeserialized.Count); LLSDMap llsdMapDeserialized = (LLSDMap)llsdNestedDeserialized[0]; Assert.AreEqual(LLSDType.Map, llsdMapDeserialized.Type); Assert.AreEqual(2, llsdMapDeserialized.Count); Assert.AreEqual(LLSDType.Array, llsdMapDeserialized["t0st"].Type); LLSDArray llsdNestedArray = (LLSDArray)llsdMapDeserialized["t0st"]; Assert.AreEqual(LLSDType.Array, llsdNestedArray.Type); Assert.AreEqual(2, llsdNestedArray.Count); Assert.AreEqual(LLSDType.Integer, llsdNestedArray[0].Type); Assert.AreEqual(1, llsdNestedArray[0].AsInteger()); Assert.AreEqual(LLSDType.Integer, llsdNestedArray[1].Type); Assert.AreEqual(2, llsdNestedArray[1].AsInteger()); Assert.AreEqual(LLSDType.String, llsdMapDeserialized["test"].Type); Assert.AreEqual("what", llsdMapDeserialized["test"].AsString()); Assert.AreEqual(LLSDType.Integer, llsdNestedDeserialized[1].Type); Assert.AreEqual(124, llsdNestedDeserialized[1].AsInteger()); Assert.AreEqual(LLSDType.Integer, llsdNestedDeserialized[2].Type); Assert.AreEqual(987, llsdNestedDeserialized[2].AsInteger()); }
/// <summary> /// /// </summary> /// <returns></returns> public LLSD ToLLSD() { LLSDArray array = new LLSDArray(); // Always add default texture array.Add(DefaultTexture.ToLLSD(-1)); for (int i = 0; i < MAX_FACES; i++) { if (FaceTextures[i] != null) array.Add(FaceTextures[i].ToLLSD(i)); } return array; }
public void ToXmlRpc(XmlWriter writer) { writer.WriteStartElement("methodResponse"); { writer.WriteStartElement("params"); writer.WriteStartElement("param"); writer.WriteStartElement("value"); writer.WriteStartElement("struct"); { if (Success) { // session_id WriteXmlRpcStringMember(writer, false, "session_id", SessionID.ToString()); // ui-config WriteXmlRpcArrayStart(writer, "ui-config"); WriteXmlRpcStringMember(writer, true, "allow_first_life", "Y"); WriteXmlRpcArrayEnd(writer); // inventory-lib-owner WriteXmlRpcArrayStart(writer, "inventory-lib-owner"); WriteXmlRpcStringMember(writer, true, "agent_id", LibraryOwner.ToString()); WriteXmlRpcArrayEnd(writer); // start_location WriteXmlRpcStringMember(writer, false, "start_location", StartLocation); // seconds_since_epoch WriteXmlRpcIntMember(writer, false, "seconds_since_epoch", Utils.DateTimeToUnixTime(SecondsSinceEpoch)); // event_categories (TODO) WriteXmlRpcArrayStart(writer, "event_categories"); WriteXmlRpcCategory(writer, "Default", 20); WriteXmlRpcArrayEnd(writer); // tutorial_setting (TODO) WriteXmlRpcArrayStart(writer, "tutorial_setting"); WriteXmlRpcTutorialSetting(writer, "http://127.0.0.1/tutorial/"); WriteXmlRpcArrayEnd(writer); // classified_categories (TODO) WriteXmlRpcArrayStart(writer, "classified_categories"); WriteXmlRpcCategory(writer, "Default", 1); WriteXmlRpcArrayEnd(writer); // inventory-root WriteXmlRpcArrayStart(writer, "inventory-root"); WriteXmlRpcStringMember(writer, true, "folder_id", InventoryRoot.ToString()); WriteXmlRpcArrayEnd(writer); // sim_port WriteXmlRpcIntMember(writer, false, "sim_port", SimPort); // agent_id WriteXmlRpcStringMember(writer, false, "agent_id", AgentID.ToString()); // agent_access WriteXmlRpcStringMember(writer, false, "agent_access", AgentAccess); // inventory-skeleton WriteXmlRpcArrayStart(writer, "inventory-skeleton"); WriteXmlRpcInventoryItem(writer, "Inventory", UUID.Zero, 1, (uint)InventoryType.RootCategory, InventoryRoot); WriteXmlRpcArrayEnd(writer); // buddy-list WriteXmlRpcArrayStart(writer, "buddy-list"); WriteXmlRpcBuddy(writer, 0, 0, UUID.Random()); WriteXmlRpcArrayEnd(writer); // first_name WriteXmlRpcStringMember(writer, false, "first_name", FirstName); // global-textures WriteXmlRpcArrayStart(writer, "global-textures"); writer.WriteStartElement("value"); writer.WriteStartElement("struct"); { WriteXmlRpcStringMember(writer, false, "sun_texture_id", "cce0f112-878f-4586-a2e2-a8f104bba271"); WriteXmlRpcStringMember(writer, false, "cloud_texture_id", "fc4b9f0b-d008-45c6-96a4-01dd947ac621"); WriteXmlRpcStringMember(writer, false, "moon_texture_id", "d07f6eed-b96a-47cd-b51d-400ad4a1c428"); } writer.WriteEndElement(); writer.WriteEndElement(); WriteXmlRpcArrayEnd(writer); // inventory-skel-lib WriteXmlRpcArrayStart(writer, "inventory-skel-lib"); WriteXmlRpcInventoryItem(writer, "Library", UUID.Zero, 1, (uint)InventoryType.RootCategory, LibraryRoot); WriteXmlRpcArrayEnd(writer); // seed_capability WriteXmlRpcStringMember(writer, false, "seed_capability", SeedCapability); // gestures WriteXmlRpcArrayStart(writer, "gestures"); WriteXmlRpcGesture(writer, UUID.Random(), UUID.Random()); WriteXmlRpcArrayEnd(writer); // sim_ip WriteXmlRpcStringMember(writer, false, "sim_ip", SimIP.ToString()); // inventory-lib-root WriteXmlRpcArrayStart(writer, "inventory-lib-root"); WriteXmlRpcStringMember(writer, true, "folder_id", LibraryRoot.ToString()); WriteXmlRpcArrayEnd(writer); // login-flags WriteXmlRpcArrayStart(writer, "login-flags"); writer.WriteStartElement("value"); writer.WriteStartElement("struct"); { WriteXmlRpcStringMember(writer, false, "gendered", "Y"); WriteXmlRpcStringMember(writer, false, "stipend_since_login", "N"); WriteXmlRpcStringMember(writer, false, "ever_logged_in", "Y"); if (DateTime.Now.IsDaylightSavingTime()) WriteXmlRpcStringMember(writer, false, "daylight_savings", "Y"); else WriteXmlRpcStringMember(writer, false, "daylight_savings", "N"); } writer.WriteEndElement(); writer.WriteEndElement(); WriteXmlRpcArrayEnd(writer); // inventory_host WriteXmlRpcStringMember(writer, false, "inventory_host", IPAddress.Loopback.ToString()); // home LLSDMap home = new LLSDMap(3); LLSDArray homeRegionHandle = new LLSDArray(2); uint homeRegionX, homeRegionY; Helpers.LongToUInts(HomeRegion, out homeRegionX, out homeRegionY); homeRegionHandle.Add(LLSD.FromReal((double)homeRegionX)); homeRegionHandle.Add(LLSD.FromReal((double)homeRegionY)); home["region_handle"] = homeRegionHandle; home["position"] = LLSD.FromVector3(HomePosition); home["look_at"] = LLSD.FromVector3(HomeLookAt); WriteXmlRpcStringMember(writer, false, "home", LLSDParser.SerializeNotation(home)); // message WriteXmlRpcStringMember(writer, false, "message", Message); // look_at WriteXmlRpcStringMember(writer, false, "look_at", LLSDParser.SerializeNotation(LLSD.FromVector3(LookAt))); // login WriteXmlRpcStringMember(writer, false, "login", "true"); // event_notifications WriteXmlRpcArrayStart(writer, "event_notifications"); WriteXmlRpcArrayEnd(writer); // secure_session_id WriteXmlRpcStringMember(writer, false, "secure_session_id", SecureSessionID.ToString()); // region_x WriteXmlRpcIntMember(writer, false, "region_x", RegionX); // last_name WriteXmlRpcStringMember(writer, false, "last_name", LastName); // region_y WriteXmlRpcIntMember(writer, false, "region_y", RegionY); // circuit_code WriteXmlRpcIntMember(writer, false, "circuit_code", CircuitCode); // initial-outfit WriteXmlRpcArrayStart(writer, "initial-outfit"); WriteXmlRpcArrayEnd(writer); } else { // Login failure } } writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); writer.WriteEndElement(); } writer.WriteEndElement(); writer.Close(); }