diff options
author | Melanie | 2013-05-07 00:52:40 +0100 |
---|---|---|
committer | Melanie | 2013-05-07 00:52:40 +0100 |
commit | 1c6b8293d7b9e312c5b1fb544a1de7fd3b145670 (patch) | |
tree | 8e156426d59ee29b50308f5ef3378d13063e2ed0 /OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs | |
parent | Step 2: commit the IEstateModuleInterface changes needed (diff) | |
download | opensim-SC_OLD-1c6b8293d7b9e312c5b1fb544a1de7fd3b145670.zip opensim-SC_OLD-1c6b8293d7b9e312c5b1fb544a1de7fd3b145670.tar.gz opensim-SC_OLD-1c6b8293d7b9e312c5b1fb544a1de7fd3b145670.tar.bz2 opensim-SC_OLD-1c6b8293d7b9e312c5b1fb544a1de7fd3b145670.tar.xz |
Step 3: Commit the Avination XEstate estate comms handler
This adds estate-wide Teleport Home and Teleport All User Home as well
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs | 215 |
1 files changed, 215 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs new file mode 100644 index 0000000..948c893 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Estate/XEstateConnector.cs | |||
@@ -0,0 +1,215 @@ | |||
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.Generic; | ||
30 | using System.Reflection; | ||
31 | |||
32 | using OpenSim.Services.Interfaces; | ||
33 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
34 | using OpenSim.Server.Base; | ||
35 | using OpenSim.Framework.Servers.HttpServer; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using log4net; | ||
41 | |||
42 | namespace OpenSim.Region.CoreModules.World.Estate | ||
43 | { | ||
44 | public class EstateConnector | ||
45 | { | ||
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
47 | |||
48 | protected XEstateModule m_EstateModule; | ||
49 | |||
50 | public EstateConnector(XEstateModule module) | ||
51 | { | ||
52 | m_EstateModule = module; | ||
53 | } | ||
54 | |||
55 | public void SendTeleportHomeOneUser(uint EstateID, UUID PreyID) | ||
56 | { | ||
57 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
58 | sendData["METHOD"] = "teleport_home_one_user"; | ||
59 | |||
60 | sendData["EstateID"] = EstateID.ToString(); | ||
61 | sendData["PreyID"] = PreyID.ToString(); | ||
62 | |||
63 | SendToEstate(EstateID, sendData); | ||
64 | } | ||
65 | |||
66 | public void SendTeleportHomeAllUsers(uint EstateID) | ||
67 | { | ||
68 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
69 | sendData["METHOD"] = "teleport_home_all_users"; | ||
70 | |||
71 | sendData["EstateID"] = EstateID.ToString(); | ||
72 | |||
73 | SendToEstate(EstateID, sendData); | ||
74 | } | ||
75 | |||
76 | public bool SendUpdateCovenant(uint EstateID, UUID CovenantID) | ||
77 | { | ||
78 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
79 | sendData["METHOD"] = "update_covenant"; | ||
80 | |||
81 | sendData["CovenantID"] = CovenantID.ToString(); | ||
82 | sendData["EstateID"] = EstateID.ToString(); | ||
83 | |||
84 | // Handle local regions locally | ||
85 | // | ||
86 | foreach (Scene s in m_EstateModule.Scenes) | ||
87 | { | ||
88 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
89 | s.RegionInfo.RegionSettings.Covenant = CovenantID; | ||
90 | // s.ReloadEstateData(); | ||
91 | } | ||
92 | |||
93 | SendToEstate(EstateID, sendData); | ||
94 | |||
95 | return true; | ||
96 | } | ||
97 | |||
98 | public bool SendUpdateEstate(uint EstateID) | ||
99 | { | ||
100 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
101 | sendData["METHOD"] = "update_estate"; | ||
102 | |||
103 | sendData["EstateID"] = EstateID.ToString(); | ||
104 | |||
105 | // Handle local regions locally | ||
106 | // | ||
107 | foreach (Scene s in m_EstateModule.Scenes) | ||
108 | { | ||
109 | if (s.RegionInfo.EstateSettings.EstateID == EstateID) | ||
110 | s.ReloadEstateData(); | ||
111 | } | ||
112 | |||
113 | SendToEstate(EstateID, sendData); | ||
114 | |||
115 | return true; | ||
116 | } | ||
117 | |||
118 | public void SendEstateMessage(uint EstateID, UUID FromID, string FromName, string Message) | ||
119 | { | ||
120 | Dictionary<string, object> sendData = new Dictionary<string, object>(); | ||
121 | sendData["METHOD"] = "estate_message"; | ||
122 | |||
123 | sendData["EstateID"] = EstateID.ToString(); | ||
124 | sendData["FromID"] = FromID.ToString(); | ||
125 | sendData["FromName"] = FromName; | ||
126 | sendData["Message"] = Message; | ||
127 | |||
128 | SendToEstate(EstateID, sendData); | ||
129 | } | ||
130 | |||
131 | private void SendToEstate(uint EstateID, Dictionary<string, object> sendData) | ||
132 | { | ||
133 | List<UUID> regions = m_EstateModule.Scenes[0].GetEstateRegions((int)EstateID); | ||
134 | |||
135 | UUID ScopeID = UUID.Zero; | ||
136 | |||
137 | // Handle local regions locally | ||
138 | // | ||
139 | foreach (Scene s in m_EstateModule.Scenes) | ||
140 | { | ||
141 | if (regions.Contains(s.RegionInfo.RegionID)) | ||
142 | { | ||
143 | // All regions in one estate are in the same scope. | ||
144 | // Use that scope. | ||
145 | // | ||
146 | ScopeID = s.RegionInfo.ScopeID; | ||
147 | regions.Remove(s.RegionInfo.RegionID); | ||
148 | } | ||
149 | } | ||
150 | |||
151 | // Our own region should always be in the above list. | ||
152 | // In a standalone this would not be true. But then, | ||
153 | // Scope ID is not relevat there. Use first scope. | ||
154 | // | ||
155 | if (ScopeID == UUID.Zero) | ||
156 | ScopeID = m_EstateModule.Scenes[0].RegionInfo.ScopeID; | ||
157 | |||
158 | // Don't send to the same instance twice | ||
159 | // | ||
160 | List<string> done = new List<string>(); | ||
161 | |||
162 | // Send to remote regions | ||
163 | // | ||
164 | foreach (UUID regionID in regions) | ||
165 | { | ||
166 | GridRegion region = m_EstateModule.Scenes[0].GridService.GetRegionByUUID(ScopeID, regionID); | ||
167 | if (region != null) | ||
168 | { | ||
169 | string url = "http://" + region.ExternalHostName + ":" + region.HttpPort; | ||
170 | if (done.Contains(url)) | ||
171 | continue; | ||
172 | |||
173 | Call(region, sendData); | ||
174 | done.Add(url); | ||
175 | } | ||
176 | } | ||
177 | } | ||
178 | |||
179 | private bool Call(GridRegion region, Dictionary<string, object> sendData) | ||
180 | { | ||
181 | string reqString = ServerUtils.BuildQueryString(sendData); | ||
182 | // m_log.DebugFormat("[XESTATE CONNECTOR]: queryString = {0}", reqString); | ||
183 | try | ||
184 | { | ||
185 | string url = "http://" + region.ExternalHostName + ":" + region.HttpPort; | ||
186 | string reply = SynchronousRestFormsRequester.MakeRequest("POST", | ||
187 | url + "/estate", | ||
188 | reqString); | ||
189 | if (reply != string.Empty) | ||
190 | { | ||
191 | Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); | ||
192 | |||
193 | if (replyData.ContainsKey("RESULT")) | ||
194 | { | ||
195 | if (replyData["RESULT"].ToString().ToLower() == "true") | ||
196 | return true; | ||
197 | else | ||
198 | return false; | ||
199 | } | ||
200 | else | ||
201 | m_log.DebugFormat("[XESTATE CONNECTOR]: reply data does not contain result field"); | ||
202 | |||
203 | } | ||
204 | else | ||
205 | m_log.DebugFormat("[XESTATE CONNECTOR]: received empty reply"); | ||
206 | } | ||
207 | catch (Exception e) | ||
208 | { | ||
209 | m_log.DebugFormat("[XESTATE CONNECTOR]: Exception when contacting remote sim: {0}", e.Message); | ||
210 | } | ||
211 | |||
212 | return false; | ||
213 | } | ||
214 | } | ||
215 | } | ||