aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
diff options
context:
space:
mode:
authormingchen2007-06-27 16:55:27 +0000
committermingchen2007-06-27 16:55:27 +0000
commite392e222a83ee04ee25c00e26dfad5f47ffa69b8 (patch)
tree03e48283f634b86cc8773d88b42ab849ac999895 /OpenSim/Region/Communications/Local/LocalBackEndServices.cs
parent*Some more restructuring/fixing -- should compile, but high chance I forgot t... (diff)
downloadopensim-SC_OLD-e392e222a83ee04ee25c00e26dfad5f47ffa69b8.zip
opensim-SC_OLD-e392e222a83ee04ee25c00e26dfad5f47ffa69b8.tar.gz
opensim-SC_OLD-e392e222a83ee04ee25c00e26dfad5f47ffa69b8.tar.bz2
opensim-SC_OLD-e392e222a83ee04ee25c00e26dfad5f47ffa69b8.tar.xz
*Added some missing files I forgot to add...OpenSim.sln should compile now
Diffstat (limited to 'OpenSim/Region/Communications/Local/LocalBackEndServices.cs')
-rw-r--r--OpenSim/Region/Communications/Local/LocalBackEndServices.cs209
1 files changed, 209 insertions, 0 deletions
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
new file mode 100644
index 0000000..ae47890
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
@@ -0,0 +1,209 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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 OpenSim 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.Text;
31using libsecondlife;
32using OpenSim.Framework.Types;
33using OpenSim.Framework;
34using OpenSim.Framework.Communications;
35
36namespace OpenSim.Region.Communications.Local
37{
38
39 public class LocalBackEndServices : IGridServices, IInterRegionCommunications
40 {
41 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
42 protected Dictionary<ulong, RegionCommsListener> regionHosts = new Dictionary<ulong, RegionCommsListener>();
43
44 public LocalBackEndServices()
45 {
46
47 }
48
49 /// <summary>
50 /// Register a region method with the BackEnd Services.
51 /// </summary>
52 /// <param name="regionInfo"></param>
53 /// <returns></returns>
54 public RegionCommsListener RegisterRegion(RegionInfo regionInfo, GridInfo gridInfo)
55 {
56 //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
57 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
58 {
59 //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle );
60 this.regions.Add(regionInfo.RegionHandle, regionInfo);
61 RegionCommsListener regionHost = new RegionCommsListener();
62 this.regionHosts.Add(regionInfo.RegionHandle, regionHost);
63
64 return regionHost;
65 }
66
67 //already in our list of regions so for now lets return null
68 return null;
69 }
70
71 /// <summary>
72 /// </summary>
73 /// <param name="regionInfo"></param>
74 /// <returns></returns>
75 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo)
76 {
77 // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle);
78 List<RegionInfo> neighbours = new List<RegionInfo>();
79
80 foreach (RegionInfo reg in this.regions.Values)
81 {
82 // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
83 if (reg.RegionHandle != regionInfo.RegionHandle)
84 {
85 //Console.WriteLine("CommsManager- RequestNeighbours() - found a different region in list, checking location");
86 if ((reg.RegionLocX > (regionInfo.RegionLocX - 2)) && (reg.RegionLocX < (regionInfo.RegionLocX + 2)))
87 {
88 if ((reg.RegionLocY > (regionInfo.RegionLocY - 2)) && (reg.RegionLocY < (regionInfo.RegionLocY + 2)))
89 {
90 neighbours.Add(reg);
91 }
92 }
93 }
94 }
95 return neighbours;
96 }
97
98 /// <summary>
99 ///
100 /// </summary>
101 /// <param name="regionHandle"></param>
102 /// <returns></returns>
103 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
104 {
105 if (this.regions.ContainsKey(regionHandle))
106 {
107 return this.regions[regionHandle];
108 }
109 return null;
110 }
111
112 /// <summary>
113 ///
114 /// </summary>
115 /// <param name="minX"></param>
116 /// <param name="minY"></param>
117 /// <param name="maxX"></param>
118 /// <param name="maxY"></param>
119 /// <returns></returns>
120 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
121 {
122 List<MapBlockData> mapBlocks = new List<MapBlockData>();
123 foreach(RegionInfo regInfo in this.regions.Values)
124 {
125 if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
126 {
127 MapBlockData map = new MapBlockData();
128 map.Name = regInfo.RegionName;
129 map.X = (ushort)regInfo.RegionLocX;
130 map.Y = (ushort)regInfo.RegionLocY;
131 map.WaterHeight =(byte) regInfo.estateSettings.waterHeight;
132 map.MapImageId = regInfo.estateSettings.terrainImageID; //new LLUUID("00000000-0000-0000-9999-000000000007");
133 map.Agents = 1;
134 map.RegionFlags = 72458694;
135 map.Access = 13;
136 mapBlocks.Add(map);
137 }
138 }
139 return mapBlocks;
140 }
141
142 /// <summary>
143 /// </summary>
144 /// <param name="regionHandle"></param>
145 /// <param name="agentData"></param>
146 /// <returns></returns>
147 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData
148 {
149 //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent");
150 if (this.regionHosts.ContainsKey(regionHandle))
151 {
152 // Console.WriteLine("CommsManager- Informing a region to expect child agent");
153 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData);
154 return true;
155 }
156 return false;
157 }
158
159 /// <summary>
160 ///
161 /// </summary>
162 /// <param name="regionHandle"></param>
163 /// <param name="agentID"></param>
164 /// <param name="position"></param>
165 /// <returns></returns>
166 public bool ExpectAvatarCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position)
167 {
168 if (this.regionHosts.ContainsKey(regionHandle))
169 {
170 // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing");
171 this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
172 return true;
173 }
174 return false;
175 }
176
177 /// <summary>
178 /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
179 /// </summary>
180 /// <param name="regionHandle"></param>
181 /// <param name="loginData"></param>
182 /// <returns></returns>
183 public bool AddNewSession(ulong regionHandle, Login loginData)
184 {
185 //Console.WriteLine(" comms manager been told to expect new user");
186 AgentCircuitData agent = new AgentCircuitData();
187 agent.AgentID = loginData.Agent;
188 agent.firstname = loginData.First;
189 agent.lastname = loginData.Last;
190 agent.SessionID = loginData.Session;
191 agent.SecureSessionID = loginData.SecureSession;
192 agent.circuitcode = loginData.CircuitCode;
193 agent.BaseFolder = loginData.BaseFolder;
194 agent.InventoryFolder = loginData.InventoryFolder;
195 agent.startpos = new LLVector3(128, 128, 70);
196 agent.CapsPath = loginData.CapsPath;
197
198 if (this.regionHosts.ContainsKey(regionHandle))
199 {
200 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent);
201 return true;
202 }
203
204 // region not found
205 return false;
206 }
207 }
208}
209