* This commit incorporates the heart of the OpenGridProtocol patch that is currently on Forge in a nice, friendly modular format.

* There are a lot of changes and this is quite experimental.  It's off by default, but you can turn it on by examining the bottom of the opensim.ini.example for the proper OpenSim.ini settings.    Remember, you still need an agent domain..  
* Furthermore, it isn't quite right when it comes to teleporting to remote regions (place_avatar)
This commit is contained in:
Teravus Ovares
2008-08-25 07:35:17 +00:00
parent 032a4ee9b5
commit 2912aafe25
21 changed files with 1310 additions and 38 deletions

View File

@@ -103,10 +103,41 @@ namespace OpenSim.Framework
AgentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname;
AgentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname;
AgentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos;
// Updated for when we don't know them before calling Scene.NewUserConnection
AgentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID;
AgentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID;
// Console.WriteLine("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
}
}
/// <summary>
/// Sometimes the circuitcode may not be known before setting up the connection
/// </summary>
/// <param name="circuitcode"></param>
/// <param name="newcircuitcode"></param>
public bool TryChangeCiruitCode(uint circuitcode, uint newcircuitcode)
{
lock (AgentCircuits)
{
if (AgentCircuits.ContainsKey((uint)circuitcode) && !AgentCircuits.ContainsKey((uint)newcircuitcode))
{
AgentCircuitData agentData = AgentCircuits[(uint)circuitcode];
agentData.circuitcode = newcircuitcode;
AgentCircuits.Remove((uint)circuitcode);
AgentCircuits.Add(newcircuitcode, agentData);
return true;
}
}
return false;
}
public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
{
if (AgentCircuits.ContainsKey(circuitcode))

View File

@@ -159,6 +159,31 @@ namespace OpenSim.Framework.Communications.Cache
}
}
/// <summary>
/// Preloads User data into the region cache. Modules may use this service to add non-standard clients
/// </summary>
/// <param name="userID"></param>
/// <param name="userData"></param>
public void PreloadUserCache(LLUUID userID, UserProfileData userData)
{
if (userID == LLUUID.Zero)
return;
lock (m_userProfiles)
{
if (m_userProfiles.ContainsKey(userID))
{
return;
}
else
{
CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userData);
m_userProfiles.Add(userID, userInfo);
}
}
}
/// <summary>
/// Handle an inventory folder creation request from the client.
/// </summary>

View File

@@ -0,0 +1,31 @@
/*
* 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.
*/
namespace OpenSim.Framework.Communications.Capabilities
{
public delegate TResponse LLSDMethodString<TRequest, TResponse>(TRequest request, string path);
}

View File

@@ -339,6 +339,11 @@ namespace OpenSim.Framework.Communications
public void ClearUserAgent(LLUUID agentID)
{
UserProfileData profile = GetUserProfile(agentID);
if (profile == null)
{
return;
}
profile.CurrentAgent = null;
UpdateUserProfile(profile);

View File

@@ -349,6 +349,11 @@ namespace OpenSim.Framework
set;
}
bool SendLogoutPacketWhenClosing
{
set;
}
// [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")]
uint CircuitCode { get; }
// [Obsolete("LLClientView Specific - Replace with more bare-bones arguments.")]
@@ -741,5 +746,6 @@ namespace OpenSim.Framework
void SendRegionHandle(LLUUID regoinID, ulong handle);
void SendParcelInfo(RegionInfo info, LandData land, LLUUID parcelID, uint x, uint y);
void KillEndDone();
}
}

View File

@@ -47,8 +47,9 @@ namespace OpenSim.Framework.Servers
protected Thread m_workerThread;
protected HttpListener m_httpListener;
protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
protected LLSDMethod m_llsdHandler = null;
protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
protected DefaultLLSDMethod m_defaultLlsdHandler = null; // <-- Moving away from the monolithic.. and going to /registered/
protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>();
protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>();
protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>();
protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>();
@@ -148,9 +149,28 @@ namespace OpenSim.Framework.Servers
return false;
}
public bool SetLLSDHandler(LLSDMethod handler)
/// <summary>
/// Adds a LLSD handler, yay.
/// </summary>
/// <param name="path">/resource/ path</param>
/// <param name="handler">handle the LLSD response</param>
/// <returns></returns>
public bool AddLLSDHandler(string path, LLSDMethod handler)
{
m_llsdHandler = handler;
lock (m_llsdHandlers)
{
if (!m_llsdHandlers.ContainsKey(path))
{
m_llsdHandlers.Add(path, handler);
return true;
}
}
return false;
}
public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler)
{
m_defaultLlsdHandler = handler;
return true;
}
@@ -239,20 +259,21 @@ namespace OpenSim.Framework.Servers
switch (request.ContentType)
{
case null:
case "text/html":
HandleHTTPRequest(request, response);
return;
case null:
case "text/html":
HandleHTTPRequest(request, response);
return;
case "application/xml+llsd":
HandleLLSDRequests(request, response);
return;
case "application/llsd+xml":
case "application/xml+llsd":
HandleLLSDRequests(request, response);
return;
case "text/xml":
case "application/xml":
default:
HandleXmlRpcRequests(request, response);
return;
case "text/xml":
case "application/xml":
default:
HandleXmlRpcRequests(request, response);
return;
}
}
catch (SocketException e)
@@ -456,17 +477,37 @@ namespace OpenSim.Framework.Servers
m_log.Warn("[HTTPD]: Error - " + ex.Message);
}
if (llsdRequest != null && m_llsdHandler != null)
if (llsdRequest != null)// && m_defaultLlsdHandler != null)
{
llsdResponse = m_llsdHandler(llsdRequest);
LLSDMethod llsdhandler = null;
if (TryGetLLSDHandler(request.RawUrl, out llsdhandler))
{
// we found a registered llsd handler to service this request
llsdResponse = llsdhandler(request.RawUrl, llsdRequest, request.RemoteIPEndPoint.ToString());
}
else
{
// we didn't find a registered llsd handler to service this request
// check if we have a default llsd handler
if (m_defaultLlsdHandler != null)
{
// LibOMV path
llsdResponse = m_defaultLlsdHandler(llsdRequest);
}
else
{
// Oops, no handler for this.. give em the failed message
llsdResponse = GenerateNoLLSDHandlerResponse();
}
}
}
else
{
LLSDMap map = new LLSDMap();
map["reason"] = LLSD.FromString("LLSDRequest");
map["message"] = LLSD.FromString("No handler registered for LLSD Requests");
map["login"] = LLSD.FromString("false");
llsdResponse = map;
llsdResponse = GenerateNoLLSDHandlerResponse();
}
response.ContentType = "application/xml+llsd";
@@ -491,6 +532,68 @@ namespace OpenSim.Framework.Servers
}
}
private bool TryGetLLSDHandler(string path, out LLSDMethod llsdHandler)
{
llsdHandler = null;
// Pull out the first part of the path
// splitting the path by '/' means we'll get the following return..
// {0}/{1}/{2}
// where {0} isn't something we really control 100%
string[] pathbase = path.Split('/');
string searchquery = "/";
if (pathbase.Length < 1)
return false;
for (int i=1; i<pathbase.Length; i++)
{
searchquery += pathbase[i];
if (pathbase.Length-1 != i)
searchquery += "/";
}
// while the matching algorithm below doesn't require it, we're expecting a query in the form
//
// [] = optional
// /resource/UUID/action[/action]
//
// now try to get the closest match to the reigstered path
// at least for OGP, registered path would probably only consist of the /resource/
string bestMatch = null;
foreach (string pattern in m_llsdHandlers.Keys)
{
if (searchquery.StartsWith(searchquery))
{
if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length)
{
bestMatch = pattern;
}
}
}
if (String.IsNullOrEmpty(bestMatch))
{
llsdHandler = null;
return false;
}
else
{
llsdHandler = m_llsdHandlers[bestMatch];
return true;
}
}
private LLSDMap GenerateNoLLSDHandlerResponse()
{
LLSDMap map = new LLSDMap();
map["reason"] = LLSD.FromString("LLSDRequest");
map["message"] = LLSD.FromString("No handler registered for LLSD Requests");
map["login"] = LLSD.FromString("false");
return map;
}
/// <summary>
/// A specific agent handler was provided. Such a handler is expecetd to have an
/// intimate, and highly specific relationship with the client. Consequently,
@@ -809,6 +912,25 @@ namespace OpenSim.Framework.Servers
return false;
}
public bool RemoveLLSDHandler(string path, LLSDMethod handler)
{
try
{
if (handler == m_llsdHandlers[path])
{
m_llsdHandlers.Remove(path);
return true;
}
}
catch (KeyNotFoundException)
{
// This is an exception to prevent crashing because of invalid code
}
return false;
}
public string GetHTTP404(string host)
{

View File

@@ -29,5 +29,6 @@ using libsecondlife.StructuredData;
namespace OpenSim.Framework.Servers
{
public delegate LLSD LLSDMethod(LLSD request);
public delegate LLSD LLSDMethod( string path, LLSD request, string endpoint );
public delegate LLSD DefaultLLSDMethod(LLSD request);
}

View File

@@ -0,0 +1,33 @@
/*
* 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 libsecondlife.StructuredData;
namespace OpenSim.Framework.Servers
{
public delegate LLSD LLSDMethodString(LLSD request, string thePath);
}