aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs
diff options
context:
space:
mode:
authorMW2007-06-16 14:29:11 +0000
committerMW2007-06-16 14:29:11 +0000
commit3c8daee51027c5beb857e78c1972db0936761af3 (patch)
tree1d27af6f5af1cc2085fc4f874047fdf990f0fed5 /OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs
parentVery Preliminary border crossing added to sugilite. (Note: Sugilite doesn't h... (diff)
downloadopensim-SC-3c8daee51027c5beb857e78c1972db0936761af3.zip
opensim-SC-3c8daee51027c5beb857e78c1972db0936761af3.tar.gz
opensim-SC-3c8daee51027c5beb857e78c1972db0936761af3.tar.bz2
opensim-SC-3c8daee51027c5beb857e78c1972db0936761af3.tar.xz
Some Rearranging of CommsManager.
Diffstat (limited to 'OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs')
-rw-r--r--OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs179
1 files changed, 179 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs b/OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs
new file mode 100644
index 0000000..dfc4505
--- /dev/null
+++ b/OpenSim/OpenSim.LocalCommunications/LocalBackEndServices.cs
@@ -0,0 +1,179 @@
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 OpenGrid.Framework.Communications;
32using libsecondlife;
33using OpenSim.Framework.Types;
34using OpenSim.Framework;
35
36namespace OpenSim.LocalCommunications
37{
38
39
40 public class LocalBackEndServices : IGridServices, IInterRegionCommunications
41 {
42 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
43 protected Dictionary<ulong, RegionCommsHostBase> regionHosts = new Dictionary<ulong, RegionCommsHostBase>();
44
45 public LocalBackEndServices()
46 {
47
48 }
49
50 /// <summary>
51 /// Register a region method with the BackEnd Services.
52 /// </summary>
53 /// <param name="regionInfo"></param>
54 /// <returns></returns>
55 public RegionCommsHostBase RegisterRegion(RegionInfo regionInfo)
56 {
57 //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
58 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
59 {
60 //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle );
61 this.regions.Add(regionInfo.RegionHandle, regionInfo);
62 RegionCommsHostBase regionHost = new RegionCommsHostBase();
63 this.regionHosts.Add(regionInfo.RegionHandle, regionHost);
64
65 return regionHost;
66 }
67
68 //already in our list of regions so for now lets return null
69 return null;
70 }
71
72 /// <summary>
73 /// </summary>
74 /// <param name="regionInfo"></param>
75 /// <returns></returns>
76 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo)
77 {
78 // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle);
79 List<RegionInfo> neighbours = new List<RegionInfo>();
80
81 foreach (RegionInfo reg in this.regions.Values)
82 {
83 // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
84 if (reg.RegionHandle != regionInfo.RegionHandle)
85 {
86 //Console.WriteLine("CommsManager- RequestNeighbours() - found a different region in list, checking location");
87 if ((reg.RegionLocX > (regionInfo.RegionLocX - 2)) && (reg.RegionLocX < (regionInfo.RegionLocX + 2)))
88 {
89 if ((reg.RegionLocY > (regionInfo.RegionLocY - 2)) && (reg.RegionLocY < (regionInfo.RegionLocY + 2)))
90 {
91 neighbours.Add(reg);
92 }
93 }
94 }
95 }
96 return neighbours;
97 }
98
99 /// <summary>
100 ///
101 /// </summary>
102 /// <param name="regionHandle"></param>
103 /// <returns></returns>
104 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
105 {
106 if (this.regions.ContainsKey(regionHandle))
107 {
108 return this.regions[regionHandle];
109 }
110 return null;
111 }
112
113 /// <summary>
114 /// </summary>
115 /// <param name="regionHandle"></param>
116 /// <param name="agentData"></param>
117 /// <returns></returns>
118 public bool InformNeighbourOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData
119 {
120 //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent");
121 if (this.regionHosts.ContainsKey(regionHandle))
122 {
123 // Console.WriteLine("CommsManager- Informing a region to expect child agent");
124 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData);
125 return true;
126 }
127 return false;
128 }
129
130 /// <summary>
131 ///
132 /// </summary>
133 /// <param name="regionHandle"></param>
134 /// <param name="agentID"></param>
135 /// <param name="position"></param>
136 /// <returns></returns>
137 public bool ExpectAvatarCrossing(ulong regionHandle, libsecondlife.LLUUID agentID, libsecondlife.LLVector3 position)
138 {
139 if (this.regionHosts.ContainsKey(regionHandle))
140 {
141 // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing");
142 this.regionHosts[regionHandle].ExpectAvatarCrossing(regionHandle, agentID, position);
143 return true;
144 }
145 return false;
146 }
147
148 /// <summary>
149 /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
150 /// </summary>
151 /// <param name="regionHandle"></param>
152 /// <param name="loginData"></param>
153 /// <returns></returns>
154 public bool AddNewSession(ulong regionHandle, Login loginData)
155 {
156 //Console.WriteLine(" comms manager been told to expect new user");
157 AgentCircuitData agent = new AgentCircuitData();
158 agent.AgentID = loginData.Agent;
159 agent.firstname = loginData.First;
160 agent.lastname = loginData.Last;
161 agent.SessionID = loginData.Session;
162 agent.SecureSessionID = loginData.SecureSession;
163 agent.circuitcode = loginData.CircuitCode;
164 agent.BaseFolder = loginData.BaseFolder;
165 agent.InventoryFolder = loginData.InventoryFolder;
166 agent.startpos = new LLVector3(128, 128, 70);
167
168 if (this.regionHosts.ContainsKey(regionHandle))
169 {
170 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent);
171 return true;
172 }
173
174 // region not found
175 return false;
176 }
177 }
178}
179