diff options
author | Diva Canto | 2009-09-22 11:58:40 -0700 |
---|---|---|
committer | Diva Canto | 2009-09-22 11:58:40 -0700 |
commit | 34f4738159300ab6370e3db47df5187b6cea8771 (patch) | |
tree | b999ec7a07c4527bb38771ea6b02a8d77b5d0bdf /OpenSim/Services/Connectors/Grid | |
parent | Added Remote grid connector module. (diff) | |
download | opensim-SC_OLD-34f4738159300ab6370e3db47df5187b6cea8771.zip opensim-SC_OLD-34f4738159300ab6370e3db47df5187b6cea8771.tar.gz opensim-SC_OLD-34f4738159300ab6370e3db47df5187b6cea8771.tar.bz2 opensim-SC_OLD-34f4738159300ab6370e3db47df5187b6cea8771.tar.xz |
Added HGGridConnector and related code.
Diffstat (limited to 'OpenSim/Services/Connectors/Grid')
-rw-r--r-- | OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs new file mode 100644 index 0000000..f68c10a --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | |||
@@ -0,0 +1,155 @@ | |||
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 OpenSimulator 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using System.Drawing; | ||
33 | using System.Net; | ||
34 | using System.Reflection; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | |||
37 | using OpenSim.Framework; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.Imaging; | ||
41 | using log4net; | ||
42 | using Nwc.XmlRpc; | ||
43 | |||
44 | namespace OpenSim.Services.Connectors.Grid | ||
45 | { | ||
46 | public class HypergridServiceConnector | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private IAssetService m_AssetService; | ||
51 | |||
52 | public HypergridServiceConnector(IAssetService assService) | ||
53 | { | ||
54 | m_AssetService = assService; | ||
55 | } | ||
56 | |||
57 | public UUID LinkRegion(SimpleRegionInfo info) | ||
58 | { | ||
59 | UUID uuid = UUID.Zero; | ||
60 | |||
61 | //Hashtable hash = new Hashtable(); | ||
62 | //hash["region_name"] = info.RegionName; | ||
63 | |||
64 | //IList paramList = new ArrayList(); | ||
65 | //paramList.Add(hash); | ||
66 | |||
67 | //XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); | ||
68 | //string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | ||
69 | //m_log.Debug("[HGrid]: Linking to " + uri); | ||
70 | //XmlRpcResponse response = request.Send(uri, 10000); | ||
71 | //if (response.IsFault) | ||
72 | //{ | ||
73 | // m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
74 | //} | ||
75 | //else | ||
76 | //{ | ||
77 | // hash = (Hashtable)response.Value; | ||
78 | // //foreach (Object o in hash) | ||
79 | // // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
80 | // try | ||
81 | // { | ||
82 | // UUID.TryParse((string)hash["uuid"], out uuid); | ||
83 | // info.RegionID = uuid; | ||
84 | // if ((string)hash["handle"] != null) | ||
85 | // { | ||
86 | // info.regionSecret = (string)hash["handle"]; | ||
87 | // //m_log.Debug(">> HERE: " + info.regionSecret); | ||
88 | // } | ||
89 | // if (hash["region_image"] != null) | ||
90 | // { | ||
91 | // UUID img = UUID.Zero; | ||
92 | // UUID.TryParse((string)hash["region_image"], out img); | ||
93 | // info.RegionSettings.TerrainImageID = img; | ||
94 | // } | ||
95 | // if (hash["region_name"] != null) | ||
96 | // { | ||
97 | // info.RegionName = (string)hash["region_name"]; | ||
98 | // //m_log.Debug(">> " + info.RegionName); | ||
99 | // } | ||
100 | // if (hash["internal_port"] != null) | ||
101 | // { | ||
102 | // int port = Convert.ToInt32((string)hash["internal_port"]); | ||
103 | // info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); | ||
104 | // //m_log.Debug(">> " + info.InternalEndPoint.ToString()); | ||
105 | // } | ||
106 | // if (hash["remoting_port"] != null) | ||
107 | // { | ||
108 | // info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]); | ||
109 | // //m_log.Debug(">> " + info.RemotingPort); | ||
110 | // } | ||
111 | |||
112 | // } | ||
113 | // catch (Exception e) | ||
114 | // { | ||
115 | // m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
116 | // } | ||
117 | //} | ||
118 | return uuid; | ||
119 | } | ||
120 | |||
121 | public void GetMapImage(SimpleRegionInfo info) | ||
122 | { | ||
123 | try | ||
124 | { | ||
125 | string regionimage = "regionImage" + info.RegionID.ToString(); | ||
126 | regionimage = regionimage.Replace("-", ""); | ||
127 | |||
128 | WebClient c = new WebClient(); | ||
129 | string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; | ||
130 | //m_log.Debug("JPEG: " + uri); | ||
131 | c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); | ||
132 | Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); | ||
133 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
134 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | ||
135 | AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); | ||
136 | |||
137 | // !!! for now | ||
138 | //info.RegionSettings.TerrainImageID = ass.FullID; | ||
139 | |||
140 | ass.Type = (int)AssetType.Texture; | ||
141 | ass.Temporary = true; | ||
142 | ass.Local = true; | ||
143 | ass.Data = imageData; | ||
144 | |||
145 | m_AssetService.Store(ass); | ||
146 | |||
147 | } | ||
148 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
149 | { | ||
150 | m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | } | ||
155 | } | ||