* This is the very very early beginnings of an EventQueue:get module.
* This won't function yet as far as the client can tell.. because it doesn't respond to the first query with a 200 message. * We have to figure out how to encode those binary values in the example code in the module... * Committing this so we have a start point. Will continue to work on this more today.0.6.0-stable
parent
1f8888a287
commit
85b280385f
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace OpenSim.Framework.Servers
|
||||
{
|
||||
public abstract class BaseHTTPHandler : BaseRequestHandler, IGenericHTTPHandler
|
||||
{
|
||||
public abstract Hashtable Handle(string path, Hashtable Request);
|
||||
|
||||
protected BaseHTTPHandler(string httpMethod, string path)
|
||||
: base(httpMethod, path)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -361,9 +361,57 @@ namespace OpenSim.Framework.Servers
|
|||
|
||||
buffer = streamedRequestHandler.Handle(path, request.InputStream, request, response);
|
||||
}
|
||||
else if (requestHandler is IGenericHTTPHandler)
|
||||
{
|
||||
IGenericHTTPHandler HTTPRequestHandler = requestHandler as IGenericHTTPHandler;
|
||||
Stream requestStream = request.InputStream;
|
||||
|
||||
Encoding encoding = Encoding.UTF8;
|
||||
StreamReader reader = new StreamReader(requestStream, encoding);
|
||||
|
||||
string requestBody = reader.ReadToEnd();
|
||||
|
||||
|
||||
reader.Close();
|
||||
requestStream.Close();
|
||||
|
||||
Hashtable keysvals = new Hashtable();
|
||||
Hashtable headervals = new Hashtable();
|
||||
string host = String.Empty;
|
||||
|
||||
string[] querystringkeys = request.QueryString.AllKeys;
|
||||
string[] rHeaders = request.Headers.AllKeys;
|
||||
|
||||
|
||||
foreach (string queryname in querystringkeys)
|
||||
{
|
||||
keysvals.Add(queryname, request.QueryString[queryname]);
|
||||
}
|
||||
|
||||
foreach (string headername in rHeaders)
|
||||
{
|
||||
//m_log.Warn("[HEADER]: " + headername + "=" + request.Headers[headername]);
|
||||
headervals[headername] = request.Headers[headername];
|
||||
}
|
||||
|
||||
if (headervals.Contains("Host"))
|
||||
{
|
||||
host = (string)headervals["Host"];
|
||||
}
|
||||
keysvals.Add("requestbody",requestBody);
|
||||
if (keysvals.Contains("method"))
|
||||
{
|
||||
//m_log.Warn("[HTTP]: Contains Method");
|
||||
string method = (string)keysvals["method"];
|
||||
//m_log.Warn("[HTTP]: " + requestBody);
|
||||
|
||||
}
|
||||
DoHTTPGruntWork(HTTPRequestHandler.Handle(path,keysvals), response);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
IStreamHandler streamHandler = (IStreamHandler) requestHandler;
|
||||
IStreamHandler streamHandler = (IStreamHandler)requestHandler;
|
||||
|
||||
using (MemoryStream memoryStream = new MemoryStream())
|
||||
{
|
||||
|
@ -943,6 +991,9 @@ namespace OpenSim.Framework.Servers
|
|||
string responseString = (string)responsedata["str_response_string"];
|
||||
string contentType = (string)responsedata["content_type"];
|
||||
|
||||
if (responsedata.ContainsKey("keepalive"))
|
||||
response.KeepAlive = true;
|
||||
|
||||
//Even though only one other part of the entire code uses HTTPHandlers, we shouldn't expect this
|
||||
//and should check for NullReferenceExceptions
|
||||
|
||||
|
@ -951,10 +1002,9 @@ namespace OpenSim.Framework.Servers
|
|||
contentType = "text/html";
|
||||
}
|
||||
|
||||
// We're forgoing the usual error status codes here because the client
|
||||
// ignores anything but 200 and 301
|
||||
|
||||
response.StatusCode = (int)OSHttpStatusCode.SuccessOk;
|
||||
// The client ignores anything but 200 here for web login, so ensure that this is 200 for that
|
||||
|
||||
response.StatusCode = responsecode;
|
||||
|
||||
if (responsecode == (int)OSHttpStatusCode.RedirectMovedPermanently)
|
||||
{
|
||||
|
@ -978,6 +1028,7 @@ namespace OpenSim.Framework.Servers
|
|||
response.SendChunked = false;
|
||||
response.ContentLength64 = buffer.Length;
|
||||
response.ContentEncoding = Encoding.UTF8;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace OpenSim.Framework.Servers
|
||||
{
|
||||
public class RestHTTPHandler : BaseHTTPHandler
|
||||
{
|
||||
private GenericHTTPMethod m_dhttpMethod;
|
||||
|
||||
public GenericHTTPMethod Method
|
||||
{
|
||||
get { return m_dhttpMethod; }
|
||||
}
|
||||
|
||||
public override Hashtable Handle(string path, Hashtable request)
|
||||
{
|
||||
|
||||
string param = GetParam(path);
|
||||
request.Add("param", param);
|
||||
request.Add("path", path);
|
||||
return m_dhttpMethod(request);
|
||||
}
|
||||
|
||||
public RestHTTPHandler(string httpMethod, string path, GenericHTTPMethod dhttpMethod)
|
||||
: base(httpMethod, path)
|
||||
{
|
||||
m_dhttpMethod = dhttpMethod;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using Nwc.XmlRpc;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
using OpenSim.Framework.Communications.Capabilities;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using OpenSim.Region.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
|
||||
using LLSD = OpenMetaverse.StructuredData.LLSD;
|
||||
using LLSDMap = OpenMetaverse.StructuredData.LLSDMap;
|
||||
using LLSDArray = OpenMetaverse.StructuredData.LLSDArray;
|
||||
using Caps = OpenSim.Framework.Communications.Capabilities.Caps;
|
||||
|
||||
namespace OpenSim.Region.Environment.Modules.Framework
|
||||
{
|
||||
public class EventQueueGetModule : IEventQueue, IRegionModule
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
Scene m_scene = null;
|
||||
IConfigSource m_gConfig;
|
||||
|
||||
#region IRegionModule methods
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
{
|
||||
m_gConfig = config;
|
||||
m_scene = scene;
|
||||
|
||||
|
||||
IConfig startupConfig = m_gConfig.Configs["Startup"];
|
||||
|
||||
ReadConfigAndPopulate(scene, startupConfig, "Startup");
|
||||
|
||||
scene.RegisterModuleInterface<IEventQueue>(this);
|
||||
|
||||
scene.EventManager.OnNewClient += OnNewClient;
|
||||
scene.EventManager.OnClientClosed += ClientClosed;
|
||||
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
|
||||
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
|
||||
scene.EventManager.OnClientClosed += ClientLoggedOut;
|
||||
scene.EventManager.OnRegisterCaps += OnRegisterCaps;
|
||||
|
||||
}
|
||||
|
||||
private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "EventQueueGetModule"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IEventQueue Members
|
||||
public bool Enqueue(object o, UUID avatarID)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void OnNewClient(IClientAPI client)
|
||||
{
|
||||
|
||||
client.OnLogout += ClientClosed;
|
||||
}
|
||||
|
||||
|
||||
public void ClientClosed(IClientAPI client)
|
||||
{
|
||||
ClientClosed(client.AgentId);
|
||||
}
|
||||
|
||||
private void ClientLoggedOut(UUID AgentId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ClientClosed(UUID AgentID)
|
||||
{
|
||||
|
||||
}
|
||||
private void MakeChildAgent(ScenePresence avatar)
|
||||
{
|
||||
}
|
||||
public void OnRegisterCaps(UUID agentID, Caps caps)
|
||||
{
|
||||
m_log.DebugFormat("[EVENTQUEUE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
|
||||
string capsBase = "/CAPS/";
|
||||
caps.RegisterHandler("EventQueueGet",
|
||||
new RestHTTPHandler("POST", capsBase + UUID.Random().ToString(),
|
||||
delegate(Hashtable m_dhttpMethod)
|
||||
{
|
||||
return ProcessQueue(m_dhttpMethod,agentID, caps);
|
||||
}));
|
||||
}
|
||||
public Hashtable ProcessQueue(Hashtable request,UUID agentID, Caps caps)
|
||||
{
|
||||
|
||||
Hashtable responsedata = new Hashtable();
|
||||
responsedata["int_response_code"] = 502;
|
||||
responsedata["str_response_string"] = "Upstream error:";
|
||||
responsedata["content_type"] = "text/plain";
|
||||
responsedata["keepalive"] = true;
|
||||
|
||||
/*
|
||||
responsedata["int_response_code"] = 200;
|
||||
responsedata["content_type"] = "application/xml";
|
||||
responsedata["keepalive"] = true;
|
||||
|
||||
responsedata["str_response_string"] = @"<llsd><map><key>events</key><array><map><key>body</key><map><key>AgentData</key><map><key>AgentID</key>
|
||||
<uuid>0fd0e798-a54f-40b1-0000-000000000000</uuid><key>SessionID</key><uuid>cc91f1fe-9d52-435d-0000-000000000000
|
||||
</uuid></map><key>Info</key><map><key>LookAt</key><array><real>0.9869639873504638671875</real><real>
|
||||
-0.1609439998865127563476562</real><real>0</real></array><key>Position</key><array><real>1.43747997283935546875
|
||||
</real><real>95.30560302734375</real><real>57.3480987548828125</real></array></map><key>RegionData</key><map>
|
||||
<key>RegionHandle</key><binary encoding=" + "\"base64\"" + @">AAPnAAAD8AA=</binary><key>SeedCapability</key><string>
|
||||
https://sim7.aditi.lindenlab.com:12043/cap/64015fb3-6fee-9205-0000-000000000000</string><key>SimIP</key><binary
|
||||
encoding=" + "\"base64\"" + @">yA8FSA==</binary><key>SimPort</key><integer>13005</integer></map></map><key>message</key>
|
||||
<string>CrossedRegion</string></map></array><key>id</key><integer>1</integer></map></llsd>";
|
||||
|
||||
*/
|
||||
//string requestbody = (string)request["requestbody"];
|
||||
//LLSD llsdRequest = LLSDParser.DeserializeXml(request);
|
||||
//System.Console.WriteLine(requestbody);
|
||||
return responsedata;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using OpenSim.Framework;
|
||||
using OpenMetaverse;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.Interfaces
|
||||
{
|
||||
public interface IEventQueue
|
||||
{
|
||||
bool Enqueue(object o, UUID avatarID);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue