mirror of
https://github.com/opensim/opensim.git
synced 2026-07-31 05:45:37 +08:00
modify Dataserver request functions
This commit is contained in:
@@ -82,6 +82,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
public Action<string> action;
|
||||
}
|
||||
|
||||
public string RequestWithImediatePost(uint localID, UUID itemID, string reply)
|
||||
{
|
||||
string ID = UUID.Random().ToString();
|
||||
m_CmdManager.m_ScriptEngine.PostObjectEvent(localID,
|
||||
new EventParams("dataserver", new Object[]
|
||||
{ new LSL_Types.LSLString(ID),
|
||||
new LSL_Types.LSLString(reply)},
|
||||
new DetectParams[0]));
|
||||
return ID;
|
||||
}
|
||||
|
||||
public UUID RegisterRequest(uint localID, UUID itemID, string identifier)
|
||||
{
|
||||
lock (DataserverRequests)
|
||||
{
|
||||
if (DataserverRequests.ContainsKey(identifier))
|
||||
return UUID.Zero;
|
||||
|
||||
DataserverRequest ds = new DataserverRequest()
|
||||
{
|
||||
localID = localID,
|
||||
itemID = itemID,
|
||||
|
||||
ID = UUID.Random(),
|
||||
handle = identifier,
|
||||
|
||||
startTime = DateTime.UtcNow,
|
||||
action = null
|
||||
};
|
||||
|
||||
DataserverRequests[identifier] = ds;
|
||||
return ds.ID;
|
||||
}
|
||||
}
|
||||
|
||||
// action, if provided, is executed async
|
||||
// its code pattern should be:
|
||||
//Action<string> act = eventID =>
|
||||
@@ -92,33 +127,61 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
// eventID is the event id, provided by this on Invoque
|
||||
// see ProcessActions below
|
||||
|
||||
public UUID RegisterRequest(uint localID, UUID itemID,
|
||||
string identifier, Action<string> action = null)
|
||||
// temporary don't use
|
||||
public UUID RegisterRequest(uint localID, UUID itemID, string identifier, Action<string> action)
|
||||
{
|
||||
lock (DataserverRequests)
|
||||
{
|
||||
if (DataserverRequests.ContainsKey(identifier))
|
||||
return UUID.Zero;
|
||||
|
||||
DataserverRequest ds = new DataserverRequest();
|
||||
DataserverRequest ds = new DataserverRequest()
|
||||
{
|
||||
localID = localID,
|
||||
itemID = itemID,
|
||||
|
||||
ds.localID = localID;
|
||||
ds.itemID = itemID;
|
||||
ID = UUID.Random(),
|
||||
handle = identifier,
|
||||
|
||||
ds.ID = UUID.Random();
|
||||
ds.handle = identifier;
|
||||
|
||||
ds.startTime = DateTime.Now;
|
||||
ds.action = action;
|
||||
startTime = DateTime.UtcNow,
|
||||
action = action
|
||||
};
|
||||
|
||||
DataserverRequests[identifier] = ds;
|
||||
if(action != null)
|
||||
m_ThreadPool.QueueWorkItem((WorkItemCallback)ProcessActions, (object)identifier);
|
||||
if (action != null)
|
||||
m_ThreadPool.QueueWorkItem((WorkItemCallback)ProcessActions, identifier);
|
||||
|
||||
return ds.ID;
|
||||
}
|
||||
}
|
||||
|
||||
public UUID RegisterRequest(uint localID, UUID itemID, Action<string> action)
|
||||
{
|
||||
lock (DataserverRequests)
|
||||
{
|
||||
string identifier = UUID.Random().ToString();
|
||||
|
||||
DataserverRequest ds = new DataserverRequest()
|
||||
{
|
||||
localID = localID,
|
||||
itemID = itemID,
|
||||
|
||||
ID = UUID.Random(),
|
||||
handle = identifier,
|
||||
|
||||
startTime = DateTime.MaxValue,
|
||||
action = action
|
||||
};
|
||||
|
||||
DataserverRequests[identifier] = ds;
|
||||
if (action != null)
|
||||
m_ThreadPool.QueueWorkItem((WorkItemCallback)ProcessActions, identifier);
|
||||
|
||||
return ds.ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public object ProcessActions(object st)
|
||||
{
|
||||
string id = st as string;
|
||||
@@ -192,9 +255,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
|
||||
lock (DataserverRequests)
|
||||
{
|
||||
List<string> toremove = new List<string>(DataserverRequests.Count);
|
||||
DateTime expirebase = DateTime.UtcNow.AddSeconds(-30);
|
||||
foreach (DataserverRequest ds in DataserverRequests.Values)
|
||||
{
|
||||
if (ds.startTime > DateTime.Now.AddSeconds(30) && ds.action == null)
|
||||
if (ds.action == null && ds.startTime < expirebase)
|
||||
toremove.Add(ds.handle);
|
||||
}
|
||||
foreach (string s in toremove)
|
||||
|
||||
Reference in New Issue
Block a user