aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/XMLRPCModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/XMLRPCModule.cs65
1 files changed, 33 insertions, 32 deletions
diff --git a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
index dd84778..434c92f 100644
--- a/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
+++ b/OpenSim/Region/Environment/Modules/XMLRPCModule.cs
@@ -26,20 +26,15 @@
26* 26*
27*/ 27*/
28 28
29using System; 29using System.Collections;
30using System.IO; 30using System.Collections.Generic;
31using System.Net.Sockets;
32using System.Threading; 31using System.Threading;
33using libsecondlife; 32using libsecondlife;
34using OpenSim.Framework.Interfaces; 33using Nini.Config;
35using OpenSim.Framework; 34using Nwc.XmlRpc;
35using OpenSim.Framework.Servers;
36using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.Environment.Scenes; 37using OpenSim.Region.Environment.Scenes;
38using OpenSim.Framework.Servers;
39using Nwc.XmlRpc;
40using System.Collections;
41using System.Collections.Generic;
42using Nini.Config;
43 38
44/***************************************************** 39/*****************************************************
45 * 40 *
@@ -73,6 +68,7 @@ using Nini.Config;
73 * llCloseRemoteDataChannel 68 * llCloseRemoteDataChannel
74 * 69 *
75 * **************************************************/ 70 * **************************************************/
71
76namespace OpenSim.Region.Environment.Modules 72namespace OpenSim.Region.Environment.Modules
77{ 73{
78 public class XMLRPCModule : IRegionModule, IXMLRPC 74 public class XMLRPCModule : IRegionModule, IXMLRPC
@@ -83,7 +79,7 @@ namespace OpenSim.Region.Environment.Modules
83 private string m_name = "XMLRPCModule"; 79 private string m_name = "XMLRPCModule";
84 private int RemoteReplyScriptWait = 100; 80 private int RemoteReplyScriptWait = 100;
85 private int RemoteReplyScriptTimeout = 300; 81 private int RemoteReplyScriptTimeout = 300;
86 82
87 // <channel id, RPCChannelInfo> 83 // <channel id, RPCChannelInfo>
88 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels; 84 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels;
89 85
@@ -106,7 +102,7 @@ namespace OpenSim.Region.Environment.Modules
106 // Start http server 102 // Start http server
107 // Attach xmlrpc handlers 103 // Attach xmlrpc handlers
108 BaseHttpServer httpServer = new BaseHttpServer(20800); 104 BaseHttpServer httpServer = new BaseHttpServer(20800);
109 httpServer.AddXmlRPCHandler("llRemoteData", this.XmlRpcRemoteData); 105 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
110 httpServer.Start(); 106 httpServer.Start();
111 } 107 }
112 108
@@ -141,6 +137,7 @@ namespace OpenSim.Region.Environment.Modules
141 * current channel and assign a new one. 137 * current channel and assign a new one.
142 * 138 *
143 * ********************************************/ 139 * ********************************************/
140
144 public LLUUID OpenXMLRPCChannel(uint localID, LLUUID itemID) 141 public LLUUID OpenXMLRPCChannel(uint localID, LLUUID itemID)
145 { 142 {
146 LLUUID channel = null; 143 LLUUID channel = null;
@@ -156,7 +153,7 @@ namespace OpenSim.Region.Environment.Modules
156 } 153 }
157 } 154 }
158 155
159 if ( (channel == null) || (channel.Equals(LLUUID.Zero)) ) 156 if ((channel == null) || (channel.Equals(LLUUID.Zero)))
160 { 157 {
161 channel = LLUUID.Random(); 158 channel = LLUUID.Random();
162 RPCChannelInfo rpcChanInfo = new RPCChannelInfo(localID, itemID, channel); 159 RPCChannelInfo rpcChanInfo = new RPCChannelInfo(localID, itemID, channel);
@@ -164,7 +161,6 @@ namespace OpenSim.Region.Environment.Modules
164 { 161 {
165 m_openChannels.Add(channel, rpcChanInfo); 162 m_openChannels.Add(channel, rpcChanInfo);
166 } 163 }
167
168 } 164 }
169 165
170 return channel; 166 return channel;
@@ -176,6 +172,7 @@ namespace OpenSim.Region.Environment.Modules
176 * Response to RPC message 172 * Response to RPC message
177 * 173 *
178 *********************************************/ 174 *********************************************/
175
179 public void RemoteDataReply(string channel, string message_id, string sdata, int idata) 176 public void RemoteDataReply(string channel, string message_id, string sdata, int idata)
180 { 177 {
181 RPCRequestInfo rpcInfo; 178 RPCRequestInfo rpcInfo;
@@ -191,7 +188,6 @@ namespace OpenSim.Region.Environment.Modules
191 m_pendingResponse.Remove(message_key); 188 m_pendingResponse.Remove(message_key);
192 } 189 }
193 } 190 }
194
195 } 191 }
196 192
197 /********************************************** 193 /**********************************************
@@ -200,41 +196,44 @@ namespace OpenSim.Region.Environment.Modules
200 * Remove channel from dictionary 196 * Remove channel from dictionary
201 * 197 *
202 *********************************************/ 198 *********************************************/
199
203 public void CloseXMLRPCChannel(LLUUID channelKey) 200 public void CloseXMLRPCChannel(LLUUID channelKey)
204 { 201 {
205 if(m_openChannels.ContainsKey(channelKey)) 202 if (m_openChannels.ContainsKey(channelKey))
206 m_openChannels.Remove(channelKey); 203 m_openChannels.Remove(channelKey);
207 } 204 }
208 205
209 206
210 public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request) 207 public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
211 { 208 {
212
213 XmlRpcResponse response = new XmlRpcResponse(); 209 XmlRpcResponse response = new XmlRpcResponse();
214 210
215 Hashtable requestData = (Hashtable)request.Params[0]; 211 Hashtable requestData = (Hashtable) request.Params[0];
216 bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") && requestData.Contains("StringValue")); 212 bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
213 requestData.Contains("StringValue"));
217 214
218 if (GoodXML) 215 if (GoodXML)
219 { 216 {
220 LLUUID channel = new LLUUID((string)requestData["Channel"]); 217 LLUUID channel = new LLUUID((string) requestData["Channel"]);
221 RPCChannelInfo rpcChanInfo; 218 RPCChannelInfo rpcChanInfo;
222 if (m_openChannels.TryGetValue(channel, out rpcChanInfo)) 219 if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
223 { 220 {
224 string intVal = (string)requestData["IntValue"]; 221 string intVal = (string) requestData["IntValue"];
225 string strVal = (string)requestData["StringValue"]; 222 string strVal = (string) requestData["StringValue"];
226 223
227 RPCRequestInfo rpcInfo; 224 RPCRequestInfo rpcInfo;
228 225
229 lock (XMLRPCListLock) 226 lock (XMLRPCListLock)
230 { 227 {
231 rpcInfo = new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal, intVal); 228 rpcInfo =
229 new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
230 intVal);
232 rpcQueue.Enqueue(rpcInfo); 231 rpcQueue.Enqueue(rpcInfo);
233 } 232 }
234 233
235 int timeoutCtr = 0; 234 int timeoutCtr = 0;
236 235
237 while(!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout)) 236 while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
238 { 237 {
239 Thread.Sleep(RemoteReplyScriptWait); 238 Thread.Sleep(RemoteReplyScriptWait);
240 timeoutCtr += RemoteReplyScriptWait; 239 timeoutCtr += RemoteReplyScriptWait;
@@ -252,13 +251,11 @@ namespace OpenSim.Region.Environment.Modules
252 m_pendingResponse.Remove(rpcInfo.GetMessageID()); 251 m_pendingResponse.Remove(rpcInfo.GetMessageID());
253 } 252 }
254 } 253 }
255
256 } 254 }
257 else 255 else
258 { 256 {
259 response.SetFault(-1, "Invalid channel"); 257 response.SetFault(-1, "Invalid channel");
260 } 258 }
261
262 } 259 }
263 260
264 return response; 261 return response;
@@ -278,7 +275,6 @@ namespace OpenSim.Region.Environment.Modules
278 return rpcInfo; 275 return rpcInfo;
279 } 276 }
280 } 277 }
281
282 } 278 }
283 279
284 /************************************************************** 280 /**************************************************************
@@ -288,6 +284,7 @@ namespace OpenSim.Region.Environment.Modules
288 * Holds details about incoming requests until they are picked 284 * Holds details about incoming requests until they are picked
289 * from the queue by LSLLongCmdHandler 285 * from the queue by LSLLongCmdHandler
290 * ***********************************************************/ 286 * ***********************************************************/
287
291 public class RPCRequestInfo 288 public class RPCRequestInfo
292 { 289 {
293 private string m_StrVal; 290 private string m_StrVal;
@@ -315,6 +312,7 @@ namespace OpenSim.Region.Environment.Modules
315 { 312 {
316 return m_processed; 313 return m_processed;
317 } 314 }
315
318 public LLUUID GetChannelKey() 316 public LLUUID GetChannelKey()
319 { 317 {
320 return m_ChannelKey; 318 return m_ChannelKey;
@@ -324,36 +322,41 @@ namespace OpenSim.Region.Environment.Modules
324 { 322 {
325 m_processed = processed; 323 m_processed = processed;
326 } 324 }
325
327 public void SetRetval(string resp) 326 public void SetRetval(string resp)
328 { 327 {
329 m_resp = resp; 328 m_resp = resp;
330 } 329 }
330
331 public string GetRetval() 331 public string GetRetval()
332 { 332 {
333 return m_resp; 333 return m_resp;
334 } 334 }
335
335 public uint GetLocalID() 336 public uint GetLocalID()
336 { 337 {
337 return m_localID; 338 return m_localID;
338 } 339 }
340
339 public LLUUID GetItemID() 341 public LLUUID GetItemID()
340 { 342 {
341 return m_ItemID; 343 return m_ItemID;
342 } 344 }
345
343 public string GetStrVal() 346 public string GetStrVal()
344 { 347 {
345 return m_StrVal; 348 return m_StrVal;
346 } 349 }
350
347 public int GetIntValue() 351 public int GetIntValue()
348 { 352 {
349 return int.Parse(m_IntVal); 353 return int.Parse(m_IntVal);
350 } 354 }
355
351 public LLUUID GetMessageID() 356 public LLUUID GetMessageID()
352 { 357 {
353 return m_MessageID; 358 return m_MessageID;
354 } 359 }
355
356
357 } 360 }
358 361
359 public class RPCChannelInfo 362 public class RPCChannelInfo
@@ -383,7 +386,5 @@ namespace OpenSim.Region.Environment.Modules
383 { 386 {
384 return m_localID; 387 return m_localID;
385 } 388 }
386
387 } 389 }
388 390} \ No newline at end of file
389}