Implemented: llSetText, llResetScript
Implemented: llHTTPRequest (queue, thread, etc -- but not actuall call)afrisby
parent
88968622ea
commit
c654506b18
|
@ -612,8 +612,8 @@ namespace OpenSim.Region.ScriptEngine.Common
|
|||
//wiki: integer llGetRegionFlags()
|
||||
int llGetRegionFlags();
|
||||
//wiki: string llXorBase64StringsCorrect(string str1, string str2)
|
||||
string llXorBase64StringsCorrect(string str1, string str2);
|
||||
void llHTTPRequest();
|
||||
string llXorBase64StringsCorrect(string str1, string str2);
|
||||
void llHTTPRequest(string url, List<string> parameters, string body);
|
||||
//wiki: llResetLandBanList()
|
||||
void llResetLandBanList();
|
||||
//wiki: llResetLandPassList()
|
||||
|
|
|
@ -96,13 +96,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
AppDomainSetup ads = new AppDomainSetup();
|
||||
ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
|
||||
ads.DisallowBindingRedirects = false;
|
||||
ads.DisallowCodeDownload = true;
|
||||
ads.DisallowCodeDownload = true;
|
||||
ads.LoaderOptimization = LoaderOptimization.MultiDomain; // Sounds good ;)
|
||||
ads.ShadowCopyFiles = "true"; // Enabled shadowing
|
||||
ads.ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
||||
|
||||
AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads);
|
||||
Console.WriteLine("Loading: " + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString());
|
||||
AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" + AppDomainNameCount, null, ads);
|
||||
Console.WriteLine("Loading: " + AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll").ToString());
|
||||
AD.Load(AssemblyName.GetAssemblyName("OpenSim.Region.ScriptEngine.Common.dll"));
|
||||
|
||||
// Return the new AppDomain
|
||||
|
|
|
@ -18,8 +18,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
|||
dataTypes.Add("integer", "int");
|
||||
dataTypes.Add("float", "double");
|
||||
dataTypes.Add("string", "string");
|
||||
dataTypes.Add("key", "string");
|
||||
dataTypes.Add("vector", "LSL_Types.Vector3");
|
||||
dataTypes.Add("key", "string");
|
||||
dataTypes.Add("vector", "LSL_Types.Vector3");
|
||||
dataTypes.Add("rotation", "LSL_Types.Quaternion");
|
||||
dataTypes.Add("list", "list");
|
||||
dataTypes.Add("null", "null");
|
||||
|
@ -225,9 +225,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
|||
}
|
||||
|
||||
|
||||
// Add namespace, class name and inheritance
|
||||
|
||||
Return = "" +
|
||||
// Add namespace, class name and inheritance
|
||||
|
||||
Return = "" +
|
||||
"using OpenSim.Region.ScriptEngine.Common;";
|
||||
//"using System; " +
|
||||
//"using System.Collections.Generic; " +
|
||||
|
|
|
@ -45,7 +45,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
|||
}
|
||||
}
|
||||
|
||||
public LSL_BuiltIn_Commands_Interface m_LSL_Functions;
|
||||
public LSL_BuiltIn_Commands_Interface m_LSL_Functions;
|
||||
public string SourceCode = "";
|
||||
|
||||
public LSL_BaseClass()
|
||||
{
|
||||
|
@ -452,8 +453,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
|||
public int llGetUnixTime() { return m_LSL_Functions.llGetUnixTime(); }
|
||||
public int llGetParcelFlags(LSL_Types.Vector3 pos) { return m_LSL_Functions.llGetParcelFlags(pos); }
|
||||
public int llGetRegionFlags() { return m_LSL_Functions.llGetRegionFlags(); }
|
||||
public string llXorBase64StringsCorrect(string str1, string str2) { return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); }
|
||||
public void llHTTPRequest() { m_LSL_Functions.llHTTPRequest(); }
|
||||
public string llXorBase64StringsCorrect(string str1, string str2) { return m_LSL_Functions.llXorBase64StringsCorrect(str1, str2); }
|
||||
public void llHTTPRequest(string url, List<string> parameters, string body) { m_LSL_Functions.llHTTPRequest(url, parameters, body); }
|
||||
public void llResetLandBanList() { m_LSL_Functions.llResetLandBanList(); }
|
||||
public void llResetLandPassList() { m_LSL_Functions.llResetLandPassList(); }
|
||||
public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { return m_LSL_Functions.llGetParcelPrimCount(pos, category, sim_wide); }
|
||||
|
|
|
@ -327,7 +327,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
return src.Substring(start, end);
|
||||
}
|
||||
|
||||
public string llDeleteSubString(string src, int start, int end)
|
||||
public string llDeleteSubString(string src, int start, int end)
|
||||
{
|
||||
return src.Remove(start, end - start);
|
||||
}
|
||||
|
@ -431,7 +431,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
public void llGiveInventory(string destination, string inventory) { NotImplemented("llGiveInventory"); }
|
||||
public void llRemoveInventory(string item) { NotImplemented("llRemoveInventory"); }
|
||||
|
||||
public void llSetText(string text, LSL_Types.Vector3 color, double alpha) { NotImplemented("llSetText"); }
|
||||
public void llSetText(string text, LSL_Types.Vector3 color, double alpha)
|
||||
{
|
||||
Axiom.Math.Vector3 av3 = new Axiom.Math.Vector3((float)color.X, (float)color.Y, (float)color.Z);
|
||||
m_host.SetText(text, av3, alpha);
|
||||
}
|
||||
|
||||
|
||||
public double llWater(LSL_Types.Vector3 offset) { NotImplemented("llWater"); return 0; }
|
||||
public void llPassTouches(int pass) { NotImplemented("llPassTouches"); }
|
||||
|
@ -443,7 +448,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
public void llCollisionSound(string impact_sound, double impact_volume) { NotImplemented("llCollisionSound"); }
|
||||
public void llCollisionSprite(string impact_sprite) { NotImplemented("llCollisionSprite"); }
|
||||
public string llGetAnimation(string id) { NotImplemented("llGetAnimation"); return ""; }
|
||||
public void llResetScript() { }
|
||||
public void llResetScript()
|
||||
{
|
||||
m_ScriptEngine.m_ScriptManager.ResetScript(m_localID, m_itemID);
|
||||
}
|
||||
public void llMessageLinked(int linknum, int num, string str, string id) { }
|
||||
public void llPushObject(string target, LSL_Types.Vector3 impulse, LSL_Types.Vector3 ang_impulse, int local) { }
|
||||
public void llPassCollisions(int pass) { }
|
||||
|
@ -482,7 +490,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
|
||||
public LSL_Types.Vector3 llGetCenterOfMass() { NotImplemented("llGetCenterOfMass"); return new LSL_Types.Vector3(); }
|
||||
|
||||
public List<string> llListSort(List<string> src, int stride, int ascending) {
|
||||
public List<string> llListSort(List<string> src, int stride, int ascending)
|
||||
{
|
||||
SortedList<string, List<string>> sorted = new SortedList<string, List<string>>();
|
||||
// Add chunks to an array
|
||||
int s = stride;
|
||||
|
@ -497,7 +506,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
if (c > s)
|
||||
{
|
||||
sorted.Add(chunkString, chunk);
|
||||
chunkString = "";
|
||||
chunkString = "";
|
||||
chunk = new List<string>();
|
||||
c = 0;
|
||||
}
|
||||
|
@ -554,7 +563,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
{
|
||||
return new LSL_Types.Vector3(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2]));
|
||||
}
|
||||
public LSL_Types.Quaternion llList2Rot(List<string> src, int index) {
|
||||
public LSL_Types.Quaternion llList2Rot(List<string> src, int index)
|
||||
{
|
||||
return new LSL_Types.Quaternion(double.Parse(src[index]), double.Parse(src[index + 1]), double.Parse(src[index + 2]), double.Parse(src[index + 3]));
|
||||
}
|
||||
public List<string> llList2List(List<string> src, int start, int end)
|
||||
|
@ -632,7 +642,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
if (chunk.Count > 0)
|
||||
tmp.Add(chunk);
|
||||
|
||||
// Decreate array back into a list
|
||||
// Decreate (<- what kind of word is that? :D ) array back into a list
|
||||
int rnd;
|
||||
List<string> ret = new List<string>();
|
||||
while (tmp.Count > 0)
|
||||
|
@ -649,7 +659,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
|
||||
|
||||
}
|
||||
public List<string> llList2ListStrided(List<string> src, int start, int end, int stride)
|
||||
public List<string> llList2ListStrided(List<string> src, int start, int end, int stride)
|
||||
{
|
||||
List<string> ret = new List<string>();
|
||||
int s = stride;
|
||||
|
@ -657,9 +667,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
s = 1;
|
||||
|
||||
int sc = s;
|
||||
for (int i = start; i < src.Count; i++) {
|
||||
for (int i = start; i < src.Count; i++)
|
||||
{
|
||||
sc--;
|
||||
if (sc ==0) {
|
||||
if (sc == 0)
|
||||
{
|
||||
sc = s;
|
||||
// Addthis
|
||||
ret.Add(src[i]);
|
||||
|
@ -795,7 +807,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
}
|
||||
|
||||
public void llSetPrimitiveParams(List<string> rules) { NotImplemented("llSetPrimitiveParams"); }
|
||||
public string llStringToBase64(string str) {
|
||||
public string llStringToBase64(string str)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -808,14 +821,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
{
|
||||
throw new Exception("Error in base64Encode" + e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string llBase64ToString(string str) {
|
||||
public string llBase64ToString(string str)
|
||||
{
|
||||
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
|
||||
System.Text.Decoder utf8Decode = encoder.GetDecoder();
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
byte[] todecode_byte = Convert.FromBase64String(str);
|
||||
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
|
||||
char[] decoded_char = new char[charCount];
|
||||
|
@ -861,11 +875,13 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
public List<string> llGetBoundingBox(string obj) { NotImplemented("llGetBoundingBox"); return new List<string>(); }
|
||||
public LSL_Types.Vector3 llGetGeometricCenter() { NotImplemented("llGetGeometricCenter"); return new LSL_Types.Vector3(); }
|
||||
public void llGetPrimitiveParams() { NotImplemented("llGetPrimitiveParams"); }
|
||||
public string llIntegerToBase64(int number) {
|
||||
NotImplemented("llIntegerToBase64"); return "";
|
||||
public string llIntegerToBase64(int number)
|
||||
{
|
||||
NotImplemented("llIntegerToBase64"); return "";
|
||||
}
|
||||
public int llBase64ToInteger(string str) {
|
||||
NotImplemented("llBase64ToInteger"); return 0;
|
||||
public int llBase64ToInteger(string str)
|
||||
{
|
||||
NotImplemented("llBase64ToInteger"); return 0;
|
||||
}
|
||||
|
||||
public double llGetGMTclock()
|
||||
|
@ -957,7 +973,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
|
||||
public int llGetParcelFlags(LSL_Types.Vector3 pos) { NotImplemented("llGetParcelFlags"); return 0; }
|
||||
public int llGetRegionFlags() { NotImplemented("llGetRegionFlags"); return 0; }
|
||||
public string llXorBase64StringsCorrect(string str1, string str2) {
|
||||
public string llXorBase64StringsCorrect(string str1, string str2)
|
||||
{
|
||||
string ret = "";
|
||||
string src1 = llBase64ToString(str1);
|
||||
string src2 = llBase64ToString(str2);
|
||||
|
@ -972,7 +989,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler
|
|||
}
|
||||
return llStringToBase64(ret);
|
||||
}
|
||||
public void llHTTPRequest() { NotImplemented("llHTTPRequest"); }
|
||||
public void llHTTPRequest(string url, List<string> parameters, string body)
|
||||
{
|
||||
m_ScriptEngine.m_LSLLongCmdHandler.StartHttpRequest(m_localID, m_itemID, url, parameters, body);
|
||||
}
|
||||
public void llResetLandBanList() { NotImplemented("llResetLandBanList"); }
|
||||
public void llResetLandPassList() { NotImplemented("llResetLandPassList"); }
|
||||
public int llGetParcelPrimCount(LSL_Types.Vector3 pos, int category, int sim_wide) { NotImplemented("llGetParcelPrimCount"); return 0; }
|
||||
|
|
|
@ -1,148 +1,262 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
|
||||
/// </summary>
|
||||
class LSLLongCmdHandler
|
||||
{
|
||||
private Thread cmdHandlerThread;
|
||||
private int cmdHandlerThreadCycleSleepms = 100;
|
||||
|
||||
private ScriptEngine m_ScriptEngine;
|
||||
public LSLLongCmdHandler(ScriptEngine _ScriptEngine)
|
||||
{
|
||||
m_ScriptEngine = _ScriptEngine;
|
||||
|
||||
// Start the thread that will be doing the work
|
||||
cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
|
||||
cmdHandlerThread.Name = "CmdHandlerThread";
|
||||
cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
|
||||
cmdHandlerThread.IsBackground = true;
|
||||
cmdHandlerThread.Start();
|
||||
}
|
||||
~LSLLongCmdHandler()
|
||||
{
|
||||
// Shut down thread
|
||||
try
|
||||
{
|
||||
if (cmdHandlerThread != null)
|
||||
{
|
||||
if (cmdHandlerThread.IsAlive == true)
|
||||
{
|
||||
cmdHandlerThread.Abort();
|
||||
cmdHandlerThread.Join();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void CmdHandlerThreadLoop()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// Check timers
|
||||
CheckTimerEvents();
|
||||
|
||||
// Sleep before next cycle
|
||||
Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a specific script (and all its pending commands)
|
||||
/// </summary>
|
||||
/// <param name="m_localID"></param>
|
||||
/// <param name="m_itemID"></param>
|
||||
public void RemoveScript(uint m_localID, LLUUID m_itemID)
|
||||
{
|
||||
// Remove a specific script
|
||||
|
||||
// Remove from: Timers
|
||||
UnSetTimerEvents(m_localID, m_itemID);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// TIMER
|
||||
//
|
||||
private class TimerClass
|
||||
{
|
||||
public uint localID;
|
||||
public LLUUID itemID;
|
||||
public double interval;
|
||||
public DateTime next;
|
||||
}
|
||||
private List<TimerClass> Timers = new List<TimerClass>();
|
||||
private object ListLock = new object();
|
||||
public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
|
||||
{
|
||||
Console.WriteLine("SetTimerEvent");
|
||||
|
||||
// Always remove first, in case this is a re-set
|
||||
UnSetTimerEvents(m_localID, m_itemID);
|
||||
if (sec == 0) // Disabling timer
|
||||
return;
|
||||
|
||||
// Add to timer
|
||||
TimerClass ts = new TimerClass();
|
||||
ts.localID = m_localID;
|
||||
ts.itemID = m_itemID;
|
||||
ts.interval = sec;
|
||||
ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
|
||||
lock (ListLock)
|
||||
{
|
||||
Timers.Add(ts);
|
||||
}
|
||||
}
|
||||
public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID)
|
||||
{
|
||||
// Remove from timer
|
||||
lock (ListLock)
|
||||
{
|
||||
List<TimerClass> NewTimers = new List<TimerClass>();
|
||||
foreach (TimerClass ts in Timers)
|
||||
{
|
||||
if (ts.localID != m_localID && ts.itemID != m_itemID)
|
||||
{
|
||||
NewTimers.Add(ts);
|
||||
}
|
||||
}
|
||||
Timers.Clear();
|
||||
Timers = NewTimers;
|
||||
}
|
||||
}
|
||||
public void CheckTimerEvents()
|
||||
{
|
||||
// Nothing to do here?
|
||||
if (Timers.Count == 0)
|
||||
return;
|
||||
|
||||
lock (ListLock)
|
||||
{
|
||||
|
||||
// Go through all timers
|
||||
foreach (TimerClass ts in Timers)
|
||||
{
|
||||
// Time has passed?
|
||||
if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
|
||||
{
|
||||
// Add it to queue
|
||||
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { });
|
||||
// set next interval
|
||||
|
||||
|
||||
ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
|
||||
}
|
||||
}
|
||||
} // lock
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using libsecondlife;
|
||||
using OpenSim.Region.ScriptEngine.Common;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles LSL commands that takes long time and returns an event, for example timers, HTTP requests, etc.
|
||||
/// </summary>
|
||||
class LSLLongCmdHandler
|
||||
{
|
||||
private Thread cmdHandlerThread;
|
||||
private int cmdHandlerThreadCycleSleepms = 100;
|
||||
|
||||
private ScriptEngine m_ScriptEngine;
|
||||
public LSLLongCmdHandler(ScriptEngine _ScriptEngine)
|
||||
{
|
||||
m_ScriptEngine = _ScriptEngine;
|
||||
|
||||
// Start the thread that will be doing the work
|
||||
cmdHandlerThread = new Thread(CmdHandlerThreadLoop);
|
||||
cmdHandlerThread.Name = "CmdHandlerThread";
|
||||
cmdHandlerThread.Priority = ThreadPriority.BelowNormal;
|
||||
cmdHandlerThread.IsBackground = true;
|
||||
cmdHandlerThread.Start();
|
||||
}
|
||||
~LSLLongCmdHandler()
|
||||
{
|
||||
// Shut down thread
|
||||
try
|
||||
{
|
||||
if (cmdHandlerThread != null)
|
||||
{
|
||||
if (cmdHandlerThread.IsAlive == true)
|
||||
{
|
||||
cmdHandlerThread.Abort();
|
||||
cmdHandlerThread.Join();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void CmdHandlerThreadLoop()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
// Check timers
|
||||
CheckTimerEvents();
|
||||
// Check HttpRequests
|
||||
CheckHttpRequests();
|
||||
|
||||
// Sleep before next cycle
|
||||
Thread.Sleep(cmdHandlerThreadCycleSleepms);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove a specific script (and all its pending commands)
|
||||
/// </summary>
|
||||
/// <param name="m_localID"></param>
|
||||
/// <param name="m_itemID"></param>
|
||||
public void RemoveScript(uint localID, LLUUID itemID)
|
||||
{
|
||||
// Remove a specific script
|
||||
|
||||
// Remove from: Timers
|
||||
UnSetTimerEvents(localID, itemID);
|
||||
// Remove from: HttpRequest
|
||||
StopHttpRequest(localID, itemID);
|
||||
}
|
||||
|
||||
#region TIMER
|
||||
|
||||
//
|
||||
// TIMER
|
||||
//
|
||||
private class TimerClass
|
||||
{
|
||||
public uint localID;
|
||||
public LLUUID itemID;
|
||||
public double interval;
|
||||
public DateTime next;
|
||||
}
|
||||
private List<TimerClass> Timers = new List<TimerClass>();
|
||||
private object TimerListLock = new object();
|
||||
public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
|
||||
{
|
||||
Console.WriteLine("SetTimerEvent");
|
||||
|
||||
// Always remove first, in case this is a re-set
|
||||
UnSetTimerEvents(m_localID, m_itemID);
|
||||
if (sec == 0) // Disabling timer
|
||||
return;
|
||||
|
||||
// Add to timer
|
||||
TimerClass ts = new TimerClass();
|
||||
ts.localID = m_localID;
|
||||
ts.itemID = m_itemID;
|
||||
ts.interval = sec;
|
||||
ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
|
||||
lock (TimerListLock)
|
||||
{
|
||||
Timers.Add(ts);
|
||||
}
|
||||
}
|
||||
public void UnSetTimerEvents(uint m_localID, LLUUID m_itemID)
|
||||
{
|
||||
// Remove from timer
|
||||
lock (TimerListLock)
|
||||
{
|
||||
List<TimerClass> NewTimers = new List<TimerClass>();
|
||||
foreach (TimerClass ts in Timers)
|
||||
{
|
||||
if (ts.localID != m_localID && ts.itemID != m_itemID)
|
||||
{
|
||||
NewTimers.Add(ts);
|
||||
}
|
||||
}
|
||||
Timers.Clear();
|
||||
Timers = NewTimers;
|
||||
}
|
||||
}
|
||||
public void CheckTimerEvents()
|
||||
{
|
||||
// Nothing to do here?
|
||||
if (Timers.Count == 0)
|
||||
return;
|
||||
|
||||
lock (TimerListLock)
|
||||
{
|
||||
|
||||
// Go through all timers
|
||||
foreach (TimerClass ts in Timers)
|
||||
{
|
||||
// Time has passed?
|
||||
if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
|
||||
{
|
||||
// Add it to queue
|
||||
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "timer", new object[] { });
|
||||
// set next interval
|
||||
|
||||
|
||||
ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
|
||||
}
|
||||
}
|
||||
} // lock
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region HTTP REQUEST
|
||||
|
||||
//
|
||||
// HTTP REAQUEST
|
||||
//
|
||||
private class HttpClass
|
||||
{
|
||||
public uint localID;
|
||||
public LLUUID itemID;
|
||||
public string url;
|
||||
public List<string> parameters;
|
||||
public string body;
|
||||
public DateTime next;
|
||||
|
||||
public string response_request_id;
|
||||
public int response_status;
|
||||
public List<string> response_metadata;
|
||||
public string response_body;
|
||||
|
||||
public void SendRequest()
|
||||
{
|
||||
// TODO: SEND REQUEST!!!
|
||||
}
|
||||
public void Stop()
|
||||
{
|
||||
// TODO: Cancel any ongoing request
|
||||
}
|
||||
public bool CheckResponse()
|
||||
{
|
||||
// TODO: Check if we got a response yet, return true if so -- false if not
|
||||
return true;
|
||||
|
||||
// TODO: If we got a response, set the following then return true
|
||||
//response_request_id
|
||||
//response_status
|
||||
//response_metadata
|
||||
//response_body
|
||||
|
||||
}
|
||||
}
|
||||
private List<HttpClass> HttpRequests = new List<HttpClass>();
|
||||
private object HttpListLock = new object();
|
||||
public void StartHttpRequest(uint localID, LLUUID itemID, string url, List<string> parameters, string body)
|
||||
{
|
||||
Console.WriteLine("StartHttpRequest");
|
||||
|
||||
HttpClass htc = new HttpClass();
|
||||
htc.localID = localID;
|
||||
htc.itemID = itemID;
|
||||
htc.url = url;
|
||||
htc.parameters = parameters;
|
||||
htc.body = body;
|
||||
lock (HttpListLock)
|
||||
{
|
||||
|
||||
//ADD REQUEST
|
||||
HttpRequests.Add(htc);
|
||||
}
|
||||
}
|
||||
public void StopHttpRequest(uint m_localID, LLUUID m_itemID)
|
||||
{
|
||||
// Remove from list
|
||||
lock (HttpListLock)
|
||||
{
|
||||
List<HttpClass> NewHttpList = new List<HttpClass>();
|
||||
foreach (HttpClass ts in HttpRequests)
|
||||
{
|
||||
if (ts.localID != m_localID && ts.itemID != m_itemID)
|
||||
{
|
||||
// Keeping this one
|
||||
NewHttpList.Add(ts);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Shutting this one down
|
||||
ts.Stop();
|
||||
}
|
||||
}
|
||||
HttpRequests.Clear();
|
||||
HttpRequests = NewHttpList;
|
||||
}
|
||||
}
|
||||
public void CheckHttpRequests()
|
||||
{
|
||||
// Nothing to do here?
|
||||
if (HttpRequests.Count == 0)
|
||||
return;
|
||||
|
||||
lock (HttpListLock)
|
||||
{
|
||||
foreach (HttpClass ts in HttpRequests)
|
||||
{
|
||||
|
||||
if (ts.CheckResponse() == true)
|
||||
{
|
||||
// Add it to event queue
|
||||
//key request_id, integer status, list metadata, string body
|
||||
object[] resobj = new object[] { ts.response_request_id, ts.response_status, ts.response_metadata, ts.response_body };
|
||||
m_ScriptEngine.m_EventQueueManager.AddToScriptQueue(ts.localID, ts.itemID, "http_response", resobj);
|
||||
// Now stop it
|
||||
StopHttpRequest(ts.localID, ts.itemID);
|
||||
}
|
||||
}
|
||||
} // lock
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -221,7 +221,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
|
||||
}
|
||||
#endregion
|
||||
#region Start/Stop script
|
||||
#region Start/Stop/Reset script
|
||||
/// <summary>
|
||||
/// Fetches, loads and hooks up a script to an objects events
|
||||
/// </summary>
|
||||
|
@ -246,6 +246,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
ls.localID = localID;
|
||||
ls.itemID = itemID;
|
||||
unloadQueue.Enqueue(ls);
|
||||
}
|
||||
public void ResetScript(uint localID, LLUUID itemID)
|
||||
{
|
||||
string script = GetScript(localID, itemID).SourceCode;
|
||||
StopScript(localID, itemID);
|
||||
StartScript(localID, itemID, script);
|
||||
}
|
||||
|
||||
private void _StartScript(uint localID, LLUUID itemID, string Script)
|
||||
|
@ -255,7 +261,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
|
||||
// We will initialize and start the script.
|
||||
// It will be up to the script itself to hook up the correct events.
|
||||
string FileName = "";
|
||||
string ScriptSource = "";
|
||||
|
||||
SceneObjectPart m_host = World.GetSceneObjectPart(localID);
|
||||
|
||||
|
@ -268,10 +274,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
// Create a new instance of the compiler (currently we don't want reuse)
|
||||
OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler LSLCompiler = new OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL.Compiler();
|
||||
// Compile (We assume LSL)
|
||||
FileName = LSLCompiler.CompileFromLSLText(Script);
|
||||
ScriptSource = LSLCompiler.CompileFromLSLText(Script);
|
||||
//Console.WriteLine("Compilation of " + FileName + " done");
|
||||
// * Insert yield into code
|
||||
FileName = ProcessYield(FileName);
|
||||
ScriptSource = ProcessYield(ScriptSource);
|
||||
|
||||
|
||||
#if DEBUG
|
||||
|
@ -279,11 +285,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
before = GC.GetTotalMemory(true);
|
||||
#endif
|
||||
LSL_BaseClass CompiledScript;
|
||||
CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(FileName);
|
||||
CompiledScript = m_scriptEngine.m_AppDomainManager.LoadScript(ScriptSource);
|
||||
#if DEBUG
|
||||
Console.WriteLine("Script " + itemID + " occupies {0} bytes", GC.GetTotalMemory(true) - before);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
CompiledScript.SourceCode = ScriptSource;
|
||||
// Add it to our script memstruct
|
||||
SetScript(localID, itemID, CompiledScript);
|
||||
|
||||
|
|
Loading…
Reference in New Issue