diff options
author | Tedd Hansen | 2008-02-25 20:10:17 +0000 |
---|---|---|
committer | Tedd Hansen | 2008-02-25 20:10:17 +0000 |
commit | dbb205c18160cfe031e4076ac650eb37b9613b86 (patch) | |
tree | 0b2202ddbc710755e807bed06a0e84a795ca2e20 /OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs | |
parent | eol (diff) | |
download | opensim-SC-dbb205c18160cfe031e4076ac650eb37b9613b86.zip opensim-SC-dbb205c18160cfe031e4076ac650eb37b9613b86.tar.gz opensim-SC-dbb205c18160cfe031e4076ac650eb37b9613b86.tar.bz2 opensim-SC-dbb205c18160cfe031e4076ac650eb37b9613b86.tar.xz |
Moved AsyncCommandManager into separate classes under "plugins".
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs | 93 |
1 files changed, 90 insertions, 3 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs index c9214f1..94c536f 100644 --- a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs +++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/AsyncCommandPlugins/HttpRequest.cs | |||
@@ -1,10 +1,97 @@ | |||
1 | using System; | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using System; | ||
30 | using System.Collections; | ||
2 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
3 | using System.Text; | 32 | using System.Threading; |
33 | using libsecondlife; | ||
34 | using Axiom.Math; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | using OpenSim.Region.Environment.Modules; | ||
37 | using OpenSim.Region.Environment.Scenes; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins; | ||
4 | 40 | ||
5 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins | 41 | namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase.AsyncCommandPlugins |
6 | { | 42 | { |
7 | class HttpRequest | 43 | public class HttpRequest |
8 | { | 44 | { |
45 | public AsyncCommandManager m_CmdManager; | ||
46 | |||
47 | public HttpRequest(AsyncCommandManager CmdManager) | ||
48 | { | ||
49 | m_CmdManager = CmdManager; | ||
50 | } | ||
51 | |||
52 | |||
53 | public void CheckHttpRequests() | ||
54 | { | ||
55 | if (m_CmdManager.m_ScriptEngine.World == null) | ||
56 | return; | ||
57 | |||
58 | IHttpRequests iHttpReq = | ||
59 | m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<IHttpRequests>(); | ||
60 | |||
61 | HttpRequestClass httpInfo = null; | ||
62 | |||
63 | if (iHttpReq != null) | ||
64 | httpInfo = iHttpReq.GetNextCompletedRequest(); | ||
65 | |||
66 | while (httpInfo != null) | ||
67 | { | ||
68 | //m_ScriptEngine.Log.Info("[AsyncLSL]:" + httpInfo.response_body + httpInfo.status); | ||
69 | |||
70 | // Deliver data to prim's remote_data handler | ||
71 | // | ||
72 | // TODO: Returning null for metadata, since the lsl function | ||
73 | // only returns the byte for HTTP_BODY_TRUNCATED, which is not | ||
74 | // implemented here yet anyway. Should be fixed if/when maxsize | ||
75 | // is supported | ||
76 | |||
77 | if (m_CmdManager.m_ScriptEngine.m_ScriptManager.GetScript(httpInfo.localID, httpInfo.itemID) != null) | ||
78 | { | ||
79 | iHttpReq.RemoveCompletedRequest(httpInfo.reqID); | ||
80 | object[] resobj = new object[] | ||
81 | { | ||
82 | httpInfo.reqID.ToString(), httpInfo.status, null, httpInfo.response_body | ||
83 | }; | ||
84 | |||
85 | m_CmdManager.m_ScriptEngine.m_EventQueueManager.AddToScriptQueue( | ||
86 | httpInfo.localID, httpInfo.itemID, "http_response", EventQueueManager.llDetectNull, resobj | ||
87 | ); | ||
88 | //Thread.Sleep(2500); | ||
89 | } | ||
90 | |||
91 | httpInfo = iHttpReq.GetNextCompletedRequest(); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | |||
9 | } | 96 | } |
10 | } | 97 | } |