* Cruft removal step #1. Cleaning Modules directory.

This commit is contained in:
Adam Frisby
2008-04-30 21:43:47 +00:00
parent 3da6a05eaa
commit be20f41637
35 changed files with 2216 additions and 2127 deletions

View File

@@ -47,32 +47,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>();
public void Initialise(Scene scene, IConfigSource config)
{
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
scene.RegisterModuleInterface<IDynamicTextureManager>(this);
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "DynamicTextureModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
#region IDynamicTextureManager Members
public void RegisterRender(string handleType, IDynamicTextureRender render)
{
@@ -164,20 +139,55 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
return LLUUID.Zero;
}
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
scene.RegisterModuleInterface<IDynamicTextureManager>(this);
}
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "DynamicTextureModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
#region Nested type: DynamicTextureUpdater
public class DynamicTextureUpdater
{
public LLUUID SimUUID;
public LLUUID UpdaterID;
public string ContentType;
public string Url;
public bool BlendWithOldTexture = false;
public string BodyData;
public LLUUID PrimID;
public int UpdateTimer;
public string ContentType;
public byte FrontAlpha = 255;
public LLUUID LastAssetID;
public string Params;
public bool BlendWithOldTexture = false;
public LLUUID PrimID;
public bool SetNewFrontAlpha = false;
public byte FrontAlpha = 255;
public LLUUID SimUUID;
public LLUUID UpdaterID;
public int UpdateTimer;
public string Url;
public DynamicTextureUpdater()
{
@@ -224,7 +234,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
LastAssetID = asset.FullID;
part.Shape.Textures = new LLObject.TextureEntry(asset.FullID);
part.ScheduleFullUpdate();
}
@@ -273,5 +283,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
}
}
}
#endregion
}
}

View File

@@ -84,45 +84,20 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
{
public class HttpRequestModule : IRegionModule, IHttpRequests
{
private Scene m_scene;
private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
private object HttpListLock = new object();
private string m_name = "HttpScriptRequests";
private int httpTimeout = 30000;
private string m_name = "HttpScriptRequests";
// <request id, HttpRequestClass>
private Dictionary<LLUUID, HttpRequestClass> m_pendingRequests;
private Scene m_scene;
private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
public HttpRequestModule()
{
}
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_scene.RegisterModuleInterface<IHttpRequests>(this);
m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>();
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
#region IHttpRequests Members
public LLUUID MakeHttpRequest(string url, string parameters, string body)
{
@@ -141,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
if (parameters != null)
{
string[] parms = parameters.ToArray();
for (int i = 0; i < parms.Length/2; i += 2)
for (int i = 0; i < parms.Length / 2; i += 2)
{
switch (Int32.Parse(parms[i]))
{
@@ -187,7 +162,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
public void StopHttpRequest(uint m_localID, LLUUID m_itemID)
{
if(m_pendingRequests != null) {
if (m_pendingRequests != null)
{
lock (HttpListLock)
{
HttpRequestClass tmpReq;
@@ -243,36 +219,68 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
}
}
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
m_scene.RegisterModuleInterface<IHttpRequests>(this);
m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>();
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
}
public class HttpRequestClass
{
// Constants for parameters
public const int HTTP_BODY_MAXLENGTH = 2;
public const int HTTP_METHOD = 0;
public const int HTTP_MIMETYPE = 1;
public const int HTTP_BODY_MAXLENGTH = 2;
public const int HTTP_VERIFY_CERT = 3;
public bool finished;
public int httpBodyMaxLen = 2048; // not implemented
// Parameter members and default values
public string httpMethod = "GET";
public string httpMIMEType = "text/plain;charset=utf-8";
public int httpBodyMaxLen = 2048; // not implemented
private Thread httpThread;
public int httpTimeout;
public bool httpVerifyCert = true; // not implemented
// Request info
public uint localID;
public LLUUID itemID;
public LLUUID reqID;
public int httpTimeout;
public string url;
public string outbound_body;
public uint localID;
public DateTime next;
public int status;
public bool finished;
public List<string> response_metadata;
public string response_body;
public string outbound_body;
public LLUUID reqID;
public HttpWebRequest request;
private Thread httpThread;
public string response_body;
public List<string> response_metadata;
public int status;
public string url;
public void process()
{

View File

@@ -40,39 +40,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
public class LoadImageURLModule : IRegionModule, IDynamicTextureRender
{
private string m_name = "LoadImageURL";
private IDynamicTextureManager m_textureManager;
private Scene m_scene;
private IDynamicTextureManager m_textureManager;
public void Initialise(Scene scene, IConfigSource config)
{
if (m_scene == null)
{
m_scene = scene;
}
}
public void PostInitialise()
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
if (m_textureManager != null)
{
m_textureManager.RegisterRender(GetContentType(), this);
}
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
#region IDynamicTextureRender Members
public string GetName()
{
@@ -110,6 +81,43 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
return false;
}
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
if (m_scene == null)
{
m_scene = scene;
}
}
public void PostInitialise()
{
m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
if (m_textureManager != null)
{
m_textureManager.RegisterRender(GetContentType(), this);
}
}
public void Close()
{
}
public string Name
{
get { return m_name; }
}
public bool IsSharedModule
{
get { return true; }
}
#endregion
private void MakeHttpRequest(string url, LLUUID requestID)
{
WebRequest request = HttpWebRequest.Create(url);
@@ -138,8 +146,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
else if ((image.Height < 128) && (image.Width < 128))
{
newsize = new Size(64, 64);
}
else if ((image.Height <256) && (image.Width < 256))
}
else if ((image.Height < 256) && (image.Width < 256))
{
newsize = new Size(128, 128);
}
@@ -153,8 +161,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
}
else
{
newsize = new Size(1024,1024);
}
newsize = new Size(1024, 1024);
}
Bitmap resize = new Bitmap(image, newsize);
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
@@ -163,6 +171,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
}
}
#region Nested type: RequestState
public class RequestState
{
public HttpWebRequest Request = null;
@@ -175,5 +185,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
RequestID = requestID;
}
}
#endregion
}
}

View File

@@ -44,14 +44,56 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
{
public class VectorRenderModule : IRegionModule, IDynamicTextureRender
{
private Scene m_scene;
private string m_name = "VectorRenderModule";
private Scene m_scene;
private IDynamicTextureManager m_textureManager;
public VectorRenderModule()
{
}
#region IDynamicTextureRender Members
public string GetContentType()
{
return ("vector");
}
public string GetName()
{
return m_name;
}
public bool SupportsAsynchronous()
{
return true;
}
public byte[] ConvertUrl(string url, string extraParams)
{
return null;
}
public byte[] ConvertStream(Stream data, string extraParams)
{
return null;
}
public bool AsyncConvertUrl(LLUUID id, string url, string extraParams)
{
return false;
}
public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams)
{
Draw(bodyData, id, extraParams);
return true;
}
#endregion
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
if (m_scene == null)
@@ -83,21 +125,25 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
get { return true; }
}
#endregion
private void Draw(string data, LLUUID id, string extraParams)
{
// TODO: this is a brutal hack. extraParams should actually be parsed reasonably.
int size = 256;
try {
try
{
size = Convert.ToInt32(extraParams);
} catch (Exception e) {
}
catch (Exception e)
{
//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used
Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString());
}
if ((size < 128) || (size > 1024))
size = 256;
Bitmap bitmap = new Bitmap(size, size, PixelFormat.Format32bppArgb);
Graphics graph = Graphics.FromImage(bitmap);
@@ -121,13 +167,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
}
}
GDIDraw(data, graph);
byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true);
m_textureManager.ReturnData(id, imageJ2000);
}
/*
@@ -175,10 +219,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
Pen drawPen = new Pen(Color.Black, 7);
Font myFont = new Font("Times New Roman", 14);
SolidBrush myBrush = new SolidBrush(Color.Black);
char[] lineDelimiter = { ';' };
char[] partsDelimiter = { ',' };
char[] lineDelimiter = {';'};
char[] partsDelimiter = {','};
string[] lines = data.Split(lineDelimiter);
foreach (string line in lines)
{
string nextLine = line.Trim();
@@ -188,16 +232,16 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0;
float y = 0;
GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
startPoint.X = (int)x;
startPoint.Y = (int)y;
startPoint.X = (int) x;
startPoint.Y = (int) y;
}
else if (nextLine.StartsWith("LineTo"))
{
float x = 0;
float y = 0;
GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
endPoint.X = (int)x;
endPoint.Y = (int)y;
endPoint.X = (int) x;
endPoint.Y = (int) y;
graph.DrawLine(drawPen, startPoint, endPoint);
startPoint.X = endPoint.X;
startPoint.Y = endPoint.Y;
@@ -213,10 +257,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0;
float y = 0;
GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y);
endPoint.X = (int)x;
endPoint.Y = (int)y;
endPoint.X = (int) x;
endPoint.Y = (int) y;
Image image = ImageHttpRequest(nextLine);
graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y);
graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y);
startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y;
}
@@ -225,8 +269,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0;
float y = 0;
GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y);
endPoint.X = (int)x;
endPoint.Y = (int)y;
endPoint.X = (int) x;
endPoint.Y = (int) y;
graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y;
@@ -236,8 +280,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0;
float y = 0;
GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y);
endPoint.X = (int)x;
endPoint.Y = (int)y;
endPoint.X = (int) x;
endPoint.Y = (int) y;
graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y;
@@ -247,8 +291,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
float x = 0;
float y = 0;
GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y);
endPoint.X = (int)x;
endPoint.Y = (int)y;
endPoint.X = (int) x;
endPoint.Y = (int) y;
graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y;
@@ -271,7 +315,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
{
nextLine = nextLine.Remove(0, 9);
nextLine = nextLine.Trim();
Color newColour = Color.FromName(nextLine);
myBrush.Color = newColour;
@@ -312,7 +356,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
WebRequest request = HttpWebRequest.Create(url);
//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
//Ckrinke Stream str = null;
HttpWebResponse response = (HttpWebResponse)(request).GetResponse();
HttpWebResponse response = (HttpWebResponse) (request).GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Bitmap image = new Bitmap(response.GetResponseStream());
@@ -321,41 +365,5 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
return null;
}
public string GetContentType()
{
return ("vector");
}
public string GetName()
{
return m_name;
}
public bool SupportsAsynchronous()
{
return true;
}
public byte[] ConvertUrl(string url, string extraParams)
{
return null;
}
public byte[] ConvertStream(Stream data, string extraParams)
{
return null;
}
public bool AsyncConvertUrl(LLUUID id, string url, string extraParams)
{
return false;
}
public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams)
{
Draw(bodyData, id, extraParams);
return true;
}
}
}

View File

@@ -67,18 +67,20 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
{
public class WorldCommModule : IRegionModule, IWorldComm
{
private Scene m_scene;
private object CommListLock = new object();
private object ListLock = new object();
private string m_name = "WorldCommModule";
private ListenerManager m_listenerManager;
private Queue m_pendingQ;
private string m_name = "WorldCommModule";
private Queue m_pending;
private Queue m_pendingQ;
private Scene m_scene;
public WorldCommModule()
{
}
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
m_scene = scene;
@@ -107,23 +109,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
get { return false; }
}
public void NewClient(IClientAPI client)
{
client.OnChatFromViewer += DeliverClientMessage;
}
#endregion
/********************************************************************
*
* Listener Stuff
*
* *****************************************************************/
private void DeliverClientMessage(Object sender, ChatFromViewerArgs e)
{
DeliverMessage(e.Sender.AgentId.ToString(),
e.Type, e.Channel,
e.Sender.FirstName + " " + e.Sender.LastName,
e.Message);
}
#region IWorldComm Members
public int Listen(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
{
@@ -295,7 +283,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
lock (m_pending.SyncRoot)
{
li = (ListenerInfo)m_pending.Dequeue();
li = (ListenerInfo) m_pending.Dequeue();
}
return li;
@@ -303,20 +291,41 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
public uint PeekNextMessageLocalID()
{
return ((ListenerInfo)m_pending.Peek()).GetLocalID();
return ((ListenerInfo) m_pending.Peek()).GetLocalID();
}
public LLUUID PeekNextMessageItemID()
{
return ((ListenerInfo)m_pending.Peek()).GetItemID();
return ((ListenerInfo) m_pending.Peek()).GetItemID();
}
#endregion
public void NewClient(IClientAPI client)
{
client.OnChatFromViewer += DeliverClientMessage;
}
/********************************************************************
*
* Listener Stuff
*
* *****************************************************************/
private void DeliverClientMessage(Object sender, ChatFromViewerArgs e)
{
DeliverMessage(e.Sender.AgentId.ToString(),
e.Type, e.Channel,
e.Sender.FirstName + " " + e.Sender.LastName,
e.Message);
}
}
public class ListenerManager
{
//private Dictionary<int, ListenerInfo> m_listeners;
private Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
private object ListenersLock = new object();
private Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
private int m_MaxListeners = 100;
public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
@@ -363,7 +372,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
IDictionaryEnumerator en = m_listeners.GetEnumerator();
while (en.MoveNext())
{
ListenerInfo li = (ListenerInfo)en.Value;
ListenerInfo li = (ListenerInfo) en.Value;
if (li.GetItemID().Equals(itemID))
{
removedListeners.Add(li.GetHandle());
@@ -400,12 +409,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
public void Activate(int handle)
{
if (m_listeners.ContainsKey(handle))
{
lock (m_listeners.SyncRoot)
{
ListenerInfo li = (ListenerInfo)m_listeners[handle];
ListenerInfo li = (ListenerInfo) m_listeners[handle];
li.Activate();
}
}
@@ -413,10 +421,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
public void Dectivate(int handle)
{
if (m_listeners.ContainsKey(handle))
{
ListenerInfo li = (ListenerInfo)m_listeners[handle];
ListenerInfo li = (ListenerInfo) m_listeners[handle];
li.Deactivate();
}
}
@@ -432,9 +439,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
IDictionaryEnumerator en = m_listeners.GetEnumerator();
while (en.MoveNext())
{
ListenerInfo li = (ListenerInfo)en.Value;
ListenerInfo li = (ListenerInfo) en.Value;
if (li.IsActive())
if (li.IsActive())
{
if (li.GetHostID().Equals(listenerKey))
{
@@ -478,16 +485,16 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
public class ListenerInfo
{
private LLUUID m_itemID; // ID of the host script engine
private LLUUID m_hostID; // ID of the host/scene part
private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
private bool m_active; // Listener is active or not
private int m_channel; // Channel
private int m_handle; // Assigned handle of this listener
private uint m_localID; // Local ID from script engine
private string m_name; // Object name to filter messages from
private LLUUID m_hostID; // ID of the host/scene part
private LLUUID m_id; // ID to filter messages from
private LLUUID m_itemID; // ID of the host script engine
private uint m_localID; // Local ID from script engine
private string m_message; // The message
private bool m_active; // Listener is active or not
private string m_name; // Object name to filter messages from
private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message)
{

View File

@@ -79,20 +79,21 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private object XMLRPCListLock = new object();
private string m_name = "XMLRPCModule";
private int RemoteReplyScriptWait = 300;
private int RemoteReplyScriptTimeout = 9000;
private int m_remoteDataPort = 0;
private List<Scene> m_scenes = new List<Scene>();
// <channel id, RPCChannelInfo>
private Dictionary<LLUUID, RPCChannelInfo> m_openChannels;
private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses;
private int m_remoteDataPort = 0;
private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending;
private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses;
private List<Scene> m_scenes = new List<Scene>();
private int RemoteReplyScriptTimeout = 9000;
private int RemoteReplyScriptWait = 300;
private object XMLRPCListLock = new object();
private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses;
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
{
@@ -125,7 +126,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
// Attach xmlrpc handlers
m_log.Info("[REMOTE_DATA]: " +
"Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort);
BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort);
httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
httpServer.Start();
}
@@ -145,6 +146,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
get { return true; }
}
#endregion
#region IXMLRPC Members
public bool IsEnabled()
{
return (m_remoteDataPort > 0);
@@ -196,7 +201,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
// for when a script is deleted
public void DeleteChannels(LLUUID itemID)
{
if (m_openChannels != null)
{
ArrayList tmp = new ArrayList();
@@ -212,12 +216,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
}
IEnumerator tmpEnumerator = tmp.GetEnumerator();
while ( tmpEnumerator.MoveNext() )
m_openChannels.Remove((LLUUID)tmpEnumerator.Current);
while (tmpEnumerator.MoveNext())
m_openChannels.Remove((LLUUID) tmpEnumerator.Current);
}
}
}
/**********************************************
@@ -255,67 +257,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
}
public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable)request.Params[0];
bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
requestData.Contains("StringValue"));
if (GoodXML)
{
LLUUID channel = new LLUUID((string)requestData["Channel"]);
RPCChannelInfo rpcChanInfo;
if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
{
string intVal = (string)requestData["IntValue"];
string strVal = (string)requestData["StringValue"];
RPCRequestInfo rpcInfo;
lock (XMLRPCListLock)
{
rpcInfo =
new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
intVal);
m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
}
int timeoutCtr = 0;
while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
{
Thread.Sleep(RemoteReplyScriptWait);
timeoutCtr += RemoteReplyScriptWait;
}
if (rpcInfo.IsProcessed())
{
Hashtable param = new Hashtable();
param["StringValue"] = rpcInfo.GetStrRetval();
param["IntValue"] = Convert.ToString(rpcInfo.GetIntRetval());
ArrayList parameters = new ArrayList();
parameters.Add(param);
response.Value = parameters;
rpcInfo = null;
}
else
{
response.SetFault(-1, "Script timeout");
rpcInfo = null;
}
}
else
{
response.SetFault(-1, "Invalid channel");
}
}
return response;
}
public bool hasRequests()
{
lock (XMLRPCListLock)
@@ -339,7 +280,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
if (m_rpcPending.TryGetValue(luid, out tmpReq))
{
if (!tmpReq.IsProcessed()) return tmpReq;
}
}
@@ -367,13 +307,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
public LLUUID SendRemoteData(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata)
{
SendRemoteDataRequest req = new SendRemoteDataRequest(
localID, itemID, channel, dest, idata, sdata
);
m_pendingSRDResponses.Add(req.GetReqID(), req);
return req.process();
}
public SendRemoteDataRequest GetNextCompletedSRDRequest()
@@ -423,19 +361,82 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
}
}
}
#endregion
public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
{
XmlRpcResponse response = new XmlRpcResponse();
Hashtable requestData = (Hashtable) request.Params[0];
bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
requestData.Contains("StringValue"));
if (GoodXML)
{
LLUUID channel = new LLUUID((string) requestData["Channel"]);
RPCChannelInfo rpcChanInfo;
if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
{
string intVal = (string) requestData["IntValue"];
string strVal = (string) requestData["StringValue"];
RPCRequestInfo rpcInfo;
lock (XMLRPCListLock)
{
rpcInfo =
new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
intVal);
m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
}
int timeoutCtr = 0;
while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
{
Thread.Sleep(RemoteReplyScriptWait);
timeoutCtr += RemoteReplyScriptWait;
}
if (rpcInfo.IsProcessed())
{
Hashtable param = new Hashtable();
param["StringValue"] = rpcInfo.GetStrRetval();
param["IntValue"] = Convert.ToString(rpcInfo.GetIntRetval());
ArrayList parameters = new ArrayList();
parameters.Add(param);
response.Value = parameters;
rpcInfo = null;
}
else
{
response.SetFault(-1, "Script timeout");
rpcInfo = null;
}
}
else
{
response.SetFault(-1, "Invalid channel");
}
}
return response;
}
}
public class RPCRequestInfo
{
private string m_StrVal;
private string m_IntVal;
private bool m_processed;
private string m_respStr;
private int m_respInt;
private uint m_localID;
private LLUUID m_ItemID;
private LLUUID m_MessageID;
private LLUUID m_ChannelKey;
private string m_IntVal;
private LLUUID m_ItemID;
private uint m_localID;
private LLUUID m_MessageID;
private bool m_processed;
private int m_respInt;
private string m_respStr;
private string m_StrVal;
public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal)
{
@@ -474,6 +475,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{
return m_respStr;
}
public void SetIntRetval(int resp)
{
m_respInt = resp;
@@ -483,6 +485,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{
return m_respInt;
}
public uint GetLocalID()
{
return m_localID;
@@ -511,9 +514,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
public class RPCChannelInfo
{
private LLUUID m_ChannelKey;
private LLUUID m_itemID;
private uint m_localID;
private LLUUID m_ChannelKey;
public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID)
{
@@ -536,38 +539,34 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
{
return m_localID;
}
}
public class SendRemoteDataRequest
{
public LLUUID reqID;
public string destURL;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public string channel;
public string sdata;
public int idata;
public string destURL;
public bool finished;
public string response_sdata;
public int response_idata;
public XmlRpcRequest request;
private Thread httpThread;
public int idata;
public LLUUID m_itemID;
public uint m_localID;
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public LLUUID reqID;
public XmlRpcRequest request;
public int response_idata;
public string response_sdata;
public string sdata;
public SendRemoteDataRequest(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata)
{
this.channel = channel;
this.destURL = dest;
destURL = dest;
this.idata = idata;
this.sdata = sdata;
m_itemID = itemID;
m_localID = localID;
reqID = LLUUID.Random();
}
public LLUUID process()
@@ -581,7 +580,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
ThreadTracker.Add(httpThread);
return reqID;
}
/*
@@ -597,8 +595,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
// if not, use as method name
LLUUID parseUID;
string mName = "llRemoteData";
if( (channel != null) && (channel != "") )
if( !LLUUID.TryParse(channel, out parseUID) )
if ((channel != null) && (channel != ""))
if (!LLUUID.TryParse(channel, out parseUID))
mName = channel;
else
param["Channel"] = channel;
@@ -615,26 +613,28 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
if (resp != null)
{
Hashtable respParms;
if(resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable"))) {
respParms = (Hashtable)resp.Value;
if (resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable")))
{
respParms = (Hashtable) resp.Value;
}
else {
ArrayList respData = (ArrayList)resp.Value;
respParms = (Hashtable)respData[0];
else
{
ArrayList respData = (ArrayList) resp.Value;
respParms = (Hashtable) respData[0];
}
if (respParms != null)
{
if (respParms.Contains("StringValue"))
{
sdata = (string)respParms["StringValue"];
sdata = (string) respParms["StringValue"];
}
if (respParms.Contains("IntValue"))
{
idata = Convert.ToInt32((string)respParms["IntValue"]);
idata = Convert.ToInt32((string) respParms["IntValue"]);
}
if (respParms.Contains("faultString"))
{
sdata = (string)respParms["faultString"];
sdata = (string) respParms["faultString"];
}
if (respParms.Contains("faultCode"))
{