A message sent from the viewer to the simulator requesting the update of an existing script contained within a tasks inventory
Inheritance: AssetUploaderBlock
Example #1
0
        /// <summary>
        /// Update an existing script in an task Inventory
        /// </summary>
        /// <param name="data">A byte[] array containing the encoded scripts contents</param>
        /// <param name="itemID">the itemID of the script</param>
        /// <param name="taskID">UUID of the prim containting the script</param>
        /// <param name="mono">if true, sets the script content to run on the mono interpreter</param>
        /// <param name="running">if true, sets the script to running</param>
        /// <param name="callback"></param>
        public void RequestUpdateScriptTask(byte[] data, UUID itemID, UUID taskID, bool mono, bool running, ScriptUpdatedCallback callback)
        {
            Uri url = Client.Network.CurrentSim.Caps.CapabilityURI("UpdateScriptTask");

            if (url != null)
            {
                UpdateScriptTaskUpdateMessage msg = new UpdateScriptTaskUpdateMessage();
                msg.ItemID = itemID;
                msg.TaskID = taskID;
                msg.ScriptRunning = running;
                msg.Target = mono ? "mono" : "lsl2";

                CapsClient request = new CapsClient(url);
                request.OnComplete += new CapsClient.CompleteCallback(UpdateScriptAgentInventoryResponse);
                request.UserData = new object[2] { new KeyValuePair<ScriptUpdatedCallback, byte[]>(callback, data), itemID };
                request.BeginGetResponse(msg.Serialize(), OSDFormat.Xml, Client.Settings.CAPS_TIMEOUT);
            }
            else
            {
                throw new Exception("UpdateScriptTask capability is not currently available");
            }
        }
        public void UpdateScriptTaskMessage()
        {
            UpdateScriptTaskUpdateMessage s = new UpdateScriptTaskUpdateMessage();
            s.TaskID = UUID.Random();
            s.Target = "mono";
            s.ScriptRunning = true;
            s.ItemID = UUID.Random();

            OSDMap map = s.Serialize();
            UpdateScriptTaskUpdateMessage t = new UpdateScriptTaskUpdateMessage();
            t.Deserialize(map);

            Assert.AreEqual(s.ItemID, t.ItemID);
            Assert.AreEqual(s.ScriptRunning, t.ScriptRunning);
            Assert.AreEqual(s.Target, t.Target);
            Assert.AreEqual(s.TaskID, t.TaskID);
        }