aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorTeravus Ovares2008-08-25 07:35:17 +0000
committerTeravus Ovares2008-08-25 07:35:17 +0000
commit2912aafe259727351eb9405532e45aa3501b7e9a (patch)
tree34774a49306ae19a6682580d41927fcfb222ea6e /OpenSim/Framework
parentMantis#2043. Thank you kindly, Ralphos for a patch that addresses: (diff)
downloadopensim-SC_OLD-2912aafe259727351eb9405532e45aa3501b7e9a.zip
opensim-SC_OLD-2912aafe259727351eb9405532e45aa3501b7e9a.tar.gz
opensim-SC_OLD-2912aafe259727351eb9405532e45aa3501b7e9a.tar.bz2
opensim-SC_OLD-2912aafe259727351eb9405532e45aa3501b7e9a.tar.xz
* 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)
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/AgentCircuitManager.cs31
-rw-r--r--OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs25
-rw-r--r--OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs31
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs5
-rw-r--r--OpenSim/Framework/IClientAPI.cs6
-rw-r--r--OpenSim/Framework/Servers/BaseHttpServer.cs168
-rw-r--r--OpenSim/Framework/Servers/LLSDMethod.cs3
-rw-r--r--OpenSim/Framework/Servers/LLSDMethodString.cs33
8 files changed, 278 insertions, 24 deletions
diff --git a/OpenSim/Framework/AgentCircuitManager.cs b/OpenSim/Framework/AgentCircuitManager.cs
index 426e8e2..80e2f87 100644
--- a/OpenSim/Framework/AgentCircuitManager.cs
+++ b/OpenSim/Framework/AgentCircuitManager.cs
@@ -103,10 +103,41 @@ namespace OpenSim.Framework
103 AgentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname; 103 AgentCircuits[(uint) agentData.circuitcode].firstname = agentData.firstname;
104 AgentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname; 104 AgentCircuits[(uint) agentData.circuitcode].lastname = agentData.lastname;
105 AgentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos; 105 AgentCircuits[(uint) agentData.circuitcode].startpos = agentData.startpos;
106
107 // Updated for when we don't know them before calling Scene.NewUserConnection
108 AgentCircuits[(uint) agentData.circuitcode].SecureSessionID = agentData.SecureSessionID;
109 AgentCircuits[(uint) agentData.circuitcode].SessionID = agentData.SessionID;
110
106 // Console.WriteLine("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z); 111 // Console.WriteLine("update user start pos is " + agentData.startpos.X + " , " + agentData.startpos.Y + " , " + agentData.startpos.Z);
107 } 112 }
108 } 113 }
109 114
115
116 /// <summary>
117 /// Sometimes the circuitcode may not be known before setting up the connection
118 /// </summary>
119 /// <param name="circuitcode"></param>
120 /// <param name="newcircuitcode"></param>
121
122 public bool TryChangeCiruitCode(uint circuitcode, uint newcircuitcode)
123 {
124 lock (AgentCircuits)
125 {
126 if (AgentCircuits.ContainsKey((uint)circuitcode) && !AgentCircuits.ContainsKey((uint)newcircuitcode))
127 {
128 AgentCircuitData agentData = AgentCircuits[(uint)circuitcode];
129
130 agentData.circuitcode = newcircuitcode;
131
132 AgentCircuits.Remove((uint)circuitcode);
133 AgentCircuits.Add(newcircuitcode, agentData);
134 return true;
135 }
136 }
137 return false;
138
139 }
140
110 public void UpdateAgentChildStatus(uint circuitcode, bool childstatus) 141 public void UpdateAgentChildStatus(uint circuitcode, bool childstatus)
111 { 142 {
112 if (AgentCircuits.ContainsKey(circuitcode)) 143 if (AgentCircuits.ContainsKey(circuitcode))
diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
index 4e3840b..3b02c88 100644
--- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
+++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs
@@ -160,6 +160,31 @@ namespace OpenSim.Framework.Communications.Cache
160 } 160 }
161 161
162 /// <summary> 162 /// <summary>
163 /// Preloads User data into the region cache. Modules may use this service to add non-standard clients
164 /// </summary>
165 /// <param name="userID"></param>
166 /// <param name="userData"></param>
167 public void PreloadUserCache(LLUUID userID, UserProfileData userData)
168 {
169 if (userID == LLUUID.Zero)
170 return;
171
172 lock (m_userProfiles)
173 {
174 if (m_userProfiles.ContainsKey(userID))
175 {
176 return;
177 }
178 else
179 {
180
181 CachedUserInfo userInfo = new CachedUserInfo(m_commsManager, userData);
182 m_userProfiles.Add(userID, userInfo);
183 }
184 }
185 }
186
187 /// <summary>
163 /// Handle an inventory folder creation request from the client. 188 /// Handle an inventory folder creation request from the client.
164 /// </summary> 189 /// </summary>
165 /// <param name="remoteClient"></param> 190 /// <param name="remoteClient"></param>
diff --git a/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs b/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs
new file mode 100644
index 0000000..31325d8
--- /dev/null
+++ b/OpenSim/Framework/Communications/Capabilities/LLSDMethodString.cs
@@ -0,0 +1,31 @@
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
28namespace OpenSim.Framework.Communications.Capabilities
29{
30 public delegate TResponse LLSDMethodString<TRequest, TResponse>(TRequest request, string path);
31}
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index fd02382..a35ed72 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -339,6 +339,11 @@ namespace OpenSim.Framework.Communications
339 public void ClearUserAgent(LLUUID agentID) 339 public void ClearUserAgent(LLUUID agentID)
340 { 340 {
341 UserProfileData profile = GetUserProfile(agentID); 341 UserProfileData profile = GetUserProfile(agentID);
342
343 if (profile == null)
344 {
345 return;
346 }
342 profile.CurrentAgent = null; 347 profile.CurrentAgent = null;
343 348
344 UpdateUserProfile(profile); 349 UpdateUserProfile(profile);
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index b2d13c7..f437902 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -349,6 +349,11 @@ namespace OpenSim.Framework
349 set; 349 set;
350 } 350 }
351 351
352 bool SendLogoutPacketWhenClosing
353 {
354 set;
355 }
356
352 // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")] 357 // [Obsolete("LLClientView Specific - Circuits are unique to LLClientView")]
353 uint CircuitCode { get; } 358 uint CircuitCode { get; }
354 // [Obsolete("LLClientView Specific - Replace with more bare-bones arguments.")] 359 // [Obsolete("LLClientView Specific - Replace with more bare-bones arguments.")]
@@ -741,5 +746,6 @@ namespace OpenSim.Framework
741 746
742 void SendRegionHandle(LLUUID regoinID, ulong handle); 747 void SendRegionHandle(LLUUID regoinID, ulong handle);
743 void SendParcelInfo(RegionInfo info, LandData land, LLUUID parcelID, uint x, uint y); 748 void SendParcelInfo(RegionInfo info, LandData land, LLUUID parcelID, uint x, uint y);
749 void KillEndDone();
744 } 750 }
745} 751}
diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs
index 23c28e6..7b2b599 100644
--- a/OpenSim/Framework/Servers/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/BaseHttpServer.cs
@@ -47,8 +47,9 @@ namespace OpenSim.Framework.Servers
47 47
48 protected Thread m_workerThread; 48 protected Thread m_workerThread;
49 protected HttpListener m_httpListener; 49 protected HttpListener m_httpListener;
50 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); 50 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
51 protected LLSDMethod m_llsdHandler = null; 51 protected DefaultLLSDMethod m_defaultLlsdHandler = null; // <-- Moving away from the monolithic.. and going to /registered/
52 protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>();
52 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>(); 53 protected Dictionary<string, IRequestHandler> m_streamHandlers = new Dictionary<string, IRequestHandler>();
53 protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>(); 54 protected Dictionary<string, GenericHTTPMethod> m_HTTPHandlers = new Dictionary<string, GenericHTTPMethod>();
54 protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>(); 55 protected Dictionary<string, IHttpAgentHandler> m_agentHandlers = new Dictionary<string, IHttpAgentHandler>();
@@ -148,9 +149,28 @@ namespace OpenSim.Framework.Servers
148 return false; 149 return false;
149 } 150 }
150 151
151 public bool SetLLSDHandler(LLSDMethod handler) 152 /// <summary>
153 /// Adds a LLSD handler, yay.
154 /// </summary>
155 /// <param name="path">/resource/ path</param>
156 /// <param name="handler">handle the LLSD response</param>
157 /// <returns></returns>
158 public bool AddLLSDHandler(string path, LLSDMethod handler)
152 { 159 {
153 m_llsdHandler = handler; 160 lock (m_llsdHandlers)
161 {
162 if (!m_llsdHandlers.ContainsKey(path))
163 {
164 m_llsdHandlers.Add(path, handler);
165 return true;
166 }
167 }
168 return false;
169 }
170
171 public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler)
172 {
173 m_defaultLlsdHandler = handler;
154 return true; 174 return true;
155 } 175 }
156 176
@@ -239,20 +259,21 @@ namespace OpenSim.Framework.Servers
239 259
240 switch (request.ContentType) 260 switch (request.ContentType)
241 { 261 {
242 case null: 262 case null:
243 case "text/html": 263 case "text/html":
244 HandleHTTPRequest(request, response); 264 HandleHTTPRequest(request, response);
245 return; 265 return;
246 266
247 case "application/xml+llsd": 267 case "application/llsd+xml":
248 HandleLLSDRequests(request, response); 268 case "application/xml+llsd":
249 return; 269 HandleLLSDRequests(request, response);
270 return;
250 271
251 case "text/xml": 272 case "text/xml":
252 case "application/xml": 273 case "application/xml":
253 default: 274 default:
254 HandleXmlRpcRequests(request, response); 275 HandleXmlRpcRequests(request, response);
255 return; 276 return;
256 } 277 }
257 } 278 }
258 catch (SocketException e) 279 catch (SocketException e)
@@ -456,17 +477,37 @@ namespace OpenSim.Framework.Servers
456 m_log.Warn("[HTTPD]: Error - " + ex.Message); 477 m_log.Warn("[HTTPD]: Error - " + ex.Message);
457 } 478 }
458 479
459 if (llsdRequest != null && m_llsdHandler != null) 480 if (llsdRequest != null)// && m_defaultLlsdHandler != null)
460 { 481 {
461 llsdResponse = m_llsdHandler(llsdRequest); 482
483 LLSDMethod llsdhandler = null;
484
485 if (TryGetLLSDHandler(request.RawUrl, out llsdhandler))
486 {
487 // we found a registered llsd handler to service this request
488 llsdResponse = llsdhandler(request.RawUrl, llsdRequest, request.RemoteIPEndPoint.ToString());
489 }
490 else
491 {
492 // we didn't find a registered llsd handler to service this request
493 // check if we have a default llsd handler
494
495 if (m_defaultLlsdHandler != null)
496 {
497 // LibOMV path
498 llsdResponse = m_defaultLlsdHandler(llsdRequest);
499 }
500 else
501 {
502 // Oops, no handler for this.. give em the failed message
503 llsdResponse = GenerateNoLLSDHandlerResponse();
504 }
505 }
506
462 } 507 }
463 else 508 else
464 { 509 {
465 LLSDMap map = new LLSDMap(); 510 llsdResponse = GenerateNoLLSDHandlerResponse();
466 map["reason"] = LLSD.FromString("LLSDRequest");
467 map["message"] = LLSD.FromString("No handler registered for LLSD Requests");
468 map["login"] = LLSD.FromString("false");
469 llsdResponse = map;
470 } 511 }
471 512
472 response.ContentType = "application/xml+llsd"; 513 response.ContentType = "application/xml+llsd";
@@ -491,6 +532,68 @@ namespace OpenSim.Framework.Servers
491 } 532 }
492 } 533 }
493 534
535 private bool TryGetLLSDHandler(string path, out LLSDMethod llsdHandler)
536 {
537 llsdHandler = null;
538 // Pull out the first part of the path
539 // splitting the path by '/' means we'll get the following return..
540 // {0}/{1}/{2}
541 // where {0} isn't something we really control 100%
542
543 string[] pathbase = path.Split('/');
544 string searchquery = "/";
545
546 if (pathbase.Length < 1)
547 return false;
548
549 for (int i=1; i<pathbase.Length; i++)
550 {
551 searchquery += pathbase[i];
552 if (pathbase.Length-1 != i)
553 searchquery += "/";
554 }
555
556 // while the matching algorithm below doesn't require it, we're expecting a query in the form
557 //
558 // [] = optional
559 // /resource/UUID/action[/action]
560 //
561 // now try to get the closest match to the reigstered path
562 // at least for OGP, registered path would probably only consist of the /resource/
563
564 string bestMatch = null;
565
566 foreach (string pattern in m_llsdHandlers.Keys)
567 {
568 if (searchquery.StartsWith(searchquery))
569 {
570 if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length)
571 {
572 bestMatch = pattern;
573 }
574 }
575 }
576
577 if (String.IsNullOrEmpty(bestMatch))
578 {
579 llsdHandler = null;
580 return false;
581 }
582 else
583 {
584 llsdHandler = m_llsdHandlers[bestMatch];
585 return true;
586 }
587 }
588
589 private LLSDMap GenerateNoLLSDHandlerResponse()
590 {
591 LLSDMap map = new LLSDMap();
592 map["reason"] = LLSD.FromString("LLSDRequest");
593 map["message"] = LLSD.FromString("No handler registered for LLSD Requests");
594 map["login"] = LLSD.FromString("false");
595 return map;
596 }
494 /// <summary> 597 /// <summary>
495 /// A specific agent handler was provided. Such a handler is expecetd to have an 598 /// A specific agent handler was provided. Such a handler is expecetd to have an
496 /// intimate, and highly specific relationship with the client. Consequently, 599 /// intimate, and highly specific relationship with the client. Consequently,
@@ -809,6 +912,25 @@ namespace OpenSim.Framework.Servers
809 912
810 return false; 913 return false;
811 } 914 }
915 public bool RemoveLLSDHandler(string path, LLSDMethod handler)
916 {
917
918 try
919 {
920 if (handler == m_llsdHandlers[path])
921 {
922 m_llsdHandlers.Remove(path);
923 return true;
924 }
925 }
926 catch (KeyNotFoundException)
927 {
928 // This is an exception to prevent crashing because of invalid code
929 }
930
931 return false;
932 }
933
812 934
813 public string GetHTTP404(string host) 935 public string GetHTTP404(string host)
814 { 936 {
diff --git a/OpenSim/Framework/Servers/LLSDMethod.cs b/OpenSim/Framework/Servers/LLSDMethod.cs
index 05c23b0..7bb946e 100644
--- a/OpenSim/Framework/Servers/LLSDMethod.cs
+++ b/OpenSim/Framework/Servers/LLSDMethod.cs
@@ -29,5 +29,6 @@ using libsecondlife.StructuredData;
29 29
30namespace OpenSim.Framework.Servers 30namespace OpenSim.Framework.Servers
31{ 31{
32 public delegate LLSD LLSDMethod(LLSD request); 32 public delegate LLSD LLSDMethod( string path, LLSD request, string endpoint );
33 public delegate LLSD DefaultLLSDMethod(LLSD request);
33} 34}
diff --git a/OpenSim/Framework/Servers/LLSDMethodString.cs b/OpenSim/Framework/Servers/LLSDMethodString.cs
new file mode 100644
index 0000000..8d20b69
--- /dev/null
+++ b/OpenSim/Framework/Servers/LLSDMethodString.cs
@@ -0,0 +1,33 @@
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
28using libsecondlife.StructuredData;
29
30namespace OpenSim.Framework.Servers
31{
32 public delegate LLSD LLSDMethodString(LLSD request, string thePath);
33}