aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Hypergrid
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Hypergrid')
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs265
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs174
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs77
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs391
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs56
5 files changed, 0 insertions, 963 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
deleted file mode 100644
index ec50598..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ /dev/null
@@ -1,265 +0,0 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Services.Interfaces;
40
41//using HyperGrid.Framework;
42//using OpenSim.Region.Communications.Hypergrid;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGAssetMapper
47 {
48 #region Fields
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 // This maps between inventory server urls and inventory server clients
52// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
53
54 private Scene m_scene;
55
56 private IHyperAssetService m_hyper;
57 IHyperAssetService HyperlinkAssets
58 {
59 get
60 {
61 if (m_hyper == null)
62 m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
63 return m_hyper;
64 }
65 }
66
67 #endregion
68
69 #region Constructor
70
71 public HGAssetMapper(Scene scene)
72 {
73 m_scene = scene;
74 }
75
76 #endregion
77
78 #region Internal functions
79
80// private string UserAssetURL(UUID userID)
81// {
82// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
83// if (uinfo != null)
84// return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI;
85// return null;
86// }
87
88// private string UserInventoryURL(UUID userID)
89// {
90// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
91// if (uinfo != null)
92// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
93// return null;
94// }
95
96
97 public AssetBase FetchAsset(string url, UUID assetID)
98 {
99 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
100
101 if (asset != null)
102 {
103 m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
104 return asset;
105 }
106 return null;
107 }
108
109 public bool PostAsset(string url, AssetBase asset)
110 {
111 if (asset != null)
112 {
113 // See long comment in AssetCache.AddAsset
114 if (!asset.Temporary || asset.Local)
115 {
116 // We need to copy the asset into a new asset, because
117 // we need to set its ID to be URL+UUID, so that the
118 // HGAssetService dispatches it to the remote grid.
119 // It's not pretty, but the best that can be done while
120 // not having a global naming infrastructure
121 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type);
122 Copy(asset, asset1);
123 try
124 {
125 asset1.ID = url + "/" + asset.ID;
126 }
127 catch
128 {
129 m_log.Warn("[HGScene]: Oops.");
130 }
131
132 m_scene.AssetService.Store(asset1);
133 m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
134 }
135 return true;
136 }
137 else
138 m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache.");
139
140 return false;
141 }
142
143 private void Copy(AssetBase from, AssetBase to)
144 {
145 to.Data = from.Data;
146 to.Description = from.Description;
147 to.FullID = from.FullID;
148 to.ID = from.ID;
149 to.Local = from.Local;
150 to.Name = from.Name;
151 to.Temporary = from.Temporary;
152 to.Type = from.Type;
153
154 }
155
156 // TODO: unused
157 // private void Dump(Dictionary<UUID, bool> lst)
158 // {
159 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
160 // foreach (KeyValuePair<UUID, bool> kvp in lst)
161 // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
162 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
163 // }
164
165 #endregion
166
167
168 #region Public interface
169
170 public void Get(UUID assetID, UUID ownerID)
171 {
172 // Get the item from the remote asset server onto the local AssetCache
173 // and place an entry in m_assetMap
174
175 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
176 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
177 {
178 m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL);
179 AssetBase asset = FetchAsset(userAssetURL, assetID);
180
181 if (asset != null)
182 {
183 // OK, now fetch the inside.
184 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
185 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
186 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
187 foreach (UUID uuid in ids.Keys)
188 FetchAsset(userAssetURL, uuid);
189
190 m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
191
192 }
193 else
194 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
195 }
196 else
197 m_log.Debug("[HGScene]: user's asset server is the local region's asset server");
198 }
199
200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
201 //{
202 // InventoryClient invCli = null;
203 // string inventoryURL = UserInventoryURL(item.Owner);
204 // if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
205 // {
206 // m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
207 // invCli = new InventoryClient(inventoryURL);
208 // m_inventoryServers.Add(inventoryURL, invCli);
209 // }
210
211 // item = invCli.GetInventoryItem(item);
212 // if (item != null)
213 // {
214 // // Change the folder, stick it in root folder, all items flattened out here in this region cache
215 // item.Folder = rootFolder;
216 // //userInfo.AddItem(item); don't use this, it calls back to the inventory server
217 // lock (userInfo.RootFolder.Items)
218 // {
219 // userInfo.RootFolder.Items[item.ID] = item;
220 // }
221
222 // }
223 // return item;
224 //}
225
226 public void Post(UUID assetID, UUID ownerID)
227 {
228 // Post the item from the local AssetCache onto the remote asset server
229 // and place an entry in m_assetMap
230
231 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
232 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
233 {
234 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
235 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
236 if (asset != null)
237 {
238 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
239 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
240 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
241 foreach (UUID uuid in ids.Keys)
242 {
243 asset = m_scene.AssetService.Get(uuid.ToString());
244 if (asset == null)
245 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
246 else
247 PostAsset(userAssetURL, asset);
248 }
249
250 // maybe all pieces got there...
251 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
252
253 }
254 else
255 m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID);
256 }
257 else
258 m_log.Debug("[HGScene]: user's asset server is local region's asset server");
259
260 }
261
262 #endregion
263
264 }
265}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
deleted file mode 100644
index 6f7f34f..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ /dev/null
@@ -1,174 +0,0 @@
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
28using System.Reflection;
29using log4net;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces;
36
37namespace OpenSim.Region.Framework.Scenes.Hypergrid
38{
39 public partial class HGScene : Scene
40 {
41 #region Fields
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 private HGAssetMapper m_assMapper;
45 public HGAssetMapper AssetMapper
46 {
47 get { return m_assMapper; }
48 }
49
50 private IHyperAssetService m_hyper;
51 private IHyperAssetService HyperAssets
52 {
53 get
54 {
55 if (m_hyper == null)
56 m_hyper = RequestModuleInterface<IHyperAssetService>();
57 return m_hyper;
58 }
59 }
60
61 #endregion
62
63 #region Constructors
64
65 public HGScene(RegionInfo regInfo, AgentCircuitManager authen,
66 CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
67 StorageManager storeManager,
68 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
69 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
70 : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader,
71 dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion)
72 {
73 m_log.Info("[HGScene]: Starting HGScene.");
74 m_assMapper = new HGAssetMapper(this);
75
76 EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
77 }
78
79 #endregion
80
81 #region Event handlers
82
83 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
84 {
85 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID);
86 if (userInfo != null)
87 {
88 m_assMapper.Post(assetID, avatarID);
89 }
90 }
91
92 #endregion
93
94 #region Overrides of Scene.Inventory methods
95
96 ///
97 /// CapsUpdateInventoryItemAsset
98 ///
99 public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
100 {
101 UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data);
102
103 UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0);
104
105 return newAssetID;
106 }
107
108 ///
109 /// DeleteToInventory
110 ///
111 public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient)
112 {
113 UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient);
114
115 if (!assetID.Equals(UUID.Zero))
116 {
117 UploadInventoryItem(remoteClient.AgentId, assetID, "", 0);
118 }
119 else
120 m_log.Debug("[HGScene]: Scene.Inventory did not create asset");
121
122 return assetID;
123 }
124
125 ///
126 /// RezObject
127 ///
128 public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
129 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
130 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
131 {
132 m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
133
134 //if (fromTaskID.Equals(UUID.Zero))
135 //{
136 InventoryItemBase item = new InventoryItemBase(itemID);
137 item.Owner = remoteClient.AgentId;
138 item = InventoryService.GetItem(item);
139 //if (item == null)
140 //{ // Fetch the item
141 // item = new InventoryItemBase();
142 // item.Owner = remoteClient.AgentId;
143 // item.ID = itemID;
144 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
145 //}
146 if (item != null)
147 {
148 m_assMapper.Get(item.AssetID, remoteClient.AgentId);
149
150 }
151 //}
152
153 // OK, we're done fetching. Pass it up to the default RezObject
154 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
155 RezSelected, RemoveItem, fromTaskID, attachment);
156
157 }
158
159 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
160 {
161 string userAssetServer = HyperAssets.GetUserAssetServer(sender);
162 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
163 m_assMapper.Get(item.AssetID, sender);
164
165 userAssetServer = HyperAssets.GetUserAssetServer(receiver);
166 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
167 m_assMapper.Post(item.AssetID, receiver);
168 }
169
170 #endregion
171
172 }
173
174}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
deleted file mode 100644
index b1981b6..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
+++ /dev/null
@@ -1,77 +0,0 @@
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
28using OpenMetaverse;
29using OpenSim.Framework;
30using OpenSim.Framework.Communications.Cache;
31using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
33
34namespace OpenSim.Region.Framework.Scenes.Hypergrid
35{
36 public partial class HGScene : Scene
37 {
38 /// <summary>
39 /// Teleport an avatar to their home region
40 /// </summary>
41 /// <param name="agentId"></param>
42 /// <param name="client"></param>
43 public override void TeleportClientHome(UUID agentId, IClientAPI client)
44 {
45 m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName);
46
47 CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId);
48 if (uinfo != null)
49 {
50 UserProfileData UserProfile = uinfo.UserProfile;
51
52 if (UserProfile != null)
53 {
54 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
55 //if (regionInfo != null)
56 //{
57 // UserProfile.HomeRegionID = regionInfo.RegionID;
58 // //CommsManager.UserService.UpdateUserProfile(UserProfile);
59 //}
60 if (regionInfo == null)
61 {
62 // can't find the Home region: Tell viewer and abort
63 client.SendTeleportFailed("Your home-region could not be found.");
64 return;
65 }
66 RequestTeleportLocation(
67 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
68 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
69 }
70 }
71 else
72 client.SendTeleportFailed("Sorry! I lost your home-region information.");
73
74 }
75
76 }
77}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
deleted file mode 100644
index 416826c..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ /dev/null
@@ -1,391 +0,0 @@
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
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Client;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGSceneCommunicationService : SceneCommunicationService
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private IHyperlinkService m_hg;
51 IHyperlinkService HyperlinkService
52 {
53 get
54 {
55 if (m_hg == null)
56 m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
57 return m_hg;
58 }
59 }
60
61 public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
62 {
63 }
64
65
66 /// <summary>
67 /// Try to teleport an agent to a new region.
68 /// </summary>
69 /// <param name="remoteClient"></param>
70 /// <param name="RegionHandle"></param>
71 /// <param name="position"></param>
72 /// <param name="lookAt"></param>
73 /// <param name="flags"></param>
74 public override void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
75 Vector3 lookAt, uint teleportFlags)
76 {
77 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
78 return;
79
80 bool destRegionUp = true;
81
82 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
83
84 // Reset animations; the viewer does that in teleports.
85 avatar.Animator.ResetAnimations();
86
87 if (regionHandle == m_regionInfo.RegionHandle)
88 {
89 // Teleport within the same region
90 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
91 {
92 Vector3 emergencyPos = new Vector3(128, 128, 128);
93
94 m_log.WarnFormat(
95 "[HGSceneCommService]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
96 position, avatar.Name, avatar.UUID, emergencyPos);
97 position = emergencyPos;
98 }
99 // TODO: Get proper AVG Height
100 float localAVHeight = 1.56f;
101
102 float posZLimit = 22;
103
104 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
105 {
106 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
107 }
108
109 float newPosZ = posZLimit + localAVHeight;
110 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
111 {
112 position.Z = newPosZ;
113 }
114
115 // Only send this if the event queue is null
116 if (eq == null)
117 avatar.ControllingClient.SendTeleportLocationStart();
118
119
120 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
121 avatar.Teleport(position);
122 }
123 else
124 {
125 uint x = 0, y = 0;
126 Utils.LongToUInts(regionHandle, out x, out y);
127 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
128
129 if (reg != null)
130 {
131
132 uint newRegionX = (uint)(reg.RegionHandle >> 40);
133 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
134 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
135 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
136
137 ///
138 /// Hypergrid mod start
139 ///
140 ///
141 bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
142 bool isHomeUser = true;
143 ulong realHandle = regionHandle;
144 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
145 if (uinfo != null)
146 {
147 isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
148 realHandle = m_hg.FindRegionHandle(regionHandle);
149 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
150 }
151 ///
152 /// Hypergrid mod stop
153 ///
154 ///
155
156 if (eq == null)
157 avatar.ControllingClient.SendTeleportLocationStart();
158
159
160 // Let's do DNS resolution only once in this process, please!
161 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
162 // it's actually doing a lot of work.
163 IPEndPoint endPoint = reg.ExternalEndPoint;
164 if (endPoint.Address == null)
165 {
166 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
167 destRegionUp = false;
168 }
169
170 if (destRegionUp)
171 {
172 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
173 // both regions
174 if (avatar.ParentID != (uint)0)
175 avatar.StandUp();
176
177 if (!avatar.ValidateAttachments())
178 {
179 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
180 return;
181 }
182
183 // the avatar.Close below will clear the child region list. We need this below for (possibly)
184 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
185 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
186 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
187 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
188 // once we reach here...
189 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
190
191 string capsPath = String.Empty;
192 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
193 agentCircuit.BaseFolder = UUID.Zero;
194 agentCircuit.InventoryFolder = UUID.Zero;
195 agentCircuit.startpos = position;
196 agentCircuit.child = true;
197 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
198 {
199 // brand new agent, let's create a new caps seed
200 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
201 }
202
203 string reason = String.Empty;
204
205 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
206 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
207 {
208 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
209 reason));
210 return;
211 }
212
213 // Let's close some agents
214 if (isHyperLink) // close them all except this one
215 {
216 List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
217 regions.Remove(avatar.Scene.RegionInfo.RegionHandle);
218 SendCloseChildAgentConnections(avatar.UUID, regions);
219 }
220 else // close just a few
221 avatar.CloseChildAgents(newRegionX, newRegionY);
222
223 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
224 {
225 capsPath
226 = "http://"
227 + reg.ExternalHostName
228 + ":"
229 + reg.HttpPort
230 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
231
232 if (eq != null)
233 {
234 #region IP Translation for NAT
235 IClientIPEndpoint ipepClient;
236 if (avatar.ClientView.TryGet(out ipepClient))
237 {
238 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
239 }
240 #endregion
241
242 eq.EnableSimulator(realHandle, endPoint, avatar.UUID);
243
244 // ES makes the client send a UseCircuitCode message to the destination,
245 // which triggers a bunch of things there.
246 // So let's wait
247 Thread.Sleep(2000);
248
249 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
250 }
251 else
252 {
253 avatar.ControllingClient.InformClientOfNeighbour(realHandle, endPoint);
254 // TODO: make Event Queue disablable!
255 }
256 }
257 else
258 {
259 // child agent already there
260 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
261 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
262 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
263 }
264
265 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
266 // position, false);
267
268 //if (!m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
269 // position, false))
270 //{
271 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
272 // // We should close that agent we just created over at destination...
273 // List<ulong> lst = new List<ulong>();
274 // lst.Add(realHandle);
275 // SendCloseChildAgentAsync(avatar.UUID, lst);
276 // return;
277 //}
278
279 SetInTransit(avatar.UUID);
280 // Let's send a full update of the agent. This is a synchronous call.
281 AgentData agent = new AgentData();
282 avatar.CopyTo(agent);
283 agent.Position = position;
284 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
285 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
286
287 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
288
289 m_log.DebugFormat(
290 "[CAPS]: Sending new CAPS seed url {0} to client {1}", agentCircuit.CapsPath, avatar.UUID);
291
292
293 ///
294 /// Hypergrid mod: realHandle instead of reg.RegionHandle
295 ///
296 ///
297 if (eq != null)
298 {
299 eq.TeleportFinishEvent(realHandle, 13, endPoint,
300 4, teleportFlags, capsPath, avatar.UUID);
301 }
302 else
303 {
304 avatar.ControllingClient.SendRegionTeleport(realHandle, 13, endPoint, 4,
305 teleportFlags, capsPath);
306 }
307 ///
308 /// Hypergrid mod stop
309 ///
310
311
312 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
313 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
314 // that the client contacted the destination before we send the attachments and close things here.
315 if (!WaitForCallback(avatar.UUID))
316 {
317 // Client never contacted destination. Let's restore everything back
318 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
319
320 ResetFromTransit(avatar.UUID);
321 // Yikes! We should just have a ref to scene here.
322 avatar.Scene.InformClientOfNeighbours(avatar);
323
324 // Finally, kill the agent we just created at the destination.
325 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
326
327 return;
328 }
329
330 // Can't go back from here
331 if (KiPrimitive != null)
332 {
333 KiPrimitive(avatar.LocalId);
334 }
335
336 avatar.MakeChildAgent();
337
338 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
339 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
340
341
342 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
343 ///
344 /// Hypergrid mod: extra check for isHyperLink
345 ///
346 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
347 {
348 Thread.Sleep(5000);
349 avatar.Close();
350 CloseConnection(avatar.UUID);
351 }
352 // if (teleport success) // seems to be always success here
353 // the user may change their profile information in other region,
354 // so the userinfo in UserProfileCache is not reliable any more, delete it
355 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID) || isHyperLink)
356 {
357 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
358 m_log.DebugFormat(
359 "[HGSceneCommService]: User {0} is going to another region, profile cache removed",
360 avatar.UUID);
361 }
362 }
363 else
364 {
365 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
366 }
367 }
368 else
369 {
370 // TP to a place that doesn't exist (anymore)
371 // Inform the viewer about that
372 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
373
374 // and set the map-tile to '(Offline)'
375 uint regX, regY;
376 Utils.LongToUInts(regionHandle, out regX, out regY);
377
378 MapBlockData block = new MapBlockData();
379 block.X = (ushort)(regX / Constants.RegionSize);
380 block.Y = (ushort)(regY / Constants.RegionSize);
381 block.Access = 254; // == not there
382
383 List<MapBlockData> blocks = new List<MapBlockData>();
384 blocks.Add(block);
385 avatar.ControllingClient.SendMapBlock(blocks, 0);
386 }
387 }
388 }
389
390 }
391}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
deleted file mode 100644
index 5d4e7ac..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
+++ /dev/null
@@ -1,56 +0,0 @@
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
28using System;
29using System.Collections.Generic;
30
31using OpenSim.Framework;
32using OpenSim.Services.Interfaces;
33using OpenMetaverse;
34
35namespace OpenSim.Region.Framework.Scenes.Hypergrid
36{
37 public class HGUuidGatherer : UuidGatherer
38 {
39 protected string m_assetServerURL;
40 protected HGAssetMapper m_assetMapper;
41
42 public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache)
43 {
44 m_assetMapper = assMap;
45 m_assetServerURL = assetServerURL;
46 }
47
48 protected override AssetBase GetAsset(UUID uuid)
49 {
50 if (string.Empty == m_assetServerURL)
51 return m_assetCache.Get(uuid.ToString());
52 else
53 return m_assetMapper.FetchAsset(m_assetServerURL, uuid);
54 }
55 }
56}