Update svn properties.
parent
07d680a010
commit
6ae88d129a
|
@ -1,378 +1,378 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using Nwc.XmlRpc;
|
using Nwc.XmlRpc;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Communications.Clients
|
namespace OpenSim.Framework.Communications.Clients
|
||||||
{
|
{
|
||||||
public class GridClient
|
public class GridClient
|
||||||
{
|
{
|
||||||
|
|
||||||
public bool RegisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines)
|
public bool RegisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out bool forcefulBanLines)
|
||||||
{
|
{
|
||||||
forcefulBanLines = true;
|
forcefulBanLines = true;
|
||||||
|
|
||||||
Hashtable GridParams = new Hashtable();
|
Hashtable GridParams = new Hashtable();
|
||||||
// Login / Authentication
|
// Login / Authentication
|
||||||
|
|
||||||
GridParams["authkey"] = sendKey;
|
GridParams["authkey"] = sendKey;
|
||||||
GridParams["recvkey"] = receiveKey;
|
GridParams["recvkey"] = receiveKey;
|
||||||
GridParams["UUID"] = regionInfo.RegionID.ToString();
|
GridParams["UUID"] = regionInfo.RegionID.ToString();
|
||||||
GridParams["sim_ip"] = regionInfo.ExternalHostName;
|
GridParams["sim_ip"] = regionInfo.ExternalHostName;
|
||||||
GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString();
|
GridParams["sim_port"] = regionInfo.InternalEndPoint.Port.ToString();
|
||||||
GridParams["region_locx"] = regionInfo.RegionLocX.ToString();
|
GridParams["region_locx"] = regionInfo.RegionLocX.ToString();
|
||||||
GridParams["region_locy"] = regionInfo.RegionLocY.ToString();
|
GridParams["region_locy"] = regionInfo.RegionLocY.ToString();
|
||||||
GridParams["sim_name"] = regionInfo.RegionName;
|
GridParams["sim_name"] = regionInfo.RegionName;
|
||||||
GridParams["http_port"] = regionInfo.HttpPort.ToString();
|
GridParams["http_port"] = regionInfo.HttpPort.ToString();
|
||||||
GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString();
|
GridParams["remoting_port"] = ConfigSettings.DefaultRegionRemotingPort.ToString();
|
||||||
GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString();
|
GridParams["map-image-id"] = regionInfo.RegionSettings.TerrainImageID.ToString();
|
||||||
GridParams["originUUID"] = regionInfo.originRegionID.ToString();
|
GridParams["originUUID"] = regionInfo.originRegionID.ToString();
|
||||||
GridParams["server_uri"] = regionInfo.ServerURI;
|
GridParams["server_uri"] = regionInfo.ServerURI;
|
||||||
GridParams["region_secret"] = regionInfo.regionSecret;
|
GridParams["region_secret"] = regionInfo.regionSecret;
|
||||||
GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString();
|
GridParams["major_interface_version"] = VersionInfo.MajorInterfaceVersion.ToString();
|
||||||
|
|
||||||
if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero)
|
if (regionInfo.MasterAvatarAssignedUUID != UUID.Zero)
|
||||||
GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString();
|
GridParams["master_avatar_uuid"] = regionInfo.MasterAvatarAssignedUUID.ToString();
|
||||||
else
|
else
|
||||||
GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString();
|
GridParams["master_avatar_uuid"] = regionInfo.EstateSettings.EstateOwner.ToString();
|
||||||
|
|
||||||
// Package into an XMLRPC Request
|
// Package into an XMLRPC Request
|
||||||
ArrayList SendParams = new ArrayList();
|
ArrayList SendParams = new ArrayList();
|
||||||
SendParams.Add(GridParams);
|
SendParams.Add(GridParams);
|
||||||
|
|
||||||
// Send Request
|
// Send Request
|
||||||
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
|
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_login", SendParams);
|
||||||
XmlRpcResponse GridResp;
|
XmlRpcResponse GridResp;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// The timeout should always be significantly larger than the timeout for the grid server to request
|
// The timeout should always be significantly larger than the timeout for the grid server to request
|
||||||
// the initial status of the region before confirming registration.
|
// the initial status of the region before confirming registration.
|
||||||
GridResp = GridReq.Send(gridServerURL, 90000);
|
GridResp = GridReq.Send(gridServerURL, 90000);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Exception e2
|
Exception e2
|
||||||
= new Exception(
|
= new Exception(
|
||||||
String.Format(
|
String.Format(
|
||||||
"Unable to register region with grid at {0}. Grid service not running?",
|
"Unable to register region with grid at {0}. Grid service not running?",
|
||||||
gridServerURL),
|
gridServerURL),
|
||||||
e);
|
e);
|
||||||
|
|
||||||
throw e2;
|
throw e2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable GridRespData = (Hashtable)GridResp.Value;
|
Hashtable GridRespData = (Hashtable)GridResp.Value;
|
||||||
// Hashtable griddatahash = GridRespData;
|
// Hashtable griddatahash = GridRespData;
|
||||||
|
|
||||||
// Process Response
|
// Process Response
|
||||||
if (GridRespData.ContainsKey("error"))
|
if (GridRespData.ContainsKey("error"))
|
||||||
{
|
{
|
||||||
string errorstring = (string)GridRespData["error"];
|
string errorstring = (string)GridRespData["error"];
|
||||||
|
|
||||||
Exception e = new Exception(
|
Exception e = new Exception(
|
||||||
String.Format("Unable to connect to grid at {0}: {1}", gridServerURL, errorstring));
|
String.Format("Unable to connect to grid at {0}: {1}", gridServerURL, errorstring));
|
||||||
|
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY);
|
// m_knownRegions = RequestNeighbours(regionInfo.RegionLocX, regionInfo.RegionLocY);
|
||||||
if (GridRespData.ContainsKey("allow_forceful_banlines"))
|
if (GridRespData.ContainsKey("allow_forceful_banlines"))
|
||||||
{
|
{
|
||||||
if ((string)GridRespData["allow_forceful_banlines"] != "TRUE")
|
if ((string)GridRespData["allow_forceful_banlines"] != "TRUE")
|
||||||
{
|
{
|
||||||
forcefulBanLines = false;
|
forcefulBanLines = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DeregisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out string errorMsg)
|
public bool DeregisterRegion(string gridServerURL, string sendKey, string receiveKey, RegionInfo regionInfo, out string errorMsg)
|
||||||
{
|
{
|
||||||
errorMsg = "";
|
errorMsg = "";
|
||||||
Hashtable GridParams = new Hashtable();
|
Hashtable GridParams = new Hashtable();
|
||||||
|
|
||||||
GridParams["UUID"] = regionInfo.RegionID.ToString();
|
GridParams["UUID"] = regionInfo.RegionID.ToString();
|
||||||
|
|
||||||
// Package into an XMLRPC Request
|
// Package into an XMLRPC Request
|
||||||
ArrayList SendParams = new ArrayList();
|
ArrayList SendParams = new ArrayList();
|
||||||
SendParams.Add(GridParams);
|
SendParams.Add(GridParams);
|
||||||
|
|
||||||
// Send Request
|
// Send Request
|
||||||
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams);
|
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_after_region_moved", SendParams);
|
||||||
XmlRpcResponse GridResp = null;
|
XmlRpcResponse GridResp = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GridResp = GridReq.Send(gridServerURL, 10000);
|
GridResp = GridReq.Send(gridServerURL, 10000);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Exception e2
|
Exception e2
|
||||||
= new Exception(
|
= new Exception(
|
||||||
String.Format(
|
String.Format(
|
||||||
"Unable to deregister region with grid at {0}. Grid service not running?",
|
"Unable to deregister region with grid at {0}. Grid service not running?",
|
||||||
gridServerURL),
|
gridServerURL),
|
||||||
e);
|
e);
|
||||||
|
|
||||||
throw e2;
|
throw e2;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable GridRespData = (Hashtable)GridResp.Value;
|
Hashtable GridRespData = (Hashtable)GridResp.Value;
|
||||||
|
|
||||||
// Hashtable griddatahash = GridRespData;
|
// Hashtable griddatahash = GridRespData;
|
||||||
|
|
||||||
// Process Response
|
// Process Response
|
||||||
if (GridRespData != null && GridRespData.ContainsKey("error"))
|
if (GridRespData != null && GridRespData.ContainsKey("error"))
|
||||||
{
|
{
|
||||||
errorMsg = (string)GridRespData["error"];
|
errorMsg = (string)GridRespData["error"];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, UUID regionUUID, out RegionInfo regionInfo, out string errorMsg)
|
public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, UUID regionUUID, out RegionInfo regionInfo, out string errorMsg)
|
||||||
{
|
{
|
||||||
// didn't find it so far, we have to go the long way
|
// didn't find it so far, we have to go the long way
|
||||||
regionInfo = null;
|
regionInfo = null;
|
||||||
errorMsg = string.Empty;
|
errorMsg = string.Empty;
|
||||||
Hashtable requestData = new Hashtable();
|
Hashtable requestData = new Hashtable();
|
||||||
requestData["region_UUID"] = regionUUID.ToString();
|
requestData["region_UUID"] = regionUUID.ToString();
|
||||||
requestData["authkey"] = sendKey;
|
requestData["authkey"] = sendKey;
|
||||||
ArrayList SendParams = new ArrayList();
|
ArrayList SendParams = new ArrayList();
|
||||||
SendParams.Add(requestData);
|
SendParams.Add(requestData);
|
||||||
XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams);
|
XmlRpcRequest gridReq = new XmlRpcRequest("simulator_data_request", SendParams);
|
||||||
XmlRpcResponse gridResp = null;
|
XmlRpcResponse gridResp = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
gridResp = gridReq.Send(gridServerURL, 3000);
|
gridResp = gridReq.Send(gridServerURL, 3000);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
errorMsg = e.Message;
|
errorMsg = e.Message;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Hashtable responseData = (Hashtable)gridResp.Value;
|
Hashtable responseData = (Hashtable)gridResp.Value;
|
||||||
|
|
||||||
if (responseData.ContainsKey("error"))
|
if (responseData.ContainsKey("error"))
|
||||||
{
|
{
|
||||||
errorMsg = (string)responseData["error"];
|
errorMsg = (string)responseData["error"];
|
||||||
return false; ;
|
return false; ;
|
||||||
}
|
}
|
||||||
|
|
||||||
regionInfo = BuildRegionInfo(responseData, String.Empty);
|
regionInfo = BuildRegionInfo(responseData, String.Empty);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, ulong regionHandle, out RegionInfo regionInfo, out string errorMsg)
|
public bool RequestNeighborInfo(string gridServerURL, string sendKey, string receiveKey, ulong regionHandle, out RegionInfo regionInfo, out string errorMsg)
|
||||||
{
|
{
|
||||||
// didn't find it so far, we have to go the long way
|
// didn't find it so far, we have to go the long way
|
||||||
regionInfo = null;
|
regionInfo = null;
|
||||||
errorMsg = string.Empty;
|
errorMsg = string.Empty;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Hashtable requestData = new Hashtable();
|
Hashtable requestData = new Hashtable();
|
||||||
requestData["region_handle"] = regionHandle.ToString();
|
requestData["region_handle"] = regionHandle.ToString();
|
||||||
requestData["authkey"] = sendKey;
|
requestData["authkey"] = sendKey;
|
||||||
ArrayList SendParams = new ArrayList();
|
ArrayList SendParams = new ArrayList();
|
||||||
SendParams.Add(requestData);
|
SendParams.Add(requestData);
|
||||||
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
|
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
|
||||||
XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000);
|
XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000);
|
||||||
|
|
||||||
Hashtable responseData = (Hashtable)GridResp.Value;
|
Hashtable responseData = (Hashtable)GridResp.Value;
|
||||||
|
|
||||||
if (responseData.ContainsKey("error"))
|
if (responseData.ContainsKey("error"))
|
||||||
{
|
{
|
||||||
errorMsg = (string)responseData["error"];
|
errorMsg = (string)responseData["error"];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint regX = Convert.ToUInt32((string)responseData["region_locx"]);
|
uint regX = Convert.ToUInt32((string)responseData["region_locx"]);
|
||||||
uint regY = Convert.ToUInt32((string)responseData["region_locy"]);
|
uint regY = Convert.ToUInt32((string)responseData["region_locy"]);
|
||||||
string externalHostName = (string)responseData["sim_ip"];
|
string externalHostName = (string)responseData["sim_ip"];
|
||||||
uint simPort = Convert.ToUInt32(responseData["sim_port"]);
|
uint simPort = Convert.ToUInt32(responseData["sim_port"]);
|
||||||
string regionName = (string)responseData["region_name"];
|
string regionName = (string)responseData["region_name"];
|
||||||
UUID regionID = new UUID((string)responseData["region_UUID"]);
|
UUID regionID = new UUID((string)responseData["region_UUID"]);
|
||||||
uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
|
uint remotingPort = Convert.ToUInt32((string)responseData["remoting_port"]);
|
||||||
|
|
||||||
uint httpPort = 9000;
|
uint httpPort = 9000;
|
||||||
if (responseData.ContainsKey("http_port"))
|
if (responseData.ContainsKey("http_port"))
|
||||||
{
|
{
|
||||||
httpPort = Convert.ToUInt32((string)responseData["http_port"]);
|
httpPort = Convert.ToUInt32((string)responseData["http_port"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info?
|
// Ok, so this is definitively the wrong place to do this, way too hard coded, but it doesn't seem we GET this info?
|
||||||
|
|
||||||
string simURI = "http://" + externalHostName + ":" + simPort;
|
string simURI = "http://" + externalHostName + ":" + simPort;
|
||||||
|
|
||||||
// string externalUri = (string) responseData["sim_uri"];
|
// string externalUri = (string) responseData["sim_uri"];
|
||||||
|
|
||||||
//IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
|
//IPEndPoint neighbourInternalEndPoint = new IPEndPoint(IPAddress.Parse(internalIpStr), (int) port);
|
||||||
regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI);
|
regionInfo = RegionInfo.Create(regionID, regionName, regX, regY, externalHostName, httpPort, simPort, remotingPort, simURI);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
errorMsg = e.Message;
|
errorMsg = e.Message;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RequestClosestRegion(string gridServerURL, string sendKey, string receiveKey, string regionName, out RegionInfo regionInfo, out string errorMsg)
|
public bool RequestClosestRegion(string gridServerURL, string sendKey, string receiveKey, string regionName, out RegionInfo regionInfo, out string errorMsg)
|
||||||
{
|
{
|
||||||
regionInfo = null;
|
regionInfo = null;
|
||||||
errorMsg = string.Empty;
|
errorMsg = string.Empty;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Hashtable requestData = new Hashtable();
|
Hashtable requestData = new Hashtable();
|
||||||
requestData["region_name_search"] = regionName;
|
requestData["region_name_search"] = regionName;
|
||||||
requestData["authkey"] = sendKey;
|
requestData["authkey"] = sendKey;
|
||||||
ArrayList SendParams = new ArrayList();
|
ArrayList SendParams = new ArrayList();
|
||||||
SendParams.Add(requestData);
|
SendParams.Add(requestData);
|
||||||
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
|
XmlRpcRequest GridReq = new XmlRpcRequest("simulator_data_request", SendParams);
|
||||||
XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000);
|
XmlRpcResponse GridResp = GridReq.Send(gridServerURL, 3000);
|
||||||
|
|
||||||
Hashtable responseData = (Hashtable)GridResp.Value;
|
Hashtable responseData = (Hashtable)GridResp.Value;
|
||||||
|
|
||||||
if (responseData.ContainsKey("error"))
|
if (responseData.ContainsKey("error"))
|
||||||
{
|
{
|
||||||
errorMsg = (string)responseData["error"];
|
errorMsg = (string)responseData["error"];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
regionInfo = BuildRegionInfo(responseData, "");
|
regionInfo = BuildRegionInfo(responseData, "");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
errorMsg = e.Message;
|
errorMsg = e.Message;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
|
/// Performs a XML-RPC query against the grid server returning mapblock information in the specified coordinates
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
|
/// <remarks>REDUNDANT - OGS1 is to be phased out in favour of OGS2</remarks>
|
||||||
/// <param name="minX">Minimum X value</param>
|
/// <param name="minX">Minimum X value</param>
|
||||||
/// <param name="minY">Minimum Y value</param>
|
/// <param name="minY">Minimum Y value</param>
|
||||||
/// <param name="maxX">Maximum X value</param>
|
/// <param name="maxX">Maximum X value</param>
|
||||||
/// <param name="maxY">Maximum Y value</param>
|
/// <param name="maxY">Maximum Y value</param>
|
||||||
/// <returns>Hashtable of hashtables containing map data elements</returns>
|
/// <returns>Hashtable of hashtables containing map data elements</returns>
|
||||||
public bool MapBlockQuery(string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg)
|
public bool MapBlockQuery(string gridServerURL, int minX, int minY, int maxX, int maxY, out Hashtable respData, out string errorMsg)
|
||||||
{
|
{
|
||||||
respData = new Hashtable();
|
respData = new Hashtable();
|
||||||
errorMsg = string.Empty;
|
errorMsg = string.Empty;
|
||||||
|
|
||||||
Hashtable param = new Hashtable();
|
Hashtable param = new Hashtable();
|
||||||
param["xmin"] = minX;
|
param["xmin"] = minX;
|
||||||
param["ymin"] = minY;
|
param["ymin"] = minY;
|
||||||
param["xmax"] = maxX;
|
param["xmax"] = maxX;
|
||||||
param["ymax"] = maxY;
|
param["ymax"] = maxY;
|
||||||
IList parameters = new ArrayList();
|
IList parameters = new ArrayList();
|
||||||
parameters.Add(param);
|
parameters.Add(param);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
|
XmlRpcRequest req = new XmlRpcRequest("map_block", parameters);
|
||||||
XmlRpcResponse resp = req.Send(gridServerURL, 10000);
|
XmlRpcResponse resp = req.Send(gridServerURL, 10000);
|
||||||
respData = (Hashtable)resp.Value;
|
respData = (Hashtable)resp.Value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
errorMsg = e.Message;
|
errorMsg = e.Message;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SearchRegionByName(string gridServerURL, IList parameters, out Hashtable respData, out string errorMsg)
|
public bool SearchRegionByName(string gridServerURL, IList parameters, out Hashtable respData, out string errorMsg)
|
||||||
{
|
{
|
||||||
respData = null;
|
respData = null;
|
||||||
errorMsg = string.Empty;
|
errorMsg = string.Empty;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters);
|
XmlRpcRequest request = new XmlRpcRequest("search_for_region_by_name", parameters);
|
||||||
XmlRpcResponse resp = request.Send(gridServerURL, 10000);
|
XmlRpcResponse resp = request.Send(gridServerURL, 10000);
|
||||||
respData = (Hashtable)resp.Value;
|
respData = (Hashtable)resp.Value;
|
||||||
if (respData != null && respData.Contains("faultCode"))
|
if (respData != null && respData.Contains("faultCode"))
|
||||||
{
|
{
|
||||||
errorMsg = (string)respData["faultString"];
|
errorMsg = (string)respData["faultString"];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
errorMsg = e.Message;
|
errorMsg = e.Message;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public RegionInfo BuildRegionInfo(Hashtable responseData, string prefix)
|
public RegionInfo BuildRegionInfo(Hashtable responseData, string prefix)
|
||||||
{
|
{
|
||||||
uint regX = Convert.ToUInt32((string)responseData[prefix + "region_locx"]);
|
uint regX = Convert.ToUInt32((string)responseData[prefix + "region_locx"]);
|
||||||
uint regY = Convert.ToUInt32((string)responseData[prefix + "region_locy"]);
|
uint regY = Convert.ToUInt32((string)responseData[prefix + "region_locy"]);
|
||||||
string internalIpStr = (string)responseData[prefix + "sim_ip"];
|
string internalIpStr = (string)responseData[prefix + "sim_ip"];
|
||||||
uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]);
|
uint port = Convert.ToUInt32(responseData[prefix + "sim_port"]);
|
||||||
|
|
||||||
IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int)port);
|
IPEndPoint neighbourInternalEndPoint = new IPEndPoint(Util.GetHostFromDNS(internalIpStr), (int)port);
|
||||||
|
|
||||||
RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
|
RegionInfo regionInfo = new RegionInfo(regX, regY, neighbourInternalEndPoint, internalIpStr);
|
||||||
regionInfo.RemotingPort = Convert.ToUInt32((string)responseData[prefix + "remoting_port"]);
|
regionInfo.RemotingPort = Convert.ToUInt32((string)responseData[prefix + "remoting_port"]);
|
||||||
regionInfo.RemotingAddress = internalIpStr;
|
regionInfo.RemotingAddress = internalIpStr;
|
||||||
|
|
||||||
if (responseData.ContainsKey(prefix + "http_port"))
|
if (responseData.ContainsKey(prefix + "http_port"))
|
||||||
{
|
{
|
||||||
regionInfo.HttpPort = Convert.ToUInt32((string)responseData[prefix + "http_port"]);
|
regionInfo.HttpPort = Convert.ToUInt32((string)responseData[prefix + "http_port"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
regionInfo.RegionID = new UUID((string)responseData[prefix + "region_UUID"]);
|
regionInfo.RegionID = new UUID((string)responseData[prefix + "region_UUID"]);
|
||||||
regionInfo.RegionName = (string)responseData[prefix + "region_name"];
|
regionInfo.RegionName = (string)responseData[prefix + "region_name"];
|
||||||
|
|
||||||
regionInfo.RegionSettings.TerrainImageID = new UUID((string)responseData[prefix + "map_UUID"]);
|
regionInfo.RegionSettings.TerrainImageID = new UUID((string)responseData[prefix + "map_UUID"]);
|
||||||
return regionInfo;
|
return regionInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,113 +1,113 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
* Copyright (c) Contributors, http://opensimulator.org/
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* * Redistributions of source code must retain the above copyright
|
* * Redistributions of source code must retain the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
* documentation and/or other materials provided with the distribution.
|
* documentation and/or other materials provided with the distribution.
|
||||||
* * Neither the name of the OpenSim Project nor the
|
* * Neither the name of the OpenSim Project nor the
|
||||||
* names of its contributors may be used to endorse or promote products
|
* names of its contributors may be used to endorse or promote products
|
||||||
* derived from this software without specific prior written permission.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* 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
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using log4net;
|
using log4net;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.StructuredData;
|
using OpenMetaverse.StructuredData;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications;
|
using OpenSim.Framework.Communications;
|
||||||
using OpenSim.Framework.Communications.Services;
|
using OpenSim.Framework.Communications.Services;
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
using OpenSim.Framework.Servers;
|
using OpenSim.Framework.Servers;
|
||||||
using OpenSim.Framework.Servers.HttpServer;
|
using OpenSim.Framework.Servers.HttpServer;
|
||||||
using OpenSim.Framework.Statistics;
|
using OpenSim.Framework.Statistics;
|
||||||
using OpenSim.Region.Framework;
|
using OpenSim.Region.Framework;
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace OpenSim.Region.Framework.Scenes
|
namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public class RegionStatsHandler : IStreamedRequestHandler
|
public class RegionStatsHandler : IStreamedRequestHandler
|
||||||
{
|
{
|
||||||
private string osRXStatsURI = String.Empty;
|
private string osRXStatsURI = String.Empty;
|
||||||
private string osXStatsURI = String.Empty;
|
private string osXStatsURI = String.Empty;
|
||||||
//private string osSecret = String.Empty;
|
//private string osSecret = String.Empty;
|
||||||
private OpenSim.Framework.RegionInfo regionInfo;
|
private OpenSim.Framework.RegionInfo regionInfo;
|
||||||
public string localZone = TimeZone.CurrentTimeZone.StandardName;
|
public string localZone = TimeZone.CurrentTimeZone.StandardName;
|
||||||
public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
|
public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
|
||||||
|
|
||||||
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
public RegionStatsHandler(OpenSim.Framework.RegionInfo region_info )
|
public RegionStatsHandler(OpenSim.Framework.RegionInfo region_info )
|
||||||
{
|
{
|
||||||
regionInfo = region_info;
|
regionInfo = region_info;
|
||||||
osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret);
|
osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret);
|
||||||
osXStatsURI = Util.SHA1Hash(regionInfo.osSecret);
|
osXStatsURI = Util.SHA1Hash(regionInfo.osSecret);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
public byte[] Handle(string path, Stream request, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
|
||||||
{
|
{
|
||||||
return Encoding.UTF8.GetBytes(Report());
|
return Encoding.UTF8.GetBytes(Report());
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ContentType
|
public string ContentType
|
||||||
{
|
{
|
||||||
get { return "text/plain"; }
|
get { return "text/plain"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string HttpMethod
|
public string HttpMethod
|
||||||
{
|
{
|
||||||
get { return "GET"; }
|
get { return "GET"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Path
|
public string Path
|
||||||
{
|
{
|
||||||
// This is for the region and is the regionSecret hashed
|
// This is for the region and is the regionSecret hashed
|
||||||
get { return "/" + osRXStatsURI + "/"; }
|
get { return "/" + osRXStatsURI + "/"; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private string Report()
|
private string Report()
|
||||||
{
|
{
|
||||||
OSDMap args = new OSDMap(30);
|
OSDMap args = new OSDMap(30);
|
||||||
//int time = Util.ToUnixTime( DateTime.Now );
|
//int time = Util.ToUnixTime( DateTime.Now );
|
||||||
args["OSStatsURI"] = OSD.FromString("http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "/" + osXStatsURI + "/");
|
args["OSStatsURI"] = OSD.FromString("http://" + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "/" + osXStatsURI + "/");
|
||||||
args["TimeZoneName"] = OSD.FromString(localZone);
|
args["TimeZoneName"] = OSD.FromString(localZone);
|
||||||
args["TimeZoneOffs"] = OSD.FromReal(utcOffset.TotalHours);
|
args["TimeZoneOffs"] = OSD.FromReal(utcOffset.TotalHours);
|
||||||
args["UxTime"] = OSD.FromInteger(Util.ToUnixTime(DateTime.Now));
|
args["UxTime"] = OSD.FromInteger(Util.ToUnixTime(DateTime.Now));
|
||||||
args["Memory"] = OSD.FromReal(Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
|
args["Memory"] = OSD.FromReal(Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0));
|
||||||
args["Version"] = OSD.FromString(VersionInfo.Version);
|
args["Version"] = OSD.FromString(VersionInfo.Version);
|
||||||
|
|
||||||
string strBuffer = "";
|
string strBuffer = "";
|
||||||
strBuffer = OSDParser.SerializeJsonString(args);
|
strBuffer = OSDParser.SerializeJsonString(args);
|
||||||
|
|
||||||
return strBuffer;
|
return strBuffer;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue