aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Local
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Communications/Local')
-rw-r--r--OpenSim/Region/Communications/Local/CommunicationsLocal.cs54
-rw-r--r--OpenSim/Region/Communications/Local/LocalBackEndServices.cs206
-rw-r--r--OpenSim/Region/Communications/Local/LocalUserServices.cs142
-rw-r--r--OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs33
4 files changed, 435 insertions, 0 deletions
diff --git a/OpenSim/Region/Communications/Local/CommunicationsLocal.cs b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
new file mode 100644
index 0000000..a047843
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/CommunicationsLocal.cs
@@ -0,0 +1,54 @@
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 OpenSim.Framework.Communications;
29using OpenSim.Framework.Types;
30using OpenSim.Framework.Servers;
31
32namespace OpenSim.Region.Communications.Local
33{
34 public class CommunicationsLocal : CommunicationsManager
35 {
36 public LocalBackEndServices SandBoxServices = new LocalBackEndServices();
37 public LocalUserServices UserServices;
38
39 public CommunicationsLocal(NetworkServersInfo serversInfo, BaseHttpServer httpServer )
40 : base(serversInfo, httpServer)
41 {
42 UserServices = new LocalUserServices(this, serversInfo);
43 UserServices.AddPlugin("OpenSim.Framework.Data.DB4o.dll");
44 UserServer = UserServices;
45 GridServer = SandBoxServices;
46 InterRegion = SandBoxServices;
47 }
48
49 internal void InformRegionOfLogin(ulong regionHandle, Login login)
50 {
51 this.SandBoxServices.AddNewSession(regionHandle, login);
52 }
53 }
54}
diff --git a/OpenSim/Region/Communications/Local/LocalBackEndServices.cs b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
new file mode 100644
index 0000000..d0cd991
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/LocalBackEndServices.cs
@@ -0,0 +1,206 @@
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.Collections.Generic;
29using libsecondlife;
30using OpenSim.Framework;
31using OpenSim.Framework.Communications;
32using OpenSim.Framework.Types;
33
34namespace OpenSim.Region.Communications.Local
35{
36
37 public class LocalBackEndServices : IGridServices, IInterRegionCommunications
38 {
39 protected Dictionary<ulong, RegionInfo> regions = new Dictionary<ulong, RegionInfo>();
40 protected Dictionary<ulong, RegionCommsListener> regionHosts = new Dictionary<ulong, RegionCommsListener>();
41
42 public LocalBackEndServices()
43 {
44
45 }
46
47 /// <summary>
48 /// Register a region method with the BackEnd Services.
49 /// </summary>
50 /// <param name="regionInfo"></param>
51 /// <returns></returns>
52 public RegionCommsListener RegisterRegion(RegionInfo regionInfo)
53 {
54 //Console.WriteLine("CommsManager - Region " + regionInfo.RegionHandle + " , " + regionInfo.RegionLocX + " , "+ regionInfo.RegionLocY +" is registering");
55 if (!this.regions.ContainsKey((uint)regionInfo.RegionHandle))
56 {
57 //Console.WriteLine("CommsManager - Adding Region " + regionInfo.RegionHandle );
58 this.regions.Add(regionInfo.RegionHandle, regionInfo);
59 RegionCommsListener regionHost = new RegionCommsListener();
60 this.regionHosts.Add(regionInfo.RegionHandle, regionHost);
61
62 return regionHost;
63 }
64
65 //already in our list of regions so for now lets return null
66 return null;
67 }
68
69 /// <summary>
70 /// </summary>
71 /// <param name="regionInfo"></param>
72 /// <returns></returns>
73 public List<RegionInfo> RequestNeighbours(RegionInfo regionInfo)
74 {
75 // Console.WriteLine("Finding Neighbours to " + regionInfo.RegionHandle);
76 List<RegionInfo> neighbours = new List<RegionInfo>();
77
78 foreach (RegionInfo reg in this.regions.Values)
79 {
80 // Console.WriteLine("CommsManager- RequestNeighbours() checking region " + reg.RegionLocX + " , "+ reg.RegionLocY);
81 if (reg.RegionHandle != regionInfo.RegionHandle)
82 {
83 //Console.WriteLine("CommsManager- RequestNeighbours() - found a different region in list, checking location");
84 if ((reg.RegionLocX > (regionInfo.RegionLocX - 2)) && (reg.RegionLocX < (regionInfo.RegionLocX + 2)))
85 {
86 if ((reg.RegionLocY > (regionInfo.RegionLocY - 2)) && (reg.RegionLocY < (regionInfo.RegionLocY + 2)))
87 {
88 neighbours.Add(reg);
89 }
90 }
91 }
92 }
93 return neighbours;
94 }
95
96 /// <summary>
97 ///
98 /// </summary>
99 /// <param name="regionHandle"></param>
100 /// <returns></returns>
101 public RegionInfo RequestNeighbourInfo(ulong regionHandle)
102 {
103 if (this.regions.ContainsKey(regionHandle))
104 {
105 return this.regions[regionHandle];
106 }
107 return null;
108 }
109
110 /// <summary>
111 ///
112 /// </summary>
113 /// <param name="minX"></param>
114 /// <param name="minY"></param>
115 /// <param name="maxX"></param>
116 /// <param name="maxY"></param>
117 /// <returns></returns>
118 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
119 {
120 List<MapBlockData> mapBlocks = new List<MapBlockData>();
121 foreach(RegionInfo regInfo in this.regions.Values)
122 {
123 if (((regInfo.RegionLocX >= minX) && (regInfo.RegionLocX <= maxX)) && ((regInfo.RegionLocY >= minY) && (regInfo.RegionLocY <= maxY)))
124 {
125 MapBlockData map = new MapBlockData();
126 map.Name = regInfo.RegionName;
127 map.X = (ushort)regInfo.RegionLocX;
128 map.Y = (ushort)regInfo.RegionLocY;
129 map.WaterHeight =(byte) regInfo.estateSettings.waterHeight;
130 map.MapImageId = regInfo.estateSettings.terrainImageID; //new LLUUID("00000000-0000-0000-9999-000000000007");
131 map.Agents = 1;
132 map.RegionFlags = 72458694;
133 map.Access = 13;
134 mapBlocks.Add(map);
135 }
136 }
137 return mapBlocks;
138 }
139
140 /// <summary>
141 /// </summary>
142 /// <param name="regionHandle"></param>
143 /// <param name="agentData"></param>
144 /// <returns></returns>
145 public bool InformRegionOfChildAgent(ulong regionHandle, AgentCircuitData agentData) //should change from agentCircuitData
146 {
147 //Console.WriteLine("CommsManager- Trying to Inform a region to expect child agent");
148 if (this.regionHosts.ContainsKey(regionHandle))
149 {
150 // Console.WriteLine("CommsManager- Informing a region to expect child agent");
151 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agentData);
152 return true;
153 }
154 return false;
155 }
156
157 /// <summary>
158 ///
159 /// </summary>
160 /// <param name="regionHandle"></param>
161 /// <param name="agentID"></param>
162 /// <param name="position"></param>
163 /// <returns></returns>
164 public bool ExpectAvatarCrossing(ulong regionHandle, LLUUID agentID, LLVector3 position)
165 {
166 if (this.regionHosts.ContainsKey(regionHandle))
167 {
168 // Console.WriteLine("CommsManager- Informing a region to expect avatar crossing");
169 this.regionHosts[regionHandle].TriggerExpectAvatarCrossing(regionHandle, agentID, position);
170 return true;
171 }
172 return false;
173 }
174
175 /// <summary>
176 /// Is a Sandbox mode method, used by the local Login server to inform a region of a connection user/session
177 /// </summary>
178 /// <param name="regionHandle"></param>
179 /// <param name="loginData"></param>
180 /// <returns></returns>
181 public bool AddNewSession(ulong regionHandle, Login loginData)
182 {
183 AgentCircuitData agent = new AgentCircuitData();
184 agent.AgentID = loginData.Agent;
185 agent.firstname = loginData.First;
186 agent.lastname = loginData.Last;
187 agent.SessionID = loginData.Session;
188 agent.SecureSessionID = loginData.SecureSession;
189 agent.circuitcode = loginData.CircuitCode;
190 agent.BaseFolder = loginData.BaseFolder;
191 agent.InventoryFolder = loginData.InventoryFolder;
192 agent.startpos = new LLVector3(128, 128, 70);
193 agent.CapsPath = loginData.CapsPath;
194
195 if (this.regionHosts.ContainsKey(regionHandle))
196 {
197 this.regionHosts[regionHandle].TriggerExpectUser(regionHandle, agent);
198 return true;
199 }
200
201 // region not found
202 return false;
203 }
204 }
205}
206
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs
new file mode 100644
index 0000000..592b36c
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs
@@ -0,0 +1,142 @@
1using System;
2using libsecondlife;
3using OpenSim.Framework.Communications;
4using OpenSim.Framework.Data;
5using OpenSim.Framework.Types;
6using OpenSim.Framework.UserManagement;
7using OpenSim.Framework.Utilities;
8
9namespace OpenSim.Region.Communications.Local
10{
11 public class LocalUserServices : UserManagerBase, IUserServices
12 {
13 private CommunicationsLocal m_Parent;
14
15 private NetworkServersInfo serversInfo;
16 private uint defaultHomeX ;
17 private uint defaultHomeY;
18 public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData)
19 {
20 m_Parent = parent;
21 this.serversInfo = serversData;
22 defaultHomeX = this.serversInfo.DefaultHomeLocX;
23 defaultHomeY = this.serversInfo.DefaultHomeLocY;
24 }
25
26 public UserProfileData GetUserProfile(string firstName, string lastName)
27 {
28 return GetUserProfile(firstName + " " + lastName);
29 }
30
31 public UserProfileData GetUserProfile(string name)
32 {
33 return this.getUserProfile(name);
34 }
35
36 public UserProfileData GetUserProfile(LLUUID avatarID)
37 {
38 return this.getUserProfile(avatarID);
39 }
40
41 /// <summary>
42 ///
43 /// </summary>
44 /// <returns></returns>
45 public override string GetMessage()
46 {
47 return "Welcome to OpenSim";
48 }
49
50 public override UserProfileData GetTheUser(string firstname, string lastname)
51 {
52 UserProfileData profile = getUserProfile(firstname, lastname);
53 if (profile != null)
54 {
55
56 return profile;
57 }
58
59 //no current user account so make one
60 Console.WriteLine("No User account found so creating a new one ");
61 this.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
62
63 profile = getUserProfile(firstname, lastname);
64
65 return profile;
66 }
67
68 public override bool AuthenticateUser(UserProfileData profile, string password)
69 {
70 //for now we will accept any password in sandbox mode
71 Console.WriteLine("authorising user");
72 return true;
73 }
74
75 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
76 {
77 ulong currentRegion = theUser.currentAgent.currentHandle;
78 RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion);
79
80 if (reg != null)
81 {
82 response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
83 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
84 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
85 string capsPath = Util.GetRandomCapsPath();
86 response.SimAddress = reg.ExternalEndPoint.Address.ToString();
87 response.SimPort = (Int32)reg.ExternalEndPoint.Port;
88 response.RegionX = reg.RegionLocX ;
89 response.RegionY = reg.RegionLocY ;
90
91 //following port needs changing as we don't want a http listener for every region (or do we?)
92 response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
93 theUser.currentAgent.currentRegion = reg.SimUUID;
94 theUser.currentAgent.currentHandle = reg.RegionHandle;
95
96 Login _login = new Login();
97 //copy data to login object
98 _login.First = response.Firstname;
99 _login.Last = response.Lastname;
100 _login.Agent = response.AgentID;
101 _login.Session = response.SessionID;
102 _login.SecureSession = response.SecureSessionID;
103 _login.CircuitCode = (uint)response.CircuitCode;
104 _login.CapsPath = capsPath;
105
106 m_Parent.InformRegionOfLogin(currentRegion, _login);
107 }
108 else
109 {
110 Console.WriteLine("not found region " + currentRegion);
111 }
112
113 }
114
115 public UserProfileData SetupMasterUser(string firstName, string lastName)
116 {
117 return SetupMasterUser(firstName, lastName, "");
118 }
119
120 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
121 {
122 UserProfileData profile = getUserProfile(firstName, lastName);
123 if (profile != null)
124 {
125
126 return profile;
127 }
128
129 Console.WriteLine("Unknown Master User. Sandbox Mode: Creating Account");
130 this.AddUserProfile(firstName, lastName, password, defaultHomeX, defaultHomeY);
131
132 profile = getUserProfile(firstName, lastName);
133
134 if (profile == null)
135 {
136 Console.WriteLine("Unknown Master User after creation attempt. No clue what to do here.");
137 }
138
139 return profile;
140 }
141 }
142}
diff --git a/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..9afb75e
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
1using System.Reflection;
2using System.Runtime.InteropServices;
3// General Information about an assembly is controlled through the following
4// set of attributes. Change these attribute values to modify the information
5// associated with an assembly.
6[assembly: AssemblyTitle("OpenSim.Region.Communications.Local")]
7[assembly: AssemblyDescription("")]
8[assembly: AssemblyConfiguration("")]
9[assembly: AssemblyCompany("")]
10[assembly: AssemblyProduct("OpenSim.Region.Communications.Local")]
11[assembly: AssemblyCopyright("Copyright © 2007")]
12[assembly: AssemblyTrademark("")]
13[assembly: AssemblyCulture("")]
14
15// Setting ComVisible to false makes the types in this assembly not visible
16// to COM components. If you need to access a type in this assembly from
17// COM, set the ComVisible attribute to true on that type.
18[assembly: ComVisible(false)]
19
20// The following GUID is for the ID of the typelib if this project is exposed to COM
21[assembly: Guid("fb173926-bd0a-4cd0-bb45-185b2f72ddfb")]
22
23// Version information for an assembly consists of the following four values:
24//
25// Major Version
26// Minor Version
27// Build Number
28// Revision
29//
30// You can specify all the values or you can default the Revision and Build Numbers
31// by using the '*' as shown below:
32[assembly: AssemblyVersion("1.0.0.0")]
33[assembly: AssemblyFileVersion("1.0.0.0")]