Thank you kindly, BlueWall sir, for a patch that:

Adding a jsonp wrapper to the user supplied status report 
uri if the key "callback" exists. It will work with many 
javascript toolkits to provide an ajax callback to allow 
the browser to update stats reports without the 
intervention of an intermediate server.
0.6.5-rc1
Charles Krinke 2009-05-13 01:27:23 +00:00
parent 4db2f71c45
commit a5feb0682a
2 changed files with 14 additions and 4 deletions

View File

@ -488,9 +488,17 @@ namespace OpenSim.Framework.Servers
} }
public string StatReport(OSHttpRequest httpRequest) public string StatReport(OSHttpRequest httpRequest)
{
// If we catch a request for "callback", wrap the response in the value for jsonp
if( httpRequest.Query.ContainsKey("callback"))
{
return httpRequest.Query["callback"].ToString() + "(" + m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version ) + ");";
}
else
{ {
return m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version ); return m_stats.XReport((DateTime.Now - m_startuptime).ToString() , m_version );
} }
}
protected void RemovePIDFile() protected void RemovePIDFile()
{ {

View File

@ -861,8 +861,10 @@ namespace OpenSim
} }
/// <summary> /// <summary>
/// Handler to supply the current extended status of this sim /// Handler to supply the current extended status of this sim to a user configured URI
/// Sends the statistical data in a json serialization /// Sends the statistical data in a json serialization
/// If the request contains a key, "callback" the response will be wrappend in the
/// associated value for jsonp used with ajax/javascript
/// </summary> /// </summary>
public class UXSimStatusHandler : IStreamedRequestHandler public class UXSimStatusHandler : IStreamedRequestHandler
{ {
@ -894,7 +896,7 @@ namespace OpenSim
public string Path public string Path
{ {
// This is for the OpenSim instance and is the osSecret hashed // This is for the OpenSim instance and is the user provided URI
get { return "/" + osUXStatsURI + "/"; } get { return "/" + osUXStatsURI + "/"; }
} }
} }